From 646e211b9a45093f37a18661bdb3501508234387 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 6 Jan 2012 16:24:37 +0000 Subject: Make test less brittle --- spec/controllers/user_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/controllers/user_controller_spec.rb') diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index cf50bcc7a..c13d7c9fc 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -32,10 +32,10 @@ describe UserController, "when showing a user" do session[:user_id] = users(:bob_smith_user).id get :show, :url_name => "bob_smith", :view => 'requests' response.body.should_not include("Change your password") - response.body.should include("Freedom of Information requests") + response.body.should match(/Your [0-9]+ Freedom of Information requests/) get :show, :url_name => "bob_smith", :view => 'profile' response.body.should include("Change your password") - response.body.should_not include("Freedom of Information requests") + response.body.should_not match(/Your [0-9]+ Freedom of Information requests/) end it "should assign the user" do -- cgit v1.2.3 From 4e8307fe7bd88b6cdd9840a94f8275354aae0bd8 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 11 Jan 2012 09:11:18 +0000 Subject: Don't give an error to users with an invalid postredirect token. Closes #334. --- spec/controllers/user_controller_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'spec/controllers/user_controller_spec.rb') diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index c13d7c9fc..2560b48c7 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -109,6 +109,19 @@ describe UserController, "when signing in" do response.should_not send_email 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 + get :signin, :r => "/list" + response.should render_template('sign') + post_redirect = "something invalid" + lambda { + post :signin, { :user_signin => { :email => 'bob@localhost', :password => 'jonespassword' }, + :token => post_redirect + } + }.should_not raise_error(NoMethodError) + response.should render_template('sign') + end + # No idea how to test this in the test framework :( # it "should have set a long lived cookie if they picked remember me, session cookie if they didn't" do # get :signin, :r => "/list" -- cgit v1.2.3 From be9aa2c2d19199084e12d6318feeb48db2287331 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Thu, 12 Jan 2012 08:39:35 +0000 Subject: Accounts using expired PostRedirects were still causing 500 errors. Fixes #334 (again) --- spec/controllers/user_controller_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'spec/controllers/user_controller_spec.rb') diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 2560b48c7..30ad61706 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -111,15 +111,16 @@ describe UserController, "when signing in" do 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 - get :signin, :r => "/list" - response.should render_template('sign') post_redirect = "something invalid" lambda { post :signin, { :user_signin => { :email => 'bob@localhost', :password => 'jonespassword' }, :token => post_redirect } }.should_not raise_error(NoMethodError) + post :signin, { :user_signin => { :email => 'bob@localhost', :password => 'jonespassword' }, + :token => post_redirect } response.should render_template('sign') + assigns[:post_redirect].should == nil end # No idea how to test this in the test framework :( -- cgit v1.2.3