diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-01-13 13:28:23 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-01-13 13:28:23 +0000 |
commit | 07068037e9b0ac8de80a9eae36a323689c83139d (patch) | |
tree | fc910d2304471a54ff1f08ec5ba58fcc6c56e4b6 /spec/controllers | |
parent | 08dd56bac73ce83fcb12e4776b32c4e0ce75545a (diff) |
Fix bug introduced in cec2c545e0a10e0641c4ee67839c88d872b394b8, related to issue #343.
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin_public_body_controller_spec.rb | 15 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 7 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 22 | ||||
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 2 |
4 files changed, 34 insertions, 12 deletions
diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb index 22af3df80..97636023a 100644 --- a/spec/controllers/admin_public_body_controller_spec.rb +++ b/spec/controllers/admin_public_body_controller_spec.rb @@ -44,6 +44,9 @@ describe AdminPublicBodyController, "when administering public bodies" do it "destroys a public body" do PublicBody.count.should == 2 + info_request_events(:badger_outgoing_message_event).destroy + outgoing_messages(:badger_outgoing_message).destroy + info_requests(:badger_request).destroy post :destroy, { :id => 3 } PublicBody.count.should == 1 end @@ -74,6 +77,9 @@ describe AdminPublicBodyController, "when administering public bodies and paying config['ADMIN_PASSWORD'] = '' @request.env["HTTP_AUTHORIZATION"] = "" PublicBody.count.should == 2 + info_request_events(:badger_outgoing_message_event).destroy + outgoing_messages(:badger_outgoing_message).destroy + info_requests(:badger_request).destroy post :destroy, { :id => 3 } PublicBody.count.should == 1 session[:using_admin].should == 1 @@ -84,6 +90,9 @@ describe AdminPublicBodyController, "when administering public bodies and paying config['ADMIN_PASSWORD'] = 'fuz' @request.env["HTTP_AUTHORIZATION"] = "" PublicBody.count.should == 2 + info_request_events(:badger_outgoing_message_event).destroy + outgoing_messages(:badger_outgoing_message).destroy + info_requests(:badger_request).destroy post :destroy, { :id => 3 } PublicBody.count.should == 1 session[:using_admin].should == 1 @@ -95,6 +104,9 @@ describe AdminPublicBodyController, "when administering public bodies and paying @request.env["HTTP_AUTHORIZATION"] = "" PublicBody.count.should == 2 basic_auth_login(@request, "baduser", "badpassword") + info_request_events(:badger_outgoing_message_event).destroy + outgoing_messages(:badger_outgoing_message).destroy + info_requests(:badger_request).destroy post :destroy, { :id => 3 } response.code.should == "401" PublicBody.count.should == 2 @@ -168,6 +180,9 @@ describe AdminPublicBodyController, "when administering public bodies with i18n" it "destroy a public body" do PublicBody.count.should == 2 + info_request_events(:badger_outgoing_message_event).destroy + outgoing_messages(:badger_outgoing_message).destroy + info_requests(:badger_request).destroy post :destroy, { :id => 3 } PublicBody.count.should == 1 end diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 3996bd520..a563b92ad 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -6,6 +6,11 @@ describe PublicBodyController, "when showing a body" do integrate_views fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things + before(:each) do + load_raw_emails_data(raw_emails) + rebuild_xapian_index + end + it "should be successful" do get :show, :url_name => "dfh", :view => 'all' response.should be_success @@ -26,6 +31,8 @@ describe PublicBodyController, "when showing a body" do assigns[:xapian_requests].results.count.should == 2 get :show, :url_name => "tgq", :view => 'successful' assigns[:xapian_requests].results.count.should == 0 + get :show, :url_name => "dfh", :view => 'all' + assigns[:xapian_requests].results.count.should == 1 end it "should assign the body using different locale from that used for url_name" do diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 52fea03b5..40cb168f4 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -23,9 +23,9 @@ describe RequestController, "when listing recent requests" do it "should filter requests" do get :list, :view => 'all' - assigns[:list_results].size.should == 2 + assigns[:list_results].size.should == 3 # default sort order is the request with the most recently created event first - assigns[:list_results][0].info_request.id.should == 101 + assigns[:list_results][0].info_request.id.should == 104 get :list, :view => 'successful' assigns[:list_results].size.should == 0 end @@ -34,9 +34,9 @@ describe RequestController, "when listing recent requests" do get :list, :view => 'all', :request_date_before => '13/10/2007' assigns[:list_results].size.should == 1 get :list, :view => 'all', :request_date_after => '13/10/2007' - assigns[:list_results].size.should == 2 + assigns[:list_results].size.should == 3 get :list, :view => 'all', :request_date_after => '13/10/2007', :request_date_before => '01/11/2007' - assigns[:list_results].size.should == 2 + assigns[:list_results].size.should == 1 end it "should list internal_review requests as unresolved ones" do @@ -56,7 +56,7 @@ describe RequestController, "when listing recent requests" do :matches_estimated => 103) InfoRequest.should_receive(:full_search). - with([InfoRequestEvent]," variety:sent OR variety:followup_sent OR variety:response OR variety:comment", "created_at", anything, anything, anything, anything). + with([InfoRequestEvent]," (variety:sent OR variety:followup_sent OR variety:response OR variety:comment)", "created_at", anything, anything, anything, anything). and_return(xap_results) get :list, :view => 'recent' assigns[:list_results].size.should == 25 @@ -1124,8 +1124,8 @@ describe RequestController, "sending overdue request alerts" do RequestMailer.alert_overdue_requests deliveries = ActionMailer::Base.deliveries - deliveries.size.should == 1 - mail = deliveries[0] + deliveries.size.should == 2 + mail = deliveries[1] mail.body.should =~ /promptly, as normally/ mail.to_addrs.first.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email @@ -1152,8 +1152,8 @@ describe RequestController, "sending overdue request alerts" do RequestMailer.alert_overdue_requests deliveries = ActionMailer::Base.deliveries - deliveries.size.should == 1 - mail = deliveries[0] + deliveries.size.should == 2 + mail = deliveries[1] mail.body.should =~ /promptly, as normally/ mail.to_addrs.first.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email end @@ -1177,8 +1177,8 @@ describe RequestController, "sending overdue request alerts" do RequestMailer.alert_overdue_requests deliveries = ActionMailer::Base.deliveries - deliveries.size.should == 1 - mail = deliveries[0] + deliveries.size.should == 2 + mail = deliveries[1] mail.body.should =~ /required by law/ mail.to_addrs.first.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 30ad61706..0cf574aa9 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -45,7 +45,7 @@ describe UserController, "when showing a user" do it "should search the user's contributions" do get :show, :url_name => "bob_smith" - assigns[:xapian_requests].results.count.should == 2 + assigns[:xapian_requests].results.count.should == 3 get :show, :url_name => "bob_smith", :user_query => "money" assigns[:xapian_requests].results.count.should == 1 end |