开发者

Rails 3 - How can I get rid of "test.host"?

开发者 https://www.devze.com 2023-03-14 03:57 出处:网络
I recently installed a plugin called Gretel to take care of breadcrumbs for me. It seems to be working great, except that it appears to be breaking some of my specs with the following error:

I recently installed a plugin called Gretel to take care of breadcrumbs for me. It seems to be working great, except that it appears to be breaking some of my specs with the following error:

 Fa开发者_运维百科ilure/Error: response.should redirect_to @course
 Expected response to be a redirect to </courses/904> but was a redirect to
 <http://test.host/courses/904>

What can I do to get rid of this error? The path seems totally correct, with the exception of that pesky test.host thing.


You are probably testing against my_model_url instead of my_model_path

The former does a full URI - including the host. The latter is a relative path without the host.

Go have a check in your controller and see if it uses _path or _url - and use the same one in your test-cases.


You need to expliclty define your request body..Here i have Application that uses rails 3.0...i am using Devise for authentication..and i get a customised domain that user specifies.

#get user from fixtures OR create them

  @user = users(:user1)

  #used devise "sign_in for testing"

    sign_in :user, @user  
  #defined my request

   request.host = 'myblog.free-blog.com'

  #get 'show_blog"

  get 'show'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号