From b1559ff033a3eeb289d50d1caadba0190a139cd9 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 25 Jul 2011 13:25:46 +0100 Subject: Remove redundant test (this change should be with commit dd58cd35e51c1b98228aae1aa930629e84b6a905) --- spec/controllers/request_controller_spec.rb | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 8232a7398..9d91bf8c2 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -376,20 +376,6 @@ describe RequestController, "when creating a new request" do response.should render_template('new') end - it "should give an error if the same request is submitted twice with extra whitespace in the body" do - # This only works for PostgreSQL databases which have regexp_replace - - # see model method InfoRequest.find_by_existing_request for more info - if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" - session[:user_id] = @user.id - - post :new, :info_request => { :public_body_id => info_requests(:fancy_dog_request).public_body_id, - :title => info_requests(:fancy_dog_request).title }, - :outgoing_message => { :body => "\n" + info_requests(:fancy_dog_request).outgoing_messages[0].body + " "}, - :submitted_new_request => 1, :preview => 0, :mouse_house => 1 - response.should render_template('new') - end - end - it "should let you submit another request with the same title" do session[:user_id] = @user.id -- cgit v1.2.3 From bd2472e13a03f4f30c96a5d694efdc5c76798662 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Thu, 28 Jul 2011 09:00:17 +0100 Subject: Cause the final step in the "new request" workflow to have a unique URL (so we can distinguish it in Google Analytics). Fixes #96 --- spec/controllers/request_controller_spec.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 9d91bf8c2..1a190cad6 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -363,6 +363,9 @@ describe RequestController, "when creating a new request" do mail.body.should =~ /This is a silly letter. It is too short to be interesting./ response.should redirect_to(:action => 'show', :url_title => ir.url_title) + # This test uses an explicit path because it's relied in + # Google Analytics goals: + response.redirected_to.should == "/en/request/why_is_your_quango_called_gerald/new" end it "should give an error if the same request is submitted twice" do -- cgit v1.2.3 From 7573586c3be6318e19ae02ff008dfb2a576b5980 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 29 Jul 2011 10:02:57 +0100 Subject: To make tests pass with RawEmails on the filesystem, instead of hacky dependency on existence of text_binary field in raw_emails model, rewrite tests (and their fixtures) to explicitly load data from FS when raw_emails are used. --- spec/controllers/request_controller_spec.rb | 49 ++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 1a190cad6..514eda0b4 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -8,7 +8,7 @@ require 'json' describe RequestController, "when listing recent requests" do - before(:all) do + before(:each) do rebuild_xapian_index end @@ -35,11 +35,14 @@ describe RequestController, "when listing recent requests" do end end - describe RequestController, "when showing one request" do fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views - + + before(:each) do + load_raw_emails_data(raw_emails) + end + it "should be successful" do get :show, :url_title => 'why_do_you_have_such_a_fancy_dog' response.should be_success @@ -198,6 +201,10 @@ end describe RequestController, "when changing prominence of a request" do fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views + before(:each) do + load_raw_emails_data(raw_emails) + end + it "should not show hidden requests" do ir = info_requests(:fancy_dog_request) ir.prominence = 'hidden' @@ -457,7 +464,11 @@ end describe RequestController, "when viewing an individual response for reply/followup" do integrate_views fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views - + + before(:each) do + load_raw_emails_data(raw_emails) + end + it "should ask for login if you are logged in as wrong person" do session[:user_id] = users(:silly_name_user).id get :show_response, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message) @@ -489,6 +500,7 @@ describe RequestController, "when classifying an information request" do @dog_request = info_requests(:fancy_dog_request) @dog_request.stub!(:is_old_unclassified?).and_return(false) InfoRequest.stub!(:find).and_return(@dog_request) + load_raw_emails_data(raw_emails) end def post_status(status) @@ -898,7 +910,11 @@ end describe RequestController, "sending overdue request alerts" do integrate_views fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views - + + before(:each) do + load_raw_emails_data(raw_emails) + end + it "should send an overdue alert mail to creators of overdue requests" do chicken_request = info_requests(:naughty_chicken_request) chicken_request.outgoing_messages[0].last_sent_at = Time.now() - 30.days @@ -982,7 +998,11 @@ end describe RequestController, "sending unclassified new response reminder alerts" do integrate_views fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views - + + before(:each) do + load_raw_emails_data(raw_emails) + end + it "should send an alert" do RequestMailer.alert_new_response_reminders @@ -1009,7 +1029,10 @@ end describe RequestController, "clarification required alerts" do integrate_views fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views - + before(:each) do + load_raw_emails_data(raw_emails) + end + it "should send an alert" do ir = info_requests(:fancy_dog_request) ir.set_described_state('waiting_clarification') @@ -1060,6 +1083,9 @@ end describe RequestController, "comment alerts" do integrate_views fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views + before(:each) do + load_raw_emails_data(raw_emails) + end it "should send an alert (once and once only)" do # delete ficture comment and make new one, so is in last month (as @@ -1131,7 +1157,10 @@ end describe RequestController, "when viewing comments" do integrate_views - fixtures :users + fixtures :users, :raw_emails, :incoming_messages, :info_requests + before(:each) do + load_raw_emails_data(raw_emails) + end it "should link to the user who submitted it" do session[:user_id] = users(:bob_smith_user).id @@ -1240,6 +1269,10 @@ describe RequestController, "when showing JSON version for API" do fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments + before(:each) do + load_raw_emails_data(raw_emails) + end + it "should return data in JSON form" do get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :format => 'json' -- cgit v1.2.3 From 3ba811a9e576a50123930ccccda4dc01d5e3341e Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 29 Jul 2011 13:27:53 +0100 Subject: make explicit path test locale-independent --- spec/controllers/request_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 514eda0b4..69c1433f2 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -372,7 +372,7 @@ describe RequestController, "when creating a new request" do response.should redirect_to(:action => 'show', :url_title => ir.url_title) # This test uses an explicit path because it's relied in # Google Analytics goals: - response.redirected_to.should == "/en/request/why_is_your_quango_called_gerald/new" + response.redirected_to.should =~ /request\/why_is_your_quango_called_gerald\/new$/ end it "should give an error if the same request is submitted twice" do -- cgit v1.2.3