From c9feb6a4002fc4b63021aeb5ffd6b2846ada7748 Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Tue, 11 Dec 2012 15:00:40 +1100 Subject: integrate_views is render_views RSpec 2 --- spec/controllers/user_controller_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 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 23006803b..db64bdcaf 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -5,7 +5,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') # http://rspec.rubyforge.org/rspec-rails/1.1.12/classes/Spec/Rails/Example/ControllerExampleGroup.html describe UserController, "when showing a user" do - integrate_views + render_views before(:each) do load_raw_emails_data get_fixtures_xapian_index @@ -64,7 +64,7 @@ describe UserController, "when showing a user" do end describe UserController, "when signing in" do - integrate_views + render_views def get_last_postredirect post_redirects = PostRedirect.find_by_sql("select * from post_redirects order by id desc limit 1") @@ -228,7 +228,7 @@ describe UserController, "when signing in" do end describe UserController, "when signing up" do - integrate_views + render_views it "should be an error if you type the password differently each time" do post :signup, { :user_signup => { :email => 'new@localhost', :name => 'New Person', @@ -285,7 +285,7 @@ describe UserController, "when signing up" do end describe UserController, "when signing out" do - integrate_views + render_views it "should log you out and redirect to the home page" do session[:user_id] = users(:bob_smith_user).id @@ -309,7 +309,7 @@ describe UserController, "when signing out" do end describe UserController, "when sending another user a message" do - integrate_views + render_views it "should redirect to signin page if you go to the contact form and aren't signed in" do get :contact, :id => users(:silly_name_user) @@ -346,7 +346,7 @@ describe UserController, "when sending another user a message" do end describe UserController, "when changing password" do - integrate_views + render_views it "should show the email form when not logged in" do get :signchangepassword @@ -416,7 +416,7 @@ describe UserController, "when changing password" do end describe UserController, "when changing email address" do - integrate_views + render_views it "should require login" do get :signchangeemail @@ -561,7 +561,7 @@ describe UserController, "when changing email address" do end describe UserController, "when using profile photos" do - integrate_views + render_views before do @user = users(:bob_smith_user) @@ -631,7 +631,7 @@ describe UserController, "when showing JSON version for API" do end describe UserController, "when viewing the wall" do - integrate_views + render_views before(:each) do get_fixtures_xapian_index -- cgit v1.2.3 From 8ab884f0da68b17f33577a197ebd0e7d412a28ed Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 25 Jan 2013 11:23:43 +1100 Subject: Disable routing filter in tests by using RoutingFilter.active rather than writing to ActionController::Routing::Routes.filters --- spec/controllers/user_controller_spec.rb | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 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 db64bdcaf..dcd08dfaa 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -100,8 +100,7 @@ describe UserController, "when signing in" do end it "should log in when you give right email/password, and redirect to where you were" do - old_filters = ActionController::Routing::Routes.filters - ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + RoutingFilter.active = false get :signin, :r => "/list" response.should render_template('sign') @@ -114,12 +113,11 @@ describe UserController, "when signing in" do response.should redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1) response.should_not send_email - ActionController::Routing::Routes.filters = old_filters + RoutingFilter.active = true end it "should not log you in if you use an invalid PostRedirect token, and shouldn't give 500 error either" do - old_filters = ActionController::Routing::Routes.filters - ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + RoutingFilter.active = false post_redirect = "something invalid" lambda { @@ -132,7 +130,7 @@ describe UserController, "when signing in" do response.should render_template('sign') assigns[:post_redirect].should == nil - ActionController::Routing::Routes.filters = old_filters + RoutingFilter.active = true end # No idea how to test this in the test framework :( @@ -156,8 +154,7 @@ 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 - old_filters = ActionController::Routing::Routes.filters - ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + RoutingFilter.active = false get :signin, :r => "/list" post_redirect = get_last_postredirect @@ -185,12 +182,11 @@ describe UserController, "when signing in" do 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 + RoutingFilter.active = true end it "should keep you logged in if you click a confirmation link and are already logged in as an admin" do - old_filters = ActionController::Routing::Routes.filters - ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + RoutingFilter.active = false get :signin, :r => "/list" post_redirect = get_last_postredirect @@ -222,7 +218,7 @@ describe UserController, "when signing in" do # And the redirect should still work, of course response.should redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1) - ActionController::Routing::Routes.filters = old_filters + RoutingFilter.active = true end end @@ -295,15 +291,14 @@ describe UserController, "when signing out" do end it "should log you out and redirect you to where you were" do - old_filters = ActionController::Routing::Routes.filters - ActionController::Routing::Routes.filters = RoutingFilter::Chain.new + RoutingFilter.active = false 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 + RoutingFilter.active = true end end -- cgit v1.2.3 From b37586c7165afb7b3447dfe2780169a88cb0a942 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Mon, 28 Jan 2013 19:44:22 +1100 Subject: Replace use of have_tag with have_selector from webrat --- spec/controllers/user_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 dcd08dfaa..81360d78c 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -74,7 +74,7 @@ describe UserController, "when signing in" do it "should show sign in / sign up page" do get :signin - response.should have_tag("input#signin_token") + response.should have_selector("input#signin_token") end it "should create post redirect to / when you just go to /signin" do -- cgit v1.2.3 From 97c4683e47bdbac4d170780cf2b765940fcd0168 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Tue, 29 Jan 2013 18:49:26 +1100 Subject: Replace use of response.should send_email with checking ActionMailer::Base.deliveries --- spec/controllers/user_controller_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 81360d78c..519e17441 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -111,7 +111,7 @@ describe UserController, "when signing in" do session[:user_id].should == users(:bob_smith_user).id # 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 + ActionMailer::Base.deliveries.should be_empty RoutingFilter.active = true end @@ -150,7 +150,7 @@ describe UserController, "when signing in" do :token => post_redirect.token } response.should render_template('confirm') - response.should send_email + ActionMailer::Base.deliveries.should_not be_empty end it "should confirm your email, log you in and redirect you to where you were after you click an email link" do @@ -162,7 +162,7 @@ describe UserController, "when signing in" do post :signin, { :user_signin => { :email => 'unconfirmed@localhost', :password => 'jonespassword' }, :token => post_redirect.token } - response.should send_email + ActionMailer::Base.deliveries.should_not be_empty deliveries = ActionMailer::Base.deliveries deliveries.size.should == 1 @@ -194,7 +194,7 @@ describe UserController, "when signing in" do post :signin, { :user_signin => { :email => 'unconfirmed@localhost', :password => 'jonespassword' }, :token => post_redirect.token } - response.should send_email + ActionMailer::Base.deliveries.should_not be_empty deliveries = ActionMailer::Base.deliveries deliveries.size.should == 1 -- cgit v1.2.3 From b02d852a1458a39e1d83b6b58d74b93320764892 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Tue, 29 Jan 2013 18:50:23 +1100 Subject: When matching mail.body with regex cast to string first --- spec/controllers/user_controller_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 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 519e17441..2692cada4 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -167,7 +167,7 @@ describe UserController, "when signing in" do deliveries = ActionMailer::Base.deliveries deliveries.size.should == 1 mail = deliveries[0] - mail.body =~ /(http:\/\/.*(\/c\/(.*)))/ + mail.body.to_s =~ /(http:\/\/.*(\/c\/(.*)))/ mail_url = $1 mail_path = $2 mail_token = $3 @@ -199,7 +199,7 @@ describe UserController, "when signing in" do deliveries = ActionMailer::Base.deliveries deliveries.size.should == 1 mail = deliveries[0] - mail.body =~ /(http:\/\/.*(\/c\/(.*)))/ + mail.body.to_s =~ /(http:\/\/.*(\/c\/(.*)))/ mail_url = $1 mail_path = $2 mail_token = $3 @@ -498,7 +498,7 @@ describe UserController, "when changing email address" do mail.body.should include("confirm that you want to change") mail.to.should == [ 'newbob@localhost' ] - mail.body =~ /(http:\/\/.*(\/c\/(.*)))/ + mail.body.to_s =~ /(http:\/\/.*(\/c\/(.*)))/ mail_url = $1 mail_path = $2 mail_token = $3 -- cgit v1.2.3 From 49045c68f845c60110c5795c5b793653abcf3489 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Tue, 29 Jan 2013 18:51:11 +1100 Subject: params_from doesn't exist anymore --- 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 2692cada4..9a446e704 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -174,7 +174,7 @@ describe UserController, "when signing in" do # check is right confirmation URL mail_token.should == post_redirect.email_token - params_from(:get, mail_path).should == { :controller => 'user', :action => 'confirm', :email_token => mail_token } + Rails.application.routes.recognize_path(mail_path).should == { :controller => 'user', :action => 'confirm', :email_token => mail_token } # check confirmation URL works session[:user_id].should be_nil @@ -206,7 +206,7 @@ describe UserController, "when signing in" do # check is right confirmation URL mail_token.should == post_redirect.email_token - params_from(:get, mail_path).should == { :controller => 'user', :action => 'confirm', :email_token => mail_token } + Rails.application.routes.recognize_path(mail_path).should == { :controller => 'user', :action => 'confirm', :email_token => mail_token } # Log in as an admin session[:user_id] = users(:admin_user).id -- cgit v1.2.3 From 20c20a5e403f04dd4aa221a323e8b9ed3967dc52 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Tue, 29 Jan 2013 18:52:01 +1100 Subject: errors returns an array now --- spec/controllers/user_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 9a446e704..4033bf0b6 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -230,7 +230,7 @@ describe UserController, "when signing up" do post :signup, { :user_signup => { :email => 'new@localhost', :name => 'New Person', :password => 'sillypassword', :password_confirmation => 'sillypasswordtwo' } } - assigns[:user_signup].errors[:password].should == 'Please enter the same password twice' + assigns[:user_signup].errors[:password].should == ['Please enter the same password twice'] end it "should be an error to sign up with a misformatted email" do -- cgit v1.2.3 From 154cae159b90b3b2a8d60cd71d383f4fa1831878 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Tue, 29 Jan 2013 18:52:32 +1100 Subject: mail from_addrs now doesn't return the name --- spec/controllers/user_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 4033bf0b6..a4a97acc7 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -335,7 +335,7 @@ describe UserController, "when sending another user a message" do mail.body.should include("Bob Smith has used #{Configuration::site_name} to send you the message below") mail.body.should include("Just a test!") #mail.to_addrs.first.to_s.should == users(:silly_name_user).name_and_email # XXX fix some nastiness with quoting name_and_email - mail.from_addrs.first.to_s.should == users(:bob_smith_user).name_and_email + mail.from_addrs.first.to_s.should == users(:bob_smith_user).email end end -- cgit v1.2.3 From cf0b371f6bc8454fbdd331e2a6fd19c6b67b540b Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Thu, 7 Feb 2013 18:39:50 +1100 Subject: This parameter is typecast in Rails 3 --- spec/controllers/user_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 a4a97acc7..cfff5c901 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -516,7 +516,7 @@ describe UserController, "when changing email address" do post_redirect = PostRedirect.find_by_email_token(mail_token) post_redirect.circumstance.should == 'change_email' post_redirect.user.should == users(:bob_smith_user) - post_redirect.post_params.should == {"submitted_signchangeemail_do"=>"1", + post_redirect.post_params.should == {"submitted_signchangeemail_do"=>1, "action"=>"signchangeemail", "signchangeemail"=>{ "old_email"=>"bob@localhost", -- cgit v1.2.3 From 75afaee10ab4ce41dd4e2dc0054a8fb1a2392f12 Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Thu, 21 Feb 2013 17:42:17 +1100 Subject: Correct syntax and reload for Ruby 1.9.3 --- spec/controllers/user_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 cfff5c901..0825d12bf 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -381,7 +381,7 @@ describe UserController, "when changing password" do post :signchangepassword, { :user => { :password => 'ooo', :password_confirmation => 'ooo' }, :submitted_signchangepassword_do => 1 } - users(:bob_smith_user).hashed_password.should != old_hash + users(:bob_smith_user).reload.hashed_password.should_not == old_hash response.should redirect_to(:controller => 'user', :action => 'show', :url_name => users(:bob_smith_user).url_name) end -- cgit v1.2.3 From cbdff06aa95a7987b54c712dc6729e138f608eca Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Sun, 3 Mar 2013 14:52:30 +1100 Subject: Rename Configuration class to avoid conflict with ActiveSupport::Configurable --- spec/controllers/user_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 0825d12bf..6cd1c099f 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -332,7 +332,7 @@ describe UserController, "when sending another user a message" do deliveries = ActionMailer::Base.deliveries deliveries.size.should == 1 mail = deliveries[0] - mail.body.should include("Bob Smith has used #{Configuration::site_name} to send you the message below") + mail.body.should include("Bob Smith has used #{AlaveteliConfiguration::site_name} to send you the message below") mail.body.should include("Just a test!") #mail.to_addrs.first.to_s.should == users(:silly_name_user).name_and_email # XXX fix some nastiness with quoting name_and_email mail.from_addrs.first.to_s.should == users(:bob_smith_user).email -- cgit v1.2.3 From baf809ed810c6bc419e062e0a4333424b21200f5 Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Mon, 4 Mar 2013 15:20:10 +1100 Subject: This is cast to a string in Rails 3.1 --- spec/controllers/user_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 6cd1c099f..4fc4bb279 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -516,7 +516,7 @@ describe UserController, "when changing email address" do post_redirect = PostRedirect.find_by_email_token(mail_token) post_redirect.circumstance.should == 'change_email' post_redirect.user.should == users(:bob_smith_user) - post_redirect.post_params.should == {"submitted_signchangeemail_do"=>1, + post_redirect.post_params.should == {"submitted_signchangeemail_do"=>"1", "action"=>"signchangeemail", "signchangeemail"=>{ "old_email"=>"bob@localhost", -- cgit v1.2.3 From 069ad6fbacd9420bbe0838cb8d8af1928a5dd40d Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Mon, 4 Mar 2013 15:20:28 +1100 Subject: Use built in fixture_file_upload --- spec/controllers/user_controller_spec.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 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 4fc4bb279..1f86c070f 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -561,11 +561,8 @@ describe UserController, "when using profile photos" do before do @user = users(:bob_smith_user) - @uploadedfile = File.open(file_fixture_name("parrot.png")) - @uploadedfile.stub!(:original_filename).and_return('parrot.png') - - @uploadedfile_2 = File.open(file_fixture_name("parrot.jpg")) - @uploadedfile_2.stub!(:original_filename).and_return('parrot.jpg') + @uploadedfile = fixture_file_upload("/files/parrot.png") + @uploadedfile_2 = fixture_file_upload("/files/parrot.jpg") end it "should not let you change profile photo if you're not logged in as the user" do -- cgit v1.2.3 From 8fa171594df6905e2d03359b896e550b260b0d8f Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Tue, 5 Mar 2013 14:47:42 +1100 Subject: Be a bit more exact --- spec/controllers/user_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 1f86c070f..a18554114 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -495,7 +495,7 @@ describe UserController, "when changing email address" do deliveries = ActionMailer::Base.deliveries deliveries.size.should == 1 mail = deliveries[0] - mail.body.should include("confirm that you want to change") + mail.body.should include("confirm that you want to \nchange") mail.to.should == [ 'newbob@localhost' ] mail.body.to_s =~ /(http:\/\/.*(\/c\/(.*)))/ -- cgit v1.2.3 From 16ca4662692125290f8df336d71dc098af4b937b Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 13 May 2013 16:40:09 +0100 Subject: Add call to load_raw_emails_data to fix dependency on raw emails exposed in https://travis-ci.org/mysociety/alaveteli/jobs/7126060. --- spec/controllers/user_controller_spec.rb | 1 + 1 file changed, 1 insertion(+) (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 a18554114..1d8e3dcc3 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -626,6 +626,7 @@ describe UserController, "when viewing the wall" do render_views before(:each) do + load_raw_emails_data get_fixtures_xapian_index end -- cgit v1.2.3