Forum: Ruby on Rails assert_redirected_to not working as expected

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
stan.baptista (Guest)
on 2007-01-19 17:30
(Received via mailing list)
I've installed the "acts_as_authenticated" plugin and made some
modifications to the controller (app/controllers/account_controller.rb)
"signup" module as follows:

===
 def signup
   @page_title = 'Create Account'
   @user = User.new(@params[:user])
   if request.post?
     if @user.save
       session[:user] = User.authenticate(@user.login, @user.password)
       redirect_to(:controller => '/home', :action => 'welcome')
     else
       flash[:notice] = "Signup unsuccessful!"
     end
   end
 end
===

The "success" integration test
(test/integration/authentication_test.rb) looks like this (snipped):

===
class AuthenticationTest < ActionController::IntegrationTest
 def setup
   User.create(:login => "goober",
               :email => "removed_email_address@domain.invalid",
               :password => "gomer",
               :password_confirmation => "gomer")
 end

 ...

 def test_successful_signup
   gooddog = enter_site(:gooddog)
   gooddog.signs_up_successfully
 end

 ...

 private

 module BrowsingTestDSL
   include ERB::Util
   attr_writer :name

 ...

   def signs_up_successfully
     post_signup("gooddog", "removed_email_address@domain.invalid", "gooddog",
"gooddog")
     assert_redirected_to :controller => "home", :action => "welcome"
   end
 ...

   private

   def post_signup(login, email, password, confirm_password)
     post "/account/signup", :login => login, :email => email,
:password => password, :confirm_password => confirm_password
   end

 end

 def enter_site(name)
   open_session do |session|
     session.extend(BrowsingTestDSL)
     session.name = name
     yield session if block_given?
   end
 end
end

===

I'm on Windows and am running the test using this command:

> ruby test/integration/authentication_test.rb - n test_successful_signup

Resulting in:

"Expected response to be a <:redirect>, but was <200>"

Running live produces the desired behavior, i.e., a new user is
created, data stored in the database, and the user is redirected to a
Welcome page.

Is there something(s) about the test environment that I've missed?

Thanks,

Stan
This topic is locked and can not be replied to.