diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-29 19:12:01 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-29 19:12:01 +0000 |
commit | f6cd280bbfafa2151ededb8280407686fb73e8a7 (patch) | |
tree | 068c9b8e2723efb7fe10c9602ea494ccc578e1f5 | |
parent | ba003a16e51b0316233157893b6572aa01616c77 (diff) |
Test duplicate requests are coalesced
Test that duplicate requests are coalesced on the front page.
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 5 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 1 | ||||
-rw-r--r-- | spec/fixtures/files/raw_emails/4.email | 17 | ||||
-rw-r--r-- | spec/fixtures/files/raw_emails/5.email | 17 | ||||
-rw-r--r-- | spec/fixtures/incoming_messages.yml | 13 | ||||
-rw-r--r-- | spec/fixtures/info_request_events.yml | 44 | ||||
-rw-r--r-- | spec/fixtures/info_requests.yml | 27 | ||||
-rw-r--r-- | spec/fixtures/outgoing_messages.yml | 20 | ||||
-rw-r--r-- | spec/fixtures/public_bodies.yml | 13 | ||||
-rw-r--r-- | spec/fixtures/public_body_translations.yml | 11 | ||||
-rw-r--r-- | spec/fixtures/raw_emails.yml | 6 | ||||
-rw-r--r-- | spec/fixtures/users.yml | 13 |
12 files changed, 185 insertions, 2 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 6c9f8b88d..9a5421a78 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -126,6 +126,11 @@ describe GeneralController, "when searching" do get :frontpage assigns[:request_events].first.info_request.should == info_requests(:another_boring_request) end + + it 'should coalesce duplicate requests' do + get :frontpage + assigns[:request_events].map(&:info_request).select{|x|x.url_title =~ /^spam/}.length.should == 1 + end end describe 'when using xapian search' do diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index a285a8900..4d27ea3f5 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -153,7 +153,6 @@ describe PublicBodyController, "when listing bodies" do get :list response.should render_template('list') assigns[:public_bodies].should =~ PublicBody.all(:conditions => "id <> #{PublicBody.internal_admin_body.id}") - end it "should list a machine tagged thing, should get it in both ways" do diff --git a/spec/fixtures/files/raw_emails/4.email b/spec/fixtures/files/raw_emails/4.email new file mode 100644 index 000000000..c778e5ba9 --- /dev/null +++ b/spec/fixtures/files/raw_emails/4.email @@ -0,0 +1,17 @@ +From: "The Minister" <msw@localhost> +To: robin@localhost +Date: Tue, 13 Nov 2008 11:39:55 +0000 +Bcc: +Subject: Re: v1agra +Reply-To: +In-Reply-To: <fdshjksdahhjkfsdahjkfsd@gfh.example.com> +Content-Type: text/plain; charset=utf-8 + +Thank you for your spam, which we have processed with pleasure. Please +accept herewith our order for six packs of the finest cheap v1agra. + +Yours most sincerely, + +Martin Kibble-von Scratsching, +Chief Assistant to the Assistant Chief, +Ministry of Silly Walks diff --git a/spec/fixtures/files/raw_emails/5.email b/spec/fixtures/files/raw_emails/5.email new file mode 100644 index 000000000..16b65610a --- /dev/null +++ b/spec/fixtures/files/raw_emails/5.email @@ -0,0 +1,17 @@ +From: "The Minister" <sensewalk@localhost> +To: robin@localhost +Date: Tue, 13 Nov 2008 12:39:55 +0000 +Bcc: +Subject: Re: v1agra +Reply-To: +In-Reply-To: <fdshjks+hihhjkfsdahjkfsd@gfh.example.com> +Content-Type: text/plain; charset=utf-8 + +Thank you for your spam, which we have processed with pleasure. Please +accept herewith our order for six packs of the finest cheap v1agra. + +Yours most sincerely, + +Martin Scratsching-von Kibble, +Assistant (Second class) to the Chief Assistant to the Assistant Chief, +Ministry of Sensible Walks diff --git a/spec/fixtures/incoming_messages.yml b/spec/fixtures/incoming_messages.yml index 918d4fd11..fca5c716c 100644 --- a/spec/fixtures/incoming_messages.yml +++ b/spec/fixtures/incoming_messages.yml @@ -18,3 +18,16 @@ another_useful_incoming_message: raw_email_id: 3 created_at: 2007-11-13 18:09:20 updated_at: 2007-11-13 18:09:20 + +spam_1_incoming_message: + id: 4 + info_request_id: 107 + raw_email_id: 4 + created_at: 2008-11-13 18:09:20 + updated_at: 2008-11-13 18:09:20 +spam_2_incoming_message: + id: 5 + info_request_id: 108 + raw_email_id: 5 + created_at: 2008-11-13 19:09:20 + updated_at: 2008-11-13 19:09:20 diff --git a/spec/fixtures/info_request_events.yml b/spec/fixtures/info_request_events.yml index c72ef60c8..3266ec634 100644 --- a/spec/fixtures/info_request_events.yml +++ b/spec/fixtures/info_request_events.yml @@ -106,3 +106,47 @@ another_comment_event: event_type: comment created_at: 2008-08-12 12:05:12.879634 + +# The spam requests were both successful +spam_1_outgoing_message_event: + id: 910 + params_yaml: "--- \n\ + :outgoing_message_id: 6\n" + outgoing_message_id: 6 + info_request_id: 107 + event_type: sent + created_at: 2001-01-02 01:23:45.6789100 + described_state: waiting_response + calculated_state: waiting_response +spam_1_incoming_message_event: + id: 911 + params_yaml: "--- \n\ + :incoming_message_id: 4\n" + incoming_message_id: 4 + info_request_id: 107 + event_type: response + created_at: 2001-01-03 01:23:45.6789100 + described_state: successful + calculated_state: successful + +spam_2_outgoing_message_event: + id: 912 + params_yaml: "--- \n\ + :outgoing_message_id: 7\n" + outgoing_message_id: 7 + info_request_id: 108 + event_type: sent + created_at: 2001-01-02 02:23:45.6789100 + described_state: waiting_response + calculated_state: waiting_response +spam_2_incoming_message_event: + id: 913 + params_yaml: "--- \n\ + :incoming_message_id: 5\n" + incoming_message_id: 5 + info_request_id: 108 + event_type: response + created_at: 2001-01-03 02:23:45.6789100 + described_state: successful + calculated_state: successful + diff --git a/spec/fixtures/info_requests.yml b/spec/fixtures/info_requests.yml index 69f51a9e4..33e9a16f2 100644 --- a/spec/fixtures/info_requests.yml +++ b/spec/fixtures/info_requests.yml @@ -52,4 +52,29 @@ another_boring_request: user_id: 1 described_state: successful awaiting_description: false - idhash: 173fd003 + idhash: 173fd004 + +# A pair of identical requests (with url_title differing only in the numeric suffix) +# used to test the request de-duplication features. +spam_1_request: + id: 107 + title: Cheap v1agra + url_title: spam_1 + created_at: 2010-01-01 01:23:45.6789100 + created_at: 2010-01-01 01:23:45.6789100 + public_body_id: 5 + user_id: 5 + described_state: successful + awaiting_description: false + idhash: 173fd005 +spam_2_request: + id: 108 + title: Cheap v1agra + url_title: spam_2 + created_at: 2010-01-01 02:23:45.6789100 + created_at: 2010-01-01 02:23:45.6789100 + public_body_id: 6 + user_id: 5 + described_state: successful + awaiting_description: false + idhash: 173fd005 diff --git a/spec/fixtures/outgoing_messages.yml b/spec/fixtures/outgoing_messages.yml index 3fb472630..d33ca4292 100644 --- a/spec/fixtures/outgoing_messages.yml +++ b/spec/fixtures/outgoing_messages.yml @@ -65,4 +65,24 @@ another_boring_outgoing_message: updated_at: 2006-01-12 01:56:58.586598 what_doing: normal_sort +spam_1_outgoing_message: + id: 6 + info_request_id: 107 + message_type: initial_request + status: sent + body: "Would you like some cheap v1agra?" + last_sent_at: 2007-01-12 01:57:58.586598 + created_at: 2007-01-12 01:56:58.586598 + updated_at: 2007-01-12 01:56:58.586598 + what_doing: normal_sort +spam_2_outgoing_message: + id: 7 + info_request_id: 108 + message_type: initial_request + status: sent + body: "Would you like some cheap v1agra?" + last_sent_at: 2007-01-12 02:57:58.586598 + created_at: 2007-01-12 02:56:58.586598 + updated_at: 2007-01-12 02:56:58.586598 + what_doing: normal_sort diff --git a/spec/fixtures/public_bodies.yml b/spec/fixtures/public_bodies.yml index 2ac99f99e..a0893f1e5 100644 --- a/spec/fixtures/public_bodies.yml +++ b/spec/fixtures/public_bodies.yml @@ -49,3 +49,16 @@ silly_walks_public_body: url_name: msw created_at: 2007-10-25 10:51:01.161639 notes: You know the one. +sensible_walks_public_body: + id: 6 + version: 1 + name: "Ministry of Sensible Walks" + first_letter: M + request_email: sensible-walks-requests@localhost + short_name: SenseWalk + url_name: sensible_walks + notes: I bet you’ve never heard of it. + updated_at: 2008-10-25 10:51:01.161639 + last_edit_comment: Another stunning innovation from your friendly national government + last_edit_editor: robin + created_at: 2008-10-25 10:51:01.161639 diff --git a/spec/fixtures/public_body_translations.yml b/spec/fixtures/public_body_translations.yml index b81dd35a3..cbb55bb0c 100644 --- a/spec/fixtures/public_body_translations.yml +++ b/spec/fixtures/public_body_translations.yml @@ -63,3 +63,14 @@ silly_walks_en_public_body_translation: short_name: MSW url_name: msw notes: You know the one. + +sensible_walks_en_public_body_translation: + id: 7 + public_body_id: 6 + locale: en + name: "Ministry of Sensible Walks" + first_letter: M + request_email: sensible-walks-requests@localhost + short_name: SenseWalk + url_name: sensible_walks + notes: I bet you’ve never heard of it. diff --git a/spec/fixtures/raw_emails.yml b/spec/fixtures/raw_emails.yml index d2c591812..ad2bc0a63 100644 --- a/spec/fixtures/raw_emails.yml +++ b/spec/fixtures/raw_emails.yml @@ -12,3 +12,9 @@ useful_raw_email: another_useful_raw_email: id: 3 + +spam_1_raw_email: + id: 4 + +spam_2_raw_email: + id: 5 diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml index 16ffec034..8620fb3de 100644 --- a/spec/fixtures/users.yml +++ b/spec/fixtures/users.yml @@ -53,3 +53,16 @@ unconfirmed_user: admin_level: 'none' ban_text: '' about_me: '' +robin_user: + id: 5 + name: Robin Houston + url_name: robin_houston + email: robin@localhost + salt: "-6116981980.392287733335677" + hashed_password: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 # jonespassword + updated_at: 2012-01-01 10:39:15.491593 + created_at: 2012-01-01 10:39:15.491593 + email_confirmed: true + admin_level: 'none' + ban_text: '' + about_me: 'I am the best' |