How to check Rails logging from console?

I had time to figure out how to log in and out using the response objects from Rails. Standard blogs were fine, but I finally diagnosed it and I wanted to write it here.

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 

Note. From the above it follows that you redirect after an unsuccessful auth request, and also redirect it after logging in.

To ensure that you load fixtures into the DB test environment (which usually occurs during the rake test), make sure that you do the following:

  rake db:fixtures:load RAILS_ENV=test 

(From Patrick Ritchie) The default URL will look like "www.example.com" since this host is set to ActionController :: Integration :: Session by default

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

It is installed in actionpack / lib / action_controller / integration.rb # 75

To change it in the integration test, do the following:

 session = open_session do |s| s.host = 'my-example-host.com' end 
+6
ruby ruby-on-rails
source share
1 answer

'www.example.com' is the default host set in ActionController :: Integration :: Session

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

It is installed in actionpack / lib / action_controller / integration.rb # 75

You can change it in your integration test by following these steps:

 session = open_session do |s| s.host = 'my-example-host.com' end 
+2
source share

All Articles