3

I'm running integration tests to make sure my before_filter is redirecting to root_path if the user is not logged in. Everything seems to be working fine, but I'm seeing http://www.example.com/ in the Redirected to message in log/test.log, and I'm just wondering if this is normal, or if there's a configuration that I missed somewhere. Thanks!

log/test.log

Started PUT "/users/980190963" for 127.0.0.1 at 2012-07-29 13:31:39 -0700
Processing by UsersController#update as HTML
  Parameters: {"user"=>{"password"=>"[FILTERED]"}, "id"=>"980190963"}
Redirected to http://www.example.com/
Filter chain halted as :reject_if_logged_out rendered or redirected
Completed 302 Found in 1ms (ActiveRecord: 0.0ms)

users_controller.rb

...
before_filter :reject_if_logged_out, only: [:update]
...
private
def reject_if_logged_out
  redirect_to root_path unless @current_user
end
user664833
  • 18,397
  • 19
  • 91
  • 140

2 Answers2

2

Strangely enough, only some of my apps seems to do this. But this has been answered here before, it's the default and here's how to change it: How do I change the default "www.example.com" domain for testing in rails?

Community
  • 1
  • 1
bento
  • 2,079
  • 1
  • 16
  • 13
1

Because that's the default in in capybara, the library that cucumber and many other testing frameworks for rails use. See lib/capybara.rb:

Capybara.configure do |config|
  # ...
  config.default_host = "http://www.example.com"
  # ...
end

So if you do not specify anything else in your configuration the default value for @request.host is www.example.com.

iblue
  • 29,609
  • 19
  • 89
  • 128