我有一件了不起的时间,找出如何登录以及注销使用响应的对象从轨道。标准的博客被确定,但我最后确诊了,所以我想来记录它在这里。

app.get '/'
assert_response :success
app.get '/auth_only_url'
assert_response 302
user = User.find(:user_to_login)
app.post '/signin_url', 
              :user_email => user.email, 
              :user_password => '<password in clear>'
assert_response 302
app.follow_redirect!
assert_response :success
app.get '/auth_only_url'
assert_response :success

注意,上述意味着重新定向后的一个失败的授权请求,并还认为您重新定向后的登录。

确保你载装置进入你的测试环境DB(通常发生在瑞克试验),确保执行如下:

 rake db:fixtures:load RAILS_ENV=test

(从帕特里克瑞奇) 默认的URL将出现'www.example.com',因为这个默认的主机设在ActionController::Integration::会话

ActionController::Integration::Session.new.host=> "www.example.com"

它被设置在actionpack/lib/action_controller/一体化。rb#75

去改变它在一体化试验中,做到以下几点:

session = open_session do |s|  s.host = 'my-example-host.com' end
有帮助吗?

解决方案

'www.example.com'是的默认主办作为设在ActionController::Integration::会话

>> ActionController::Integration::Session.new.host
=> "www.example.com"

它被设置在actionpack/lib/action_controller/一体化。rb#75

你应该能够改变它在你的整合测试的,通过做如下:

session = open_session do |s|
  s.host = 'my-example-host.com'
end
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top