diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-20 12:10:15 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-20 12:10:15 +0000 |
commit | 34dad8557132bc730db8e502684f12e4c247c24d (patch) | |
tree | 1091587c85289cf0f4265dfb5e7c36351b26f368 /spec/controllers/user_controller_spec.rb | |
parent | f596a8983ae514da5c41cfc280598f3946747c47 (diff) |
Be sure to restore RoutingFilters
There were some order-dependent test failures that turned out to
be caused by the fact that the RoutingFilters were cleared and
not subsequently restored, by some tests.
Diffstat (limited to 'spec/controllers/user_controller_spec.rb')
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 0cf574aa9..d8e92fbd0 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -96,7 +96,9 @@ describe UserController, "when signing in" do end it "should log in when you give right email/password, and redirect to where you were" do - ActionController::Routing::Routes.filters.clear + old_filters = ActionController::Routing::Routes.filters + ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + get :signin, :r => "/list" response.should render_template('sign') post_redirect = get_last_postredirect @@ -107,10 +109,14 @@ describe UserController, "when signing in" do # response doesn't contain /en/ but redirect_to does... response.should redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1) response.should_not send_email + + ActionController::Routing::Routes.filters = old_filters end it "should not log you in if you use an invalid PostRedirect token, and shouldn't give 500 error either" do - ActionController::Routing::Routes.filters.clear + old_filters = ActionController::Routing::Routes.filters + ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + post_redirect = "something invalid" lambda { post :signin, { :user_signin => { :email => 'bob@localhost', :password => 'jonespassword' }, @@ -121,6 +127,8 @@ describe UserController, "when signing in" do :token => post_redirect } response.should render_template('sign') assigns[:post_redirect].should == nil + + ActionController::Routing::Routes.filters = old_filters end # No idea how to test this in the test framework :( @@ -144,7 +152,9 @@ describe UserController, "when signing in" do end it "should confirm your email, log you in and redirect you to where you were after you click an email link" do - ActionController::Routing::Routes.filters.clear + old_filters = ActionController::Routing::Routes.filters + ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + get :signin, :r => "/list" post_redirect = get_last_postredirect @@ -170,6 +180,8 @@ describe UserController, "when signing in" do get :confirm, :email_token => post_redirect.email_token session[:user_id].should == users(:unconfirmed_user).id response.should redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1) + + ActionController::Routing::Routes.filters = old_filters end end @@ -244,11 +256,15 @@ describe UserController, "when signing out" do end it "should log you out and redirect you to where you were" do - ActionController::Routing::Routes.filters.clear + old_filters = ActionController::Routing::Routes.filters + ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + session[:user_id] = users(:bob_smith_user).id get :signout, :r => '/list' session[:user_id].should be_nil response.should redirect_to(:controller => 'request', :action => 'list') + + ActionController::Routing::Routes.filters = old_filters end end |