diff options
Diffstat (limited to 'spec')
34 files changed, 1022 insertions, 182 deletions
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 423c2fb49..6f9af0525 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -71,7 +71,7 @@ describe AdminRequestController, "when administering the holding pen" do post :redeliver_incoming, :redeliver_incoming_message_id => new_im.id, :url_title => ir.url_title ir = InfoRequest.find_by_url_title(ir.url_title) ir.incoming_messages.length.should == 2 - response.should redirect_to('http://test.host/admin/request/show/101') + response.should redirect_to(:controller=>'admin_request', :action=>'show', :id=>101) InfoRequest.holding_pen_request.incoming_messages.length.should == 0 end diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 4d7f1831d..1ffbda90d 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -64,7 +64,7 @@ describe GeneralController, "when searching" do it "should redirect from search query URL to pretty URL" do post :search_redirect, :query => "mouse" # query hidden in POST parameters - response.should redirect_to(:action => 'search', :combined => "mouse", :view => "all") # URL /search/:query/all + response.should redirect_to(:action => 'search', :combined => "mouse", :view => "requests") # URL /search/:query/all end describe "when using different locale settings" do diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index df3fc10dc..c5c9d60e1 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -75,7 +75,7 @@ describe PublicBodyController, "when listing bodies" do assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), public_bodies(:geraldine_public_body) ] assigns[:tag].should == "all" - assigns[:description].should == "all" + assigns[:description].should == "" end it "should support simple searching of bodies by title" do @@ -94,7 +94,7 @@ describe PublicBodyController, "when listing bodies" do response.should render_template('list') assigns[:public_bodies].should == [ public_bodies(:geraldine_public_body), public_bodies(:humpadink_public_body) ] assigns[:tag].should == "all" - assigns[:description].should == "all" + assigns[:description].should == "" I18n.default_locale = :en end @@ -113,7 +113,7 @@ describe PublicBodyController, "when listing bodies" do get :list response.should render_template('list') - assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body), public_bodies(:geraldine_public_body) ] + assigns[:public_bodies].count.should == 2 end @@ -156,6 +156,41 @@ describe PublicBodyController, "when showing JSON version for API" do end +describe PublicBodyController, "when doing type ahead searches" do + fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments + + it "should return nothing for the empty query string" do + get :search_typeahead, :q => "" + response.should render_template('public_body/_search_ahead') + assigns[:xapian_requests].results.size.should == 0 + end + + it "should return a body matching the given keyword, but not users with a matching description" do + get :search_typeahead, :q => "Geraldine" + response.should render_template('public_body/_search_ahead') + assigns[:xapian_requests].results.size.should == 1 + assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:geraldine_public_body).name + end + it "should return all requests matching any of the given keywords" do + get :search_typeahead, :q => "Geraldine Humpadinking" + response.should render_template('public_body/_search_ahead') + assigns[:xapian_requests].results.size.should == 2 + assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:humpadink_public_body).name + assigns[:xapian_requests].results[1][:model].name.should == public_bodies(:geraldine_public_body).name + end + it "should return requests matching the given keywords in any of their locales" do + get :search_typeahead, :q => "baguette" # part of the spanish notes + response.should render_template('public_body/_search_ahead') + assigns[:xapian_requests].results.size.should == 1 + assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:humpadink_public_body).name + end + it "should return partial matches" do + get :search_typeahead, :q => "geral" # 'geral' for 'Geraldine' + response.should render_template('public_body/_search_ahead') + assigns[:xapian_requests].results.size.should == 1 + assigns[:xapian_requests].results[0][:model].name.should == public_bodies(:geraldine_public_body).name + end +end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index f3084af12..aa3027c00 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -216,7 +216,28 @@ describe RequestController, "when showing one request" do response.body.should have_tag("p.attachment strong", /goodbye.txt/m) end - + it "should make a zipfile available, which has a different URL when it changes" do + ir = info_requests(:fancy_dog_request) + session[:user_id] = ir.user.id # bob_smith_user + receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) + title = 'why_do_you_have_such_a_fancy_dog' + get :download_entire_request, :url_title => title + assigns[:url_path].should have_text(/#{title}.zip$/) + old_path = assigns[:url_path] + response.location.should have_text(/#{assigns[:url_path]}$/) + zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", old_path)) { |zipfile| + zipfile.count.should == 2 + } + receive_incoming_mail('incoming-request-attachment-unknown-extension.email', ir.incoming_email) + get :download_entire_request, :url_title => title + assigns[:url_path].should have_text(/#{title}.zip$/) + response.location.should have_text(/#{assigns[:url_path]}/) + assigns[:url_path].should_not == old_path + zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", assigns[:url_path])) { |zipfile| + zipfile.count.should == 4 +zipfile.entries.each {|x| puts x.name} + } + end end end @@ -349,7 +370,20 @@ describe RequestController, "when creating a new request" do response.should render_template('new') end + it "should redirect to sign in page when input is good and nobody is logged in" do + params = { :info_request => { :public_body_id => @body.id, + :title => "Why is your quango called Geraldine?", :tag_string => "" }, + :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }, + :submitted_new_request => 1, :preview => 0 + } + post :new, params + post_redirect = PostRedirect.get_last_post_redirect + response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token) + # post_redirect.post_params.should == params # XXX get this working. there's a : vs '' problem amongst others + end + it "should show preview when input is good" do + session[:user_id] = @user.id post :new, { :info_request => { :public_body_id => @body.id, :title => "Why is your quango called Geraldine?", :tag_string => "" }, :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }, @@ -367,18 +401,6 @@ describe RequestController, "when creating a new request" do response.should render_template('new') end - it "should redirect to sign in page when input is good and nobody is logged in" do - params = { :info_request => { :public_body_id => @body.id, - :title => "Why is your quango called Geraldine?", :tag_string => "" }, - :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }, - :submitted_new_request => 1, :preview => 0 - } - post :new, params - post_redirect = PostRedirect.get_last_post_redirect - response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token) - # post_redirect.post_params.should == params # XXX get this working. there's a : vs '' problem amongst others - end - it "should create the request and outgoing message, and send the outgoing message by email, and redirect to request page when input is good and somebody is logged in" do session[:user_id] = @user.id post :new, :info_request => { :public_body_id => @body.id, @@ -450,6 +472,7 @@ describe RequestController, "when making a new request" do @user.stub!(:get_undescribed_requests).and_return([]) @user.stub!(:can_leave_requests_undescribed?).and_return(false) @user.stub!(:can_file_requests?).and_return(true) + @user.stub!(:locale).and_return("en") User.stub!(:find).and_return(@user) @body = mock_model(PublicBody, :id => 314, :eir_only? => false, :is_requestable? => true, :name => "Test Quango") @@ -510,6 +533,22 @@ describe RequestController, "when viewing an individual response for reply/follo response.should render_template('show_response') end + it "should offer the opportunity to reply to the main address" do + session[:user_id] = users(:bob_smith_user).id + get :show_response, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message) + response.body.should have_tag("div#other_recipients ul li", /the main FOI contact address for/) + end + + it "should offer an opportunity to reply to another address" do + session[:user_id] = users(:bob_smith_user).id + ir = info_requests(:fancy_dog_request) + ir.allow_new_responses_from = "anybody" + ir.save! + receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "Frob <frob@bonce.com>") + get :show_response, :id => ir.id, :incoming_message_id => incoming_messages(:useless_incoming_message) + response.body.should have_tag("div#other_recipients ul li", /Frob/) + end + it "should not show individual responses if request hidden, even if request owner" do ir = info_requests(:fancy_dog_request) ir.prominence = 'hidden' @@ -1319,5 +1358,36 @@ describe RequestController, "when showing JSON version for API" do end +describe RequestController, "when doing type ahead searches" do + fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments + + it "should return nothing for the empty query string" do + get :search_typeahead, :q => "" + response.should render_template('request/_search_ahead.rhtml') + assigns[:xapian_requests].results.size.should == 0 + end + + it "should return a request matching the given keyword, but not users with a matching description" do + get :search_typeahead, :q => "chicken" + response.should render_template('request/_search_ahead.rhtml') + assigns[:xapian_requests].results.size.should == 1 + assigns[:xapian_requests].results[0][:model].title.should == info_requests(:naughty_chicken_request).title + end + + it "should return all requests matching any of the given keywords" do + get :search_typeahead, :q => "money dog" + response.should render_template('request/_search_ahead.rhtml') + assigns[:xapian_requests].results.size.should == 2 + assigns[:xapian_requests].results[0][:model].title.should == info_requests(:fancy_dog_request).title + assigns[:xapian_requests].results[1][:model].title.should == info_requests(:naughty_chicken_request).title + end + + it "should return partial matches" do + get :search_typeahead, :q => "chick" # 'chick' for 'chicken' + response.should render_template('request/_search_ahead.rhtml') + assigns[:xapian_requests].results.size.should == 1 + assigns[:xapian_requests].results[0][:model].title.should == info_requests(:naughty_chicken_request).title + end +end diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb new file mode 100644 index 000000000..1bafd0c8f --- /dev/null +++ b/spec/controllers/services_controller_spec.rb @@ -0,0 +1,31 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe ServicesController, "when using web services" do + integrate_views + + it "should show no alaveteli message when in the deployed country" do + config = MySociety::Config.load_default() + config['ISO_COUNTRY_CODE'] = "DE" + controller.stub!(:country_from_ip).and_return('DE') + get :other_country_message + response.body.should == "" + end + + it "should show an alaveteli message when not in the deployed country and in a country with no FOI website" do + config = MySociety::Config.load_default() + config['ISO_COUNTRY_CODE'] = "DE" + controller.stub!(:country_from_ip).and_return('ZZ') + get :other_country_message + response.body.should match(/outside Germany/) + end + + it "should show link to other FOI website when not in the deployed country" do + config = MySociety::Config.load_default() + config['ISO_COUNTRY_CODE'] = "ZZ" + controller.stub!(:country_from_ip).and_return('DE') + get :other_country_message + response.body.should match(/within Germany/) + end + + +end diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index 2f3f903f9..435d9a0d3 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -16,6 +16,7 @@ describe TrackController, "when making a new track on a request" do @user = mock_model(User) User.stub!(:find).and_return(@user) + @user.stub!(:locale).and_return("en") end it "should require login when making new track" do @@ -35,7 +36,7 @@ end describe TrackController, "when sending alerts for a track" do integrate_views - fixtures :info_requests, :outgoing_messages, :incoming_messages, :raw_emails, :info_request_events, :users, :track_things, :track_things_sent_emails, :public_bodies, :public_body_translations + fixtures :comments, :info_requests, :outgoing_messages, :incoming_messages, :raw_emails, :info_request_events, :users, :track_things, :track_things_sent_emails, :public_bodies, :public_body_translations include LinkToHelper # for main_url before(:each) do @@ -69,7 +70,6 @@ describe TrackController, "when sending alerts for a track" do mail.body.should include('added an annotation') # comment included mail.body.should =~ /This a the daftest comment the world has ever seen/ # comment text included - # Check subscription managing link # XXX We can't do this, as it is redirecting to another controller. I'm # apparently meant to be writing controller unit tests here, not functional @@ -93,6 +93,19 @@ describe TrackController, "when sending alerts for a track" do deliveries.size.should == 0 end + it "should send localised alerts" do + # set the time the comment event happened at to within the last week + ire = info_request_events(:silly_comment_event) + ire.created_at = Time.now - 3.days + ire.save! + user = users(:silly_name_user) + user.locale = "es" + user.save! + TrackMailer.alert_tracks + deliveries = ActionMailer::Base.deliveries + mail = deliveries[0] + mail.body.should include('el equipo de ') + end end describe TrackController, "when viewing RSS feed for a track" do diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 438fb8c0c..b4cc0d6e3 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -32,6 +32,13 @@ describe UserController, "when showing a user" do assigns[:display_user].should == users(:bob_smith_user) end + it "should search the user's contributions" do + get :show, :url_name => "bob_smith" + assigns[:xapian_requests].results.count.should == 2 + get :show, :url_name => "bob_smith", :user_query => "money" + assigns[:xapian_requests].results.count.should == 1 + end + # Error handling not quite good enough for this yet # it "should not show unconfirmed users" do # get :show, :url_name => "silly_emnameem" @@ -104,7 +111,7 @@ describe UserController, "when signing in" do get :signin, :r => "/list" response.should render_template('sign') post_redirect = get_last_postredirect - post :signin, { :user_signin => { :email => 'silly@localhost', :password => 'jonespassword' }, + post :signin, { :user_signin => { :email => 'unconfirmed@localhost', :password => 'jonespassword' }, :token => post_redirect.token } response.should render_template('confirm') @@ -116,7 +123,7 @@ describe UserController, "when signing in" do get :signin, :r => "/list" post_redirect = get_last_postredirect - post :signin, { :user_signin => { :email => 'silly@localhost', :password => 'jonespassword' }, + post :signin, { :user_signin => { :email => 'unconfirmed@localhost', :password => 'jonespassword' }, :token => post_redirect.token } response.should send_email @@ -136,7 +143,7 @@ describe UserController, "when signing in" do # check confirmation URL works session[:user_id].should be_nil get :confirm, :email_token => post_redirect.email_token - session[:user_id].should == users(:silly_name_user).id + session[:user_id].should == users(:unconfirmed_user).id response.should redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1) end @@ -171,6 +178,19 @@ describe UserController, "when signing up" do deliveries[0].body.should include("not reveal your email") end + it "should send confirmation mail in other languages or different locales" do + session[:locale] = "es" + post :signup, {:user_signup => { :email => 'new@localhost', :name => 'New Person', + :password => 'sillypassword', :password_confirmation => 'sillypassword', + } + } + response.should render_template('confirm') + + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 1 + deliveries[0].body.should include("No revelaremos su dirección de correo") + end + it "should send special 'already signed up' mail if you fill the form in with existing registered email " do post :signup, { :user_signup => { :email => 'silly@localhost', :name => 'New Person', :password => 'sillypassword', :password_confirmation => 'sillypassword' } diff --git a/spec/fixtures/files/autoresponse-header.email b/spec/fixtures/files/autoresponse-header.email new file mode 100644 index 000000000..ecd292961 --- /dev/null +++ b/spec/fixtures/files/autoresponse-header.email @@ -0,0 +1,22 @@ +From: EMAIL_FROM +To: FOI Person <EMAIL_TO> +Delivery-date: Fri, 01 Aug 2008 14:35:58 +0100 +Return-path: <me@cheese.com> +X-Failed-Recipients: enquiries@cheese.com +Auto-Submitted: auto-replied +From: Mail Delivery System <Mailer-Daemon@sandwich.com> +Subject: Mail delivery failed: returning message to sender +Message-Id: <E1KOunW-000dXv-C6@sandwich.com> +Date: Fri, 01 Aug 2008 14:35:58 +0100 + +This message was created automatically by mail delivery software. + +A message that you sent could not be delivered to one or more of its +recipients. This is a permanent error. The following address(es) failed: + + enquiries@cheese.com + Unrouteable address + +------ This is a copy of the message, including all the headers. ------ + +Hello
\ No newline at end of file diff --git a/spec/fixtures/files/empty-return-path.email b/spec/fixtures/files/empty-return-path.email new file mode 100644 index 000000000..b01e96de8 --- /dev/null +++ b/spec/fixtures/files/empty-return-path.email @@ -0,0 +1,21 @@ +From: EMAIL_FROM +To: FOI Person <EMAIL_TO> +Return-path: <> +Delivery-date: Fri, 01 Aug 2008 14:35:58 +0100 +X-Failed-Recipients: enquiries@cheese.com +From: Mail Delivery System <Mailer-Daemon@sandwich.com> +Subject: Mail delivery failed: returning message to sender +Message-Id: <E1KOunW-000dXv-C6@sandwich.com> +Date: Fri, 01 Aug 2008 14:35:58 +0100 + +This message was created automatically by mail delivery software. + +A message that you sent could not be delivered to one or more of its +recipients. This is a permanent error. The following address(es) failed: + + enquiries@cheese.com + Unrouteable address + +------ This is a copy of the message, including all the headers. ------ + +Hello
\ No newline at end of file diff --git a/spec/fixtures/files/fake-authority-add-tags.rb b/spec/fixtures/files/fake-authority-add-tags.rb new file mode 100644 index 000000000..a5612d87f --- /dev/null +++ b/spec/fixtures/files/fake-authority-add-tags.rb @@ -0,0 +1,4 @@ +#id,request_email,name,tag_string +,north_west_foi@localhost,North West Fake Authority,aTag +,scottish_foi@localhost,Scottish Fake Authority,aTag +,ni_foi@localhost,Fake Authority of Northern Ireland,fake aTag diff --git a/spec/fixtures/files/fake-authority-type-with-field-names.csv b/spec/fixtures/files/fake-authority-type-with-field-names.csv index 9e82308fb..a4247dced 100644 --- a/spec/fixtures/files/fake-authority-type-with-field-names.csv +++ b/spec/fixtures/files/fake-authority-type-with-field-names.csv @@ -1,4 +1,4 @@ -#id,request_email,name,name.es,home_page -,north_west_foi@localhost,North West Fake Authority,Autoridad del Nordeste,http://northwest.org -,scottish_foi@localhost,Scottish Fake Authority,Autoridad Escocesa,http://scottish.org -,ni_foi@localhost,Fake Authority of Northern Ireland,Autoridad Irlandesa +#id,request_email,name,name.es,tag_string,home_page +,north_west_foi@localhost,North West Fake Authority,Autoridad del Nordeste,,http://northwest.org +,scottish_foi@localhost,Scottish Fake Authority,Autoridad Escocesa,scottish,http://scottish.org +,ni_foi@localhost,Fake Authority of Northern Ireland,Autoridad Irlandesa,fake aTag diff --git a/spec/fixtures/files/track-response-exchange-oof-1.email b/spec/fixtures/files/track-response-exchange-oof-1.email new file mode 100644 index 000000000..6bb696119 --- /dev/null +++ b/spec/fixtures/files/track-response-exchange-oof-1.email @@ -0,0 +1,102 @@ +Delivered-To: mysociety.robin@gmail.com +Received: by 10.216.187.197 with SMTP id y47cs73028wem; + Tue, 6 Sep 2011 00:02:08 -0700 (PDT) +Received: by 10.216.229.167 with SMTP id h39mr1763951weq.57.1315292527401; + Tue, 06 Sep 2011 00:02:07 -0700 (PDT) +Return-Path: <Firstname.Surname@example.com> +Received: from wildfire.ukcod.org.uk (wildfire.ukcod.org.uk [89.238.145.74]) + by mx.google.com with ESMTPS id i56si7850683wed.12.2011.09.06.00.02.05 + (version=TLSv1/SSLv3 cipher=OTHER); + Tue, 06 Sep 2011 00:02:06 -0700 (PDT) +Received-SPF: neutral (google.com: 89.238.145.74 is neither permitted nor denied by domain of Firstname.Surname@example.com) client-ip=89.238.145.74; +Authentication-Results: mx.google.com; spf=neutral (google.com: 89.238.145.74 is neither permitted nor denied by domain of Firstname.Surname@example.com) smtp.mail=Firstname.Surname@example.com +Received: from gweuoutb1.linde.com ([94.100.245.173]:15826) + by wildfire.ukcod.org.uk with esmtp (Exim 4.69) + (envelope-from <Firstname.Surname@example.com>) + id 1R0pfT-00074Q-Bb + for team@whatdotheyknow.com; Tue, 06 Sep 2011 08:01:59 +0100 +X-IronPort-AV: E=Sophos;i="4.68,337,1312149600"; + d="scan'208,217";a="16336258" +X-Header: No Trailer +Received: from unknown (HELO mlgmuc00mail099.boc.com) ([10.138.224.206]) + by gweub1.linde.grp with ESMTP; 06 Sep 2011 09:01:48 +0200 +Received: from mlgmuc00mail096.boc.com ([10.138.224.203]) by mlgmuc00mail099.boc.com with Microsoft SMTPSVC(6.0.3790.4675); + Tue, 6 Sep 2011 09:02:24 +0200 +Received: from VSUK4EX01.eu.boc.com ([172.18.77.27]) by mlgmuc00mail096.boc.com with Microsoft SMTPSVC(6.0.3790.4675); + Tue, 6 Sep 2011 09:01:32 +0200 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01CC6C62.CEC3EF3C" +Subject: Out of Office AutoReply: Was the response you got to your FOI request any good? +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Date: Tue, 6 Sep 2011 08:01:31 +0100 +Message-ID: <E75A6D7A72D76346A4BF6A27672C39AB11BFF525@VSUK4EX01.eu.boc.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Was the response you got to your FOI request any good? +Thread-Index: AcxsYs6PUz9cAAJDScO38LEWgNj/CQAAAA2I +From: "Surname,Firstname" <Firstname.Surname@example.com> +To: "WhatDoTheyKnow" <team@whatdotheyknow.com> +X-OriginalArrivalTime: 06 Sep 2011 07:01:32.0883 (UTC) FILETIME=[CF626A30:01CC6C62] +List-Id: Admin Team for What Do They Know <team@whatdotheyknow.com> + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01CC6C62.CEC3EF3C +Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +I am out of the office and have limited access to my emails until Thursday = +nth Bartember. If you have an urgent query the please telephone me on 1234= +5678. + + +The information contained in this email and any attachments may be confiden= +tial and is provided solely for the use of the intended recipient(s). If yo= +u are not the intended recipient, you are hereby notified that any disclosu= +re, distribution, or use of this e-mail, its attachments or any information= + contained therein is unauthorized and prohibited. If you have received thi= +s in error, please contact the sender immediately and delete this e-mail an= +d any attachments. + +No responsibility is accepted for any virus or defect that might arise from= + opening this e-mail or attachments, whether or not it has been checked by = +anti-virus software. + +------_=_NextPart_001_01CC6C62.CEC3EF3C +Content-Type: text/html; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> +<HEAD> +<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Diso-8859-= +1"> +<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 6.5.7654.12"> +<TITLE>Out of Office AutoReply: Was the response you got to your FOI reques= +t any good?</TITLE> +</HEAD> +<BODY> +<!-- Converted from text/plain format --> + +<P><FONT SIZE=3D2>I am out of the office and have limited access to my emai= +ls until Thursday 8th September. If you have an urgent query the plea= +se telephone me on 12345678.</FONT></P> + +<font face=3D"monospace"><br> +<br> +The information contained in this email and any attachments may be confiden= +tial and is provided solely for the use of the intended recipient(s). If yo= +u are not the intended recipient, you are hereby notified that any disclosu= +re, distribution, or use of this e-mail, its attachments or any information= + contained therein is unauthorized and prohibited. If you have received thi= +s in error, please contact the sender immediately and delete this e-mail an= +d any attachments.<br> +<br> +No responsibility is accepted for any virus or defect that might arise from= + opening this e-mail or attachments, whether or not it has been checked by = +anti-virus software.</font></BODY> +</HTML> +------_=_NextPart_001_01CC6C62.CEC3EF3C-- + diff --git a/spec/fixtures/files/track-response-exim-bounce.email b/spec/fixtures/files/track-response-exim-bounce.email new file mode 100644 index 000000000..8d40380b1 --- /dev/null +++ b/spec/fixtures/files/track-response-exim-bounce.email @@ -0,0 +1,67 @@ +Delivered-To: mysociety.robin@gmail.com +Received: by 10.216.187.197 with SMTP id y47cs98510wem; + Tue, 6 Sep 2011 14:22:44 -0700 (PDT) +Received: by 10.216.203.79 with SMTP id e57mr78207weo.42.1315344164092; + Tue, 06 Sep 2011 14:22:44 -0700 (PDT) +Return-Path: <> +Received: from wildfire.ukcod.org.uk (wildfire.ukcod.org.uk [89.238.145.74]) + by mx.google.com with ESMTPS id n64si9483505weq.102.2011.09.06.14.22.42 + (version=TLSv1/SSLv3 cipher=OTHER); + Tue, 06 Sep 2011 14:22:43 -0700 (PDT) +Received-SPF: pass (google.com: best guess record for domain of wildfire.ukcod.org.uk designates 89.238.145.74 as permitted sender) client-ip=89.238.145.74; +Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of wildfire.ukcod.org.uk designates 89.238.145.74 as permitted sender) smtp.mail= +Received: from Debian-exim by wildfire.ukcod.org.uk with local (Exim 4.69) + id 1R136L-0003xr-1Q + for team@whatdotheyknow.com; Tue, 06 Sep 2011 22:22:37 +0100 +X-Failed-Recipients: user@example.com +Auto-Submitted: auto-replied +From: Mail Delivery System <Mailer-Daemon@wildfire.ukcod.org.uk> +To: team@whatdotheyknow.com +Subject: Mail delivery failed: returning message to sender +Message-Id: <E1R136L-0003xr-1Q@wildfire.ukcod.org.uk> +Date: Tue, 06 Sep 2011 22:22:37 +0100 +List-Id: Admin Team for What Do They Know <team@whatdotheyknow.com> + +This message was created automatically by mail delivery software. + +A message that you sent could not be delivered to one or more of its +recipients. This is a permanent error. The following address(es) failed: + + user@example.com + Unrouteable address + +------ This is a copy of the message, including all the headers. ------ + +Return-path: <team@whatdotheyknow.com> +Received: from foi by wildfire.ukcod.org.uk with local (Exim 4.69) + (envelope-from <team@whatdotheyknow.com>) + id 1R136J-0003xp-Td + for user@example.com; Tue, 06 Sep 2011 22:22:36 +0100 +Date: Tue, 6 Sep 2011 22:22:35 +0100 +From: WhatDoTheyKnow <team@whatdotheyknow.com> +To: Nonexistent User <user@example.com> +Subject: Your WhatDoTheyKnow email alert +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Precedence: bulk +Auto-Submitted: auto-generated +Message-Id: <E1R136J-0003xp-Td@wildfire.ukcod.org.uk> + +FOI requests to 'Maritime and Coastguard Agency' +================================================ + +-- MCA & HM Coastguard Official Vehicles -- +Maritime and Coastguard Agency sent a response to Peter Smith (12 August 2011) + "Peter In response (reference F0000881) to your FOI questions the + MCA answer is:- 1. All MCA vehicles are purchased outright. 2. Yes + there is a volu..." +http://www.whatdotheyknow.com/request/mca_hm_coastguard_official_vehic#incoming-201529 + + +Alter your subscription +======================= + +Please click on the link below to cancel or alter these emails. +http://www.whatdotheyknow.com/c/ie4pkpy70dl4b8flsig + +-- the WhatDoTheyKnow team diff --git a/spec/fixtures/files/track-response-generic-oof.email b/spec/fixtures/files/track-response-generic-oof.email new file mode 100644 index 000000000..bf1e3e8fe --- /dev/null +++ b/spec/fixtures/files/track-response-generic-oof.email @@ -0,0 +1,8 @@ +From: Someone <someone@example.com> +Subject: Out of Office: Notification blah blah blah +To: track@whatdotheyknow.com +Return-Path: <> +Content-Type: text/plain; charset=utf-8 + +I am out of the office till the 12th of February, hunting lions in Africa. + diff --git a/spec/fixtures/files/track-response-lotus-oof-1.email b/spec/fixtures/files/track-response-lotus-oof-1.email new file mode 100644 index 000000000..dbe63714d --- /dev/null +++ b/spec/fixtures/files/track-response-lotus-oof-1.email @@ -0,0 +1,58 @@ +Delivered-To: mysociety.robin@gmail.com +Received: by 10.216.187.197 with SMTP id y47cs137414wem; + Wed, 7 Sep 2011 14:02:45 -0700 (PDT) +Received: by 10.227.179.14 with SMTP id bo14mr1666492wbb.90.1315429363348; + Wed, 07 Sep 2011 14:02:43 -0700 (PDT) +Return-Path: <Arnos.Grove@example.net> +Received: from wildfire.ukcod.org.uk (wildfire.ukcod.org.uk [89.238.145.74]) + by mx.google.com with ESMTPS id 2si1547851wbx.79.2011.09.07.14.02.41 + (version=TLSv1/SSLv3 cipher=OTHER); + Wed, 07 Sep 2011 14:02:42 -0700 (PDT) +Received-SPF: neutral (google.com: 89.238.145.74 is neither permitted nor denied by best guess record for domain of Arnos.Grove@example.net) client-ip=89.238.145.74; +Authentication-Results: mx.google.com; spf=neutral (google.com: 89.238.145.74 is neither permitted nor denied by best guess record for domain of Arnos.Grove@example.net) smtp.mail=Arnos.Grove@example.net +Received: from foi by wildfire.ukcod.org.uk with local (Exim 4.69) + (envelope-from <Arnos.Grove@example.net>) + id 1R1PGV-0008Gu-GX + for team@whatdotheyknow.com; Wed, 07 Sep 2011 22:02:35 +0100 +Received: from eu1sys200aog108.obsmtp.com ([207.126.144.125]:54514) + by wildfire.ukcod.org.uk with smtp (Exim 4.69) + (envelope-from <Arnos.Grove@example.net>) + id 1R1PGS-0008Go-Ih + for track@whatdotheyknow.com; Wed, 07 Sep 2011 22:02:32 +0100 +Received: from DomG5P.tm-gnet.com ([80.195.120.125]) by eu1sys200aob108.postini.com ([207.126.147.11]) with SMTP + ID DSNKTmfb6CEGJQfujkX1ZzzGzMsn6uoI+AGs@postini.com; Wed, 07 Sep 2011 21:02:32 UTC +Received: from dc3-email-02.tm-gnet.com ([10.145.42.2]) + by DomG5P.tm-gnet.com (Lotus Domino Release 7.0.3) + with ESMTP id 2011090722024075-323511 ; + Wed, 7 Sep 2011 22:02:40 +0100 +Subject: Emma McKinney/MAIL/BIR/MG_REG is out of the office +Auto-Submitted: auto-generated +From: Arnos.Grove@example.net +To: track@whatdotheyknow.com +Message-ID: <OF82EB79DF.C2563724-ON80257904.00739633-80257904.00739633@TrinityMirror.com> +Date: Wed, 7 Sep 2011 22:02:30 +0100 +MIME-Version: 1.0 +X-MIMETrack: Serialize by Router on DC3-Email-02/GMH(Release 8.5.1FP4|July 25, 2010) at + 07/09/2011 22:02:31, + Itemize by SMTP Server on DomG5P/GMH(Release 7.0.3|September 26, 2007) at + 09/07/2011 22:02:40, + Serialize by Router on DomG5P/GMH(Release 7.0.3|September 26, 2007) at 09/07/2011 + 22:02:41, + Serialize complete at 09/07/2011 22:02:41 +Content-type: text/plain; charset=US-ASCII +List-Id: Admin Team for What Do They Know <team@whatdotheyknow.com> + + +I will be out of the office starting dd/mm/yyyy and will not return until +dd/mm/yyyy. + +If you need to contact anyone urgently while I'm out of the office call +aaaa bbb cccc or aaaa bbb dddd. + +******************** +IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It may also contain confidential and privileged information. If you are not the intended recipient, any reliance on, use, disclosure, distribution or copying of this email or attachments is strictly prohibited. Please notify the sender immediately by email if you have received this message by mistake and delete the email and all attachments. + +Any views or opinions in this email are solely those of the author and do not necessarily represent those of Brickbat Industries PLC or its associated group companies (hereinafter referred to as "BI Group"). BI Group accept no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Although every reasonable effort is made to keep its network free from viruses, BI Group accept no liability for any virus transmitted by this email or any attachments and the recipient should use up-to-date virus checking software. Email to or from this address may be subject to interception or monitoring for operational reasons or for lawful business practices. + +Brickbat PLC is the parent company of the Brickbat group of companies and is registered in England No 99999, with its address at Nine Made-up Lane, Arnos Grove. +******************** diff --git a/spec/fixtures/files/track-response-messageclass-oof.email b/spec/fixtures/files/track-response-messageclass-oof.email new file mode 100644 index 000000000..ce82b6df0 --- /dev/null +++ b/spec/fixtures/files/track-response-messageclass-oof.email @@ -0,0 +1,63 @@ +Delivered-To: mysociety.robin@gmail.com +Received: by 10.216.187.197 with SMTP id y47cs177522wem; + Thu, 8 Sep 2011 14:01:27 -0700 (PDT) +Received: by 10.216.220.168 with SMTP id o40mr1165141wep.75.1315515686762; + Thu, 08 Sep 2011 14:01:26 -0700 (PDT) +Return-Path: <MAILER-DAEMON@wildfire.ukcod.org.uk> +Received: from wildfire.ukcod.org.uk (wildfire.ukcod.org.uk [89.238.145.74]) + by mx.google.com with ESMTPS id k18si4719546wed.16.2011.09.08.14.01.25 + (version=TLSv1/SSLv3 cipher=OTHER); + Thu, 08 Sep 2011 14:01:25 -0700 (PDT) +Received-SPF: pass (google.com: best guess record for domain of MAILER-DAEMON@wildfire.ukcod.org.uk designates 89.238.145.74 as permitted sender) client-ip=89.238.145.74; +Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of MAILER-DAEMON@wildfire.ukcod.org.uk designates 89.238.145.74 as permitted sender) smtp.mail=MAILER-DAEMON@wildfire.ukcod.org.uk +Received: from foi by wildfire.ukcod.org.uk with local (Exim 4.69) + (envelope-from <MAILER-DAEMON@wildfire.ukcod.org.uk>) + id 1R1lio-0004zB-Fv + for team_delivery@whatdotheyknow.com; Thu, 08 Sep 2011 22:01:18 +0100 +Received: from mailproxy2.newsquest.co.uk ([93.174.8.201]:2528) + by wildfire.ukcod.org.uk with esmtp (Exim 4.69) + id 1R1lin-0004z2-Lk + for track@whatdotheyknow.com; Thu, 08 Sep 2011 22:01:17 +0100 +X-IronPort-AV: E=Sophos;i="4.68,352,1312153200"; + d="scan'208";a="450582625" +Content-Type: multipart/mixed; boundary="===============1667734580==" +MIME-Version: 1.0 +Received: from sx-mailtraq.se.ad.newsquest.co.uk (sx-mailtraq.se.ad.newsquest.co.uk [10.50.6.12]) + by nqsussex.co.uk with ESMTP (Mailtraq/2.12.0.2278) id NQSSF0865193 + for track@whatdotheyknow.com; Thu, 08 Sep 2011 22:01:04 +0100 +From: "bjarne.stroustrup" <bjarne.stroustrup@example.co.uk> +To: track@whatdotheyknow.com +Date: Thu, 08 Sep 2011 22:01:01 +0100 +Message-ID: <THRGF086ADB9@example.co.uk> +Subject: Automatic Response +X-Hops: 1 +X-POST-MessageClass: 9; Autoresponder + +--===============1667734580== +MIME-Version: 1.0 +Content-Type: text/plain; charset="" + +I am out of the office until Tuesday, January 20. If your email is +urgent please resend it to news@example.co.uk. +Thanks very much +Boris + +--===============1667734580== +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +This email has been scanned for viruses and other threats using Newsquest's= + Ironport email filters. + +This document is private and confidential. +All property, copyright and other rights in it and its contents belong to +ewsquest Media Group Limited. +It must not be read, copied, disclosed or otherwise used without Newsquest= +=E2=80=99s authorisation. Newsquest may exercise its legal rights and remed= +ies in the event of any such unauthorised use. + + +--===============1667734580==-- + diff --git a/spec/fixtures/files/track-response-messagelabs-oof-1.email b/spec/fixtures/files/track-response-messagelabs-oof-1.email new file mode 100644 index 000000000..7cd5d6b8d --- /dev/null +++ b/spec/fixtures/files/track-response-messagelabs-oof-1.email @@ -0,0 +1,62 @@ +Delivered-To: mysociety.robin@gmail.com +Received: by 10.216.187.197 with SMTP id y47cs96363wem; + Tue, 6 Sep 2011 13:24:49 -0700 (PDT) +Received: by 10.216.229.200 with SMTP id h50mr234738weq.32.1315340689299; + Tue, 06 Sep 2011 13:24:49 -0700 (PDT) +Return-Path: <rick.rollington@parliament.uk> +Received: from majestic.ukcod.org.uk (majestic.ukcod.org.uk [89.238.145.68]) + by mx.google.com with ESMTPS id j13si9391756wed.109.2011.09.06.13.24.48 + (version=TLSv1/SSLv3 cipher=OTHER); + Tue, 06 Sep 2011 13:24:49 -0700 (PDT) +Received-SPF: pass (google.com: domain of rick.rollington@parliament.uk designates 89.238.145.68 as permitted sender) client-ip=89.238.145.68; +Authentication-Results: mx.google.com; spf=pass (google.com: domain of rick.rollington@parliament.uk designates 89.238.145.68 as permitted sender) smtp.mail=rick.rollington@parliament.uk +Received: from mail82.messagelabs.com ([195.245.231.67]:4996) + by majestic.ukcod.org.uk with esmtp (Exim 4.72) + (envelope-from <rick.rollington@parliament.uk>) + id 1R12CI-000465-Gx + for team@whatdotheyknow.com; Tue, 06 Sep 2011 21:24:42 +0100 +X-Env-Sender: rick.rollington@parliament.uk +X-Msg-Ref: server-4.tower-82.messagelabs.com!1315340670!59450288!1 +X-Originating-IP: [194.60.38.7] +X-StarScan-Version: 6.3.6; banners=-,-,- +X-VirusChecked: Checked +Received: (qmail 4246 invoked from network); 6 Sep 2011 20:24:31 -0000 +Received: from hpux13x.parliament.uk (HELO hpux13x.parliament.uk) (194.60.38.7) + by server-4.tower-82.messagelabs.com with DHE-RSA-AES256-SHA encrypted SMTP; 6 Sep 2011 20:24:31 -0000 +Received: from MMEH001.parliament.uk (mmeh001.parliament.uk [10.100.70.11]) + by hpux13x.parliament.uk with ESMTP id p86KOKNw039771 + for <team@whatdotheyknow.com>; Tue, 6 Sep 2011 21:24:20 +0100 (BST) +Received: from MMEM001.parliament.uk ([169.254.1.45]) by MMEH001.parliament.uk + ([10.100.70.11]) with mapi; Tue, 6 Sep 2011 21:24:20 +0100 +From: "ROLLINGTON, Rick" <rick.rollington@parliament.uk> +To: WhatDoTheyKnow <team@whatdotheyknow.com> +Date: Tue, 6 Sep 2011 21:24:20 +0100 +Subject: Out of Office +Thread-Topic: Out of Office +Thread-Index: Acxs0vWVKlHifbrXTBmxr7r0Rh9bhwAAAAGd +Message-ID: <93A0DC80C8953B4B88DB2726AE921E264E8DE93980@MMEM001.parliament.uk> +Accept-Language: en-US, en-GB +Content-Language: en-US +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +acceptlanguage: en-US, en-GB +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +MIME-Version: 1.0 +List-Id: Admin Team for What Do They Know <team@whatdotheyknow.com> + +Thank you for your email. + +I will be out of the office between xnd August and yth September. + +For urgent enquiries please email Paul the Pony at, paul.the.pony@parliame= +nt.uk + + +________________________________ +UK Parliament Disclaimer: +This e-mail is confidential to the intended recipient. If you have received= + it in error, please notify the sender and delete it from your system. Any = +unauthorised use, disclosure, or copying is not permitted. This e-mail has = +been checked for viruses, but no liability is accepted for any damage cause= +d by any virus transmitted by this e-mail.
\ No newline at end of file diff --git a/spec/fixtures/files/track-response-multipart-report.email b/spec/fixtures/files/track-response-multipart-report.email new file mode 100644 index 000000000..4f8e6d86b --- /dev/null +++ b/spec/fixtures/files/track-response-multipart-report.email @@ -0,0 +1,113 @@ +Delivered-To: mysociety.robin@gmail.com +Received: by 10.216.187.197 with SMTP id y47cs96752wem; + Tue, 6 Sep 2011 13:37:26 -0700 (PDT) +Received: by 10.216.212.37 with SMTP id x37mr3361871weo.35.1315341445852; + Tue, 06 Sep 2011 13:37:25 -0700 (PDT) +Return-Path: <> +Received: from wildfire.ukcod.org.uk (wildfire.ukcod.org.uk [89.238.145.74]) + by mx.google.com with ESMTPS id h49si1800318wed.40.2011.09.06.13.37.25 + (version=TLSv1/SSLv3 cipher=OTHER); + Tue, 06 Sep 2011 13:37:25 -0700 (PDT) +Received-SPF: pass (google.com: best guess record for domain of wildfire.ukcod.org.uk designates 89.238.145.74 as permitted sender) client-ip=89.238.145.74; +Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of wildfire.ukcod.org.uk designates 89.238.145.74 as permitted sender) smtp.mail= +Received: from cluster-a.mailcontrol.com ([85.115.52.190]:43258) + by wildfire.ukcod.org.uk with esmtp (Exim 4.69) + id 1R12OV-0003KQ-9c + for team@whatdotheyknow.com; Tue, 06 Sep 2011 21:37:19 +0100 +Received: from mail.example.com ([62.6.240.178]) + by rly22a.srv.mailcontrol.com (MailControl) with ESMTP id p86KbIZV025877 + (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) + for <team@whatdotheyknow.com>; Tue, 6 Sep 2011 21:37:18 +0100 +Received: from MX05.example.com (10.100.14.57) by GCEX534.PHSGROUP.local + (10.100.21.78) with Microsoft SMTP Server id 14.1.270.1; Tue, 6 Sep 2011 + 21:38:52 +0100 +From: <postmaster@xyz.local> +To: <team@whatdotheyknow.com> +Date: Tue, 6 Sep 2011 21:37:13 +0100 +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="9B095B5ADSN=_01CC68D9CD29F1E300015B60MX05.example.com" +X-DSNContext: 7ce717b1 - 1148 - 00000002 - 00000000 +Message-ID: <DEU8FnRwh00000d1b@MX05.example.com> +Subject: Delivery Status Notification (Failure) +X-Scanned-By: MailControl A-12-01-02 (www.mailcontrol.com) on 10.65.0.132 +List-Id: Admin Team for What Do They Know <team@whatdotheyknow.com> + +--9B095B5ADSN=_01CC68D9CD29F1E300015B60MX05.example.com +Content-Type: text/plain; charset="unicode-1-1-utf-7" + +This is an automatically generated Delivery Status Notification. + +Delivery to the following recipients failed. + + FailedUser@example.com + + + + +--9B095B5ADSN=_01CC68D9CD29F1E300015B60MX05.example.com +Content-Type: message/delivery-status + +Reporting-MTA: dns;MX05.example.com +Received-From-MTA: dns;MX04.example.com +Arrival-Date: Tue, 6 Sep 2011 21:37:13 +0100 + +Final-Recipient: rfc822;FailedUser@example.com +Action: failed +Status: 5.2.2 +X-Display-Name: Failed User + + +--9B095B5ADSN=_01CC68D9CD29F1E300015B60MX05.example.com +Content-Type: message/rfc822 + +Received: from MX04.example.com ([10.100.14.56]) by MX05.example.com with + Microsoft SMTPSVC(5.0.2195.6713); Tue, 6 Sep 2011 21:37:13 +0100 +Received: from DCEX553.example.com ([10.211.10.27]) by MX04.example.com with + Microsoft SMTPSVC(5.0.2195.6713); Tue, 6 Sep 2011 21:37:13 +0100 +Received: from cluster-a.mailcontrol.com (85.115.52.190) by mail.example.com + (10.211.10.27) with Microsoft SMTP Server id 14.1.270.1; Tue, 6 Sep 2011 + 20:36:49 +0100 +Received: from wildfire.ukcod.org.uk (wildfire.ukcod.org.uk [89.238.145.74]) + by rly01a.srv.mailcontrol.com (MailControl) with ESMTP id p86KbAZN016792 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for + <faileduser@example.com>; Tue, 6 Sep 2011 21:37:11 +0100 +Received: from foi by wildfire.ukcod.org.uk with local (Exim 4.69) + (envelope-from <team@whatdotheyknow.com>) id 1R12OL-0003K9-UE for + faileduser@example.com; Tue, 06 Sep 2011 21:37:10 +0100 +Date: Tue, 6 Sep 2011 21:37:09 +0100 +From: WhatDoTheyKnow <team@whatdotheyknow.com> +To: Failed <faileduser@example.com> +Subject: Your WhatDoTheyKnow email alert +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Precedence: bulk +Auto-Submitted: auto-generated +Message-ID: <E1R12OL-0003K9-UE@wildfire.ukcod.org.uk> +X-Mailcontrol-Inbound: 7DN0MnCsYCrl5jj2!rZ4BuxxWQ2q0l7t3Lrex4V7ScCE2eoC2RNzHw== +X-Spam-Score: -0.857 +X-Scanned-By: MailControl A-12-01-02 (www.mailcontrol.com) on 10.65.0.111 +Return-Path: team@whatdotheyknow.com +X-OriginalArrivalTime: 06 Sep 2011 20:37:13.0070 (UTC) FILETIME=[C20250E0:01CC6CD4] + +Requests or responses matching 'bottled water cooler' +===================================================== + +-- HS2 meetings - Agendas and Minutes -- +Warwickshire County Council sent a response to Richard Jones (21 July 2011) + "Dear Mr Jones FREEDOM OF INFORMATION ACT 2000 - INFORMATION + REQUEST Your request for information has now been considered. The + information you have..." +http://www.whatdotheyknow.com/request/hs2_meetings_agendas_and_minutes_2#incoming-195748 + + +Alter your subscription +======================= + +Please click on the link below to cancel or alter these emails. +http://www.whatdotheyknow.com/c/f76ffwifzlo5sk4egr3 + +-- the WhatDoTheyKnow team + + +--9B095B5ADSN=_01CC68D9CD29F1E300015B60MX05.example.com--
\ No newline at end of file diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml index 2485c95a0..16ffec034 100644 --- a/spec/fixtures/users.yml +++ b/spec/fixtures/users.yml @@ -10,6 +10,7 @@ bob_smith_user: email_confirmed: true admin_level: 'none' ban_text: '' + locale: 'en' about_me: 'I like making requests about fancy dogs and naughty chickens and stuff.' silly_name_user: id: "2" @@ -20,9 +21,10 @@ silly_name_user: hashed_password: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 # jonespassword updated_at: 2007-11-01 10:39:15.491593 created_at: 2007-11-01 10:39:15.491593 - email_confirmed: false + email_confirmed: true admin_level: 'none' ban_text: '' + locale: 'en' about_me: '' admin_user: id: "3" @@ -36,4 +38,18 @@ admin_user: email_confirmed: false admin_level: 'super' ban_text: '' + locale: '' + about_me: '' +unconfirmed_user: + id: "4" + name: "Unconfirmed" + url_name: unconfirmed + email: unconfirmed@localhost + salt: "-6116981980.392287733335677" + hashed_password: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 # jonespassword + updated_at: 2007-11-01 10:39:15.491593 + created_at: 2007-11-01 10:39:15.491593 + email_confirmed: false + admin_level: 'none' + ban_text: '' about_me: '' diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb index 84a44c9c3..c64ca79e8 100644 --- a/spec/integration/errors_spec.rb +++ b/spec/integration/errors_spec.rb @@ -1,18 +1,5 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -module TestCustomStates - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - def theme_extra_states - return ['crotchety'] - end - end -end - - describe "When rendering errors" do fixtures [ :info_requests, @@ -49,11 +36,8 @@ describe "When rendering errors" do end it "should render a 500 for general errors" do ir = info_requests(:naughty_chicken_request) - InfoRequest.send(:include, TestCustomStates) - InfoRequest.class_eval('@@custom_states_loaded = true') - ir.set_described_state("crotchety") - ir.save! - InfoRequest.class_eval('@@custom_states_loaded = false') + # Set an invalid state for the request. Note that update_attribute doesn't run the validations + ir.update_attribute(:described_state, "crotchety") get("/request/#{ir.url_title}") response.code.should == "500" end diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb index 84239f7a3..dcd20c7bd 100644 --- a/spec/integration/search_request_spec.rb +++ b/spec/integration/search_request_spec.rb @@ -13,7 +13,8 @@ describe "When searching" do :comments ] before(:each) do - load_raw_emails_data(raw_emails) + emails = raw_emails.clone + load_raw_emails_data(emails) end it "should not strip quotes from quoted query" do @@ -25,14 +26,19 @@ describe "When searching" do request_via_redirect("post", "/search", :query => 'bob' ) - response.body.should include("One person matching") + response.body.should include("FOI requests") end it "should correctly filter searches for requests" do request_via_redirect("post", "/search/bob/requests") - response.body.should_not include("One person matching") + response.body.should_not include("One person found") response.body.should include("FOI requests 1 to 2 of 2") end + it "should correctly filter searches for users" do + request_via_redirect("post", "/search/bob/users") + response.body.should include("One person found") + response.body.should_not include("FOI requests 1 to 2 of 2") + end it "should correctly filter searches for successful requests" do request_via_redirect("post", "/search", @@ -45,7 +51,7 @@ describe "When searching" do request_via_redirect("post", "/search", :query => "daftest", :request_variety => ['comments']) - response.body.should include("One FOI request matching your search") + response.body.should include("One FOI request found") request_via_redirect("post", "/search", :query => "daftest", diff --git a/spec/lib/external_command_scripts/output.sh b/spec/lib/external_command_scripts/output.sh deleted file mode 100755 index 0472c89a3..000000000 --- a/spec/lib/external_command_scripts/output.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -out_msg=${1:-out} -err_msg=${2:-} -repeats=${3:-10} -exit_status=${4:-0} - -n=0 -while [ "$n" -lt "$repeats" ] -do - if [ -n "$out_msg" ] - then - echo "$out_msg $n" - fi - if [ -n "$err_msg" ] - then - echo >&2 "$err_msg $n" - fi - n=$[$n + 1] -done - -exit "$exit_status" diff --git a/spec/lib/external_command_spec.rb b/spec/lib/external_command_spec.rb deleted file mode 100644 index 0ff1a9c0a..000000000 --- a/spec/lib/external_command_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -# This is a test of the external_command library - -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -script_dir = File.join(File.dirname(__FILE__), 'external_command_scripts') -output_script = File.join(script_dir, "output.sh") - -require 'external_command' - -describe "when running ExternalCommand" do - - it "should get correct status code for /bin/true" do - t = ExternalCommand.new("/bin/true").run() - t.status.should == 0 - t.out.should == "" - t.err.should == "" - end - - it "should get correct status code for /bin/false" do - f = ExternalCommand.new("/bin/false").run() - f.status.should == 1 - f.out.should == "" - f.err.should == "" - end - - it "should get stdout and stderr" do - f = ExternalCommand.new(output_script, "out", "err", "10", "23").run() - f.status.should == 23 - f.out.should == (0..9).map {|i| "out #{i}\n"}.join("") - f.err.should == (0..9).map {|i| "err #{i}\n"}.join("") - end - - it "should work with large amounts of data" do - f = ExternalCommand.new(output_script, "a longer output line", "a longer error line", "10000", "5").run() - f.status.should == 5 - f.out.should == (0..9999).map {|i| "a longer output line #{i}\n"}.join("") - f.err.should == (0..9999).map {|i| "a longer error line #{i}\n"}.join("") - end - -end - diff --git a/spec/models/customstates.rb b/spec/models/customstates.rb index 406d4ead9..3488e6730 100644 --- a/spec/models/customstates.rb +++ b/spec/models/customstates.rb @@ -5,16 +5,6 @@ module InfoRequestCustomStates end # Mixin methods for InfoRequest - def theme_display_status(status) - if status == 'deadline_extended' - _("Deadline extended.") - elsif status == 'wrong_response' - _("Wrong Response.") - else - raise _("unknown status ") + status - end - end - def theme_calculate_status return 'waiting_classification' if self.awaiting_description waiting_response = self.described_state == "waiting_response" || self.described_state == "deadline_extended" @@ -41,6 +31,16 @@ module InfoRequestCustomStates end module ClassMethods + def theme_display_status(status) + if status == 'deadline_extended' + _("Deadline extended.") + elsif status == 'wrong_response' + _("Wrong Response.") + else + raise _("unknown status ") + status + end + end + def theme_extra_states return ['deadline_extended', 'wrong_response'] diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 183a258af..d6923da21 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -79,11 +79,21 @@ describe IncomingMessage, " folding quoted parts of emails" do end describe IncomingMessage, " checking validity to reply to" do - def test_email(email, result) + def test_email(result, email, return_path, autosubmitted) @address = mock(TMail::Address) @address.stub!(:spec).and_return(email) + + @return_path = mock(TMail::ReturnPathHeader) + @return_path.stub!(:addr).and_return(return_path) + + @autosubmitted = mock(TMail::KeywordsHeader) + @autosubmitted.stub!(:keys).and_return(autosubmitted) + @mail = mock(TMail::Mail) @mail.stub!(:from_addrs).and_return( [ @address ] ) + @mail.stub!(:[]).with("return-path").and_return(@return_path) + @mail.stub!(:[]).with("auto-submitted").and_return(@autosubmitted) + @incoming_message = IncomingMessage.new() @incoming_message.stub!(:mail).and_return(@mail) @@ -91,27 +101,63 @@ describe IncomingMessage, " checking validity to reply to" do end it "says a valid email is fine" do - test_email("team@mysociety.org", true) + test_email(true, "team@mysociety.org", nil, []) end it "says postmaster email is bad" do - test_email("postmaster@mysociety.org", false) + test_email(false, "postmaster@mysociety.org", nil, []) end it "says Mailer-Daemon email is bad" do - test_email("Mailer-Daemon@mysociety.org", false) + test_email(false, "Mailer-Daemon@mysociety.org", nil, []) end it "says case mangled MaIler-DaemOn email is bad" do - test_email("MaIler-DaemOn@mysociety.org", false) + test_email(false, "MaIler-DaemOn@mysociety.org", nil, []) end it "says Auto_Reply email is bad" do - test_email("Auto_Reply@mysociety.org", false) + test_email(false, "Auto_Reply@mysociety.org", nil, []) end it "says DoNotReply email is bad" do - test_email("DoNotReply@tube.tfl.gov.uk", false) + test_email(false, "DoNotReply@tube.tfl.gov.uk", nil, []) + end + + it "says a filled-out return-path is fine" do + test_email(true, "team@mysociety.org", "Return-path: <foo@baz.com>", []) + end + + it "says an empty return-path is bad" do + test_email(false, "team@mysociety.org", "<>", []) + end + + it "says an auto-submitted keyword is bad" do + test_email(false, "team@mysociety.org", nil, ["auto-replied"]) + end + +end + +describe IncomingMessage, " checking validity to reply to with real emails" do + fixtures :incoming_messages, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :users + + after(:all) do + ActionMailer::Base.deliveries.clear + end + it "should allow a reply to plain emails" do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('incoming-request-plain.email', ir.incoming_email) + ir.incoming_messages[1].valid_to_reply_to?.should == true + end + it "should not allow a reply to emails with empty return-paths" do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('empty-return-path.email', ir.incoming_email) + ir.incoming_messages[1].valid_to_reply_to?.should == false + end + it "should not allow a reply to emails with autoresponse headers" do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('autoresponse-header.email', ir.incoming_email) + ir.incoming_messages[1].valid_to_reply_to?.should == false end end diff --git a/spec/models/outgoing_mailer_spec.rb b/spec/models/outgoing_mailer_spec.rb index d7587cb41..c96a3fb74 100644 --- a/spec/models/outgoing_mailer_spec.rb +++ b/spec/models/outgoing_mailer_spec.rb @@ -112,7 +112,6 @@ describe OutgoingMailer, "when working out follow up subjects" do it "should not add Re: prefix if there already is a lower case re: prefix" do ir = info_requests(:fancy_dog_request) im = ir.incoming_messages[0] - puts im.raw_email.data om = outgoing_messages(:useless_outgoing_message) om.incoming_message_followup = im diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index 3902e3662..d2b10d493 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -227,17 +227,24 @@ describe PublicBody, "when searching" do end describe PublicBody, " when loading CSV files" do + before(:each) do + # InternalBody is created the first time it's accessed, which happens sometimes during imports, + # depending on the tag used. By accessing it here before every test, it doesn't disturb our checks later on + PublicBody.internal_admin_body + end + it "should do a dry run successfully" do original_count = PublicBody.count csv_contents = load_file_fixture("fake-authority-type.csv") - errors, notes = PublicBody.import_csv(csv_contents, 'fake', true, 'someadmin') # true means dry run + errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin') # true means dry run errors.should == [] - notes.size.should == 3 + notes.size.should == 4 notes.should == [ "line 1: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"request_email\":\"north_west_foi@localhost\"\}", "line 2: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"request_email\":\"scottish_foi@localhost\"\}", - "line 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"request_email\":\"ni_foi@localhost\"\}" + "line 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"request_email\":\"ni_foi@localhost\"\}", + "Notes: Some bodies are in database, but not in CSV file:\n Department for Humpadinking\n Geraldine Quango\nYou may want to delete them manually.\n" ] PublicBody.count.should == original_count @@ -247,48 +254,104 @@ describe PublicBody, " when loading CSV files" do original_count = PublicBody.count csv_contents = load_file_fixture("fake-authority-type.csv") - errors, notes = PublicBody.import_csv(csv_contents, 'fake', false, 'someadmin') # false means real run + errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', false, 'someadmin') # false means real run errors.should == [] - notes.size.should == 3 + notes.size.should == 4 notes.should == [ "line 1: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"request_email\":\"north_west_foi@localhost\"\}", "line 2: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"request_email\":\"scottish_foi@localhost\"\}", - "line 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"request_email\":\"ni_foi@localhost\"\}" + "line 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"request_email\":\"ni_foi@localhost\"\}", + "Notes: Some bodies are in database, but not in CSV file:\n Department for Humpadinking\n Geraldine Quango\nYou may want to delete them manually.\n" ] PublicBody.count.should == original_count + 3 end + it "should do imports without a tag successfully" do + original_count = PublicBody.count + + csv_contents = load_file_fixture("fake-authority-type.csv") + errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', false, 'someadmin') # false means real run + errors.should == [] + notes.size.should == 4 + notes.should == [ + "line 1: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"request_email\":\"north_west_foi@localhost\"\}", + "line 2: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"request_email\":\"scottish_foi@localhost\"\}", + "line 3: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"request_email\":\"ni_foi@localhost\"\}", + "Notes: Some bodies are in database, but not in CSV file:\n Department for Humpadinking\n Geraldine Quango\nYou may want to delete them manually.\n" + ] + PublicBody.count.should == original_count + 3 + end + it "should handle a field list and fields out of order" do original_count = PublicBody.count csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") - errors, notes = PublicBody.import_csv(csv_contents, 'fake', true, 'someadmin') # true means dry run + errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin') # true means dry run errors.should == [] - notes.size.should == 3 + notes.size.should == 4 notes.should == [ "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"\}", - "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\"\}", - "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"request_email\":\"ni_foi@localhost\"\}" + "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"tag_string\":\"scottish\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\"\}", + "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"tag_string\":\"fake aTag\",\"request_email\":\"ni_foi@localhost\"\}", + "Notes: Some bodies are in database, but not in CSV file:\n Department for Humpadinking\n Geraldine Quango\nYou may want to delete them manually.\n" ] PublicBody.count.should == original_count end + + it "should import tags successfully when the import tag is not set" do + csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") + errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', false, 'someadmin') # false means real run + + PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == [] + PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['scottish'] + PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['fake', 'aTag'] + + # Import again to check the 'add' tag functionality works + new_tags_file = load_file_fixture('fake-authority-add-tags.rb') + errors, notes = PublicBody.import_csv(new_tags_file, '', 'add', false, 'someadmin') # false means real run + + # Check tags were added successfully + PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == ['aTag'] + PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['scottish', 'aTag'] + PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['fake', 'aTag'] + end + + it "should import tags successfully when the import tag is set" do + csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") + errors, notes = PublicBody.import_csv(csv_contents, 'fake', 'add', false, 'someadmin') # false means real run + + # Check new bodies were imported successfully + PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == ['fake'] + PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['scottish', 'fake'] + PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['fake', 'aTag'] + + # Import again to check the 'replace' tag functionality works + new_tags_file = load_file_fixture('fake-authority-add-tags.rb') + errors, notes = PublicBody.import_csv(new_tags_file, 'fake', 'replace', false, 'someadmin') # false means real run + + # Check tags were added successfully + PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == ['aTag'] + PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['aTag'] + PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['fake', 'aTag'] + end it "should create bodies with names in multiple locales" do original_count = PublicBody.count csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") - errors, notes = PublicBody.import_csv(csv_contents, 'fake', false, 'someadmin', [:en, :es]) + errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', false, 'someadmin', [:en, :es]) errors.should == [] - notes.size.should == 6 + notes.size.should == 7 notes.should == [ "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t{\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"}", "line 2: creating new authority 'North West Fake Authority' (locale: es):\n\t{\"name\":\"Autoridad del Nordeste\"}", - "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\"}", + "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"tag_string\":\"scottish\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\"}", "line 3: creating new authority 'Scottish Fake Authority' (locale: es):\n\t{\"name\":\"Autoridad Escocesa\"}", - "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"request_email\":\"ni_foi@localhost\"}", - "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: es):\n\t{\"name\":\"Autoridad Irlandesa\"}" + "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"tag_string\":\"fake aTag\",\"request_email\":\"ni_foi@localhost\"}", + "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: es):\n\t{\"name\":\"Autoridad Irlandesa\"}", + "Notes: Some bodies are in database, but not in CSV file:\n Department for Humpadinking\n Geraldine Quango\nYou may want to delete them manually.\n" ] PublicBody.count.should == original_count + 3 @@ -304,13 +367,14 @@ describe PublicBody, " when loading CSV files" do original_count = PublicBody.count csv_contents = load_file_fixture("fake-authority-type-with-field-names.csv") - errors, notes = PublicBody.import_csv(csv_contents, 'fake', true, 'someadmin', [:en, :xx]) # true means dry run + errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin', [:en, :xx]) # true means dry run errors.should == [] - notes.size.should == 3 + notes.size.should == 4 notes.should == [ "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t{\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"}", - "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\"}", - "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"request_email\":\"ni_foi@localhost\"}" + "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"tag_string\":\"scottish\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\"}", + "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"tag_string\":\"fake aTag\",\"request_email\":\"ni_foi@localhost\"}", + "Notes: Some bodies are in database, but not in CSV file:\n Department for Humpadinking\n Geraldine Quango\nYou may want to delete them manually.\n" ] PublicBody.count.should == original_count diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb index 828904d02..6612641c1 100644 --- a/spec/models/track_mailer_spec.rb +++ b/spec/models/track_mailer_spec.rb @@ -21,7 +21,9 @@ describe TrackMailer do @user = mock_model(User, :no_xapian_reindex= => false, :last_daily_track_email= => true, :save! => true, - :url_name => 'test-name') + :url_name => 'test-name', + :get_locale => 'en', + :should_be_emailed? => true) User.stub!(:find).and_return([@user]) @user.stub!(:no_xapian_reindex=) end @@ -109,6 +111,36 @@ describe TrackMailer do end + describe 'when a user should not be emailed' do + before do + @user = mock_model(User, :no_xapian_reindex= => false, + :last_daily_track_email= => true, + :save! => true, + :url_name => 'test-name', + :should_be_emailed? => false) + User.stub!(:find).and_return([@user]) + @user.stub!(:no_xapian_reindex=) + end + + it 'should not ask for any daily track things for the user' do + expected_conditions = [ "tracking_user_id = ? and track_medium = ?", @user.id, 'email_daily' ] + TrackThing.should_not_receive(:find).with(:all, :conditions => expected_conditions).and_return([]) + TrackMailer.alert_tracks + end + + + it 'should not set the no_xapian_reindex flag on the user' do + @user.should_not_receive(:no_xapian_reindex=).with(true) + TrackMailer.alert_tracks + end + + it 'should not update the time of the user\'s last daily tracking email' do + @user.should_not_receive(:last_daily_track_email=).with(Time.now) + @user.should_not_receive(:save!) + TrackMailer.alert_tracks + end + end + end describe 'delivering the email' do diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb index 6b9cd6d4a..1a0324a78 100644 --- a/spec/models/track_thing_spec.rb +++ b/spec/models/track_thing_spec.rb @@ -28,5 +28,15 @@ describe TrackThing, "when tracking changes" do found_track.should == @track_thing end + it "will make some sane descriptions of search-based tracks" do + tests = [['bob variety:user', "users matching text 'bob'"], + ['bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)', "requests which are successful or unsuccessful or comments matching text 'bob'"], + ['(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)', 'requests which are awaiting a response']] + for query, description in tests + track_thing = TrackThing.create_track_for_search_query(query) + track_thing.track_query_description.should == description + end + end + end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ee6916ffc..751a61060 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -282,3 +282,26 @@ describe User, "when setting a profile photo" do # end end +describe User, "when unconfirmed" do + fixtures :users + + before do + @user = users(:unconfirmed_user) + end + + it "should not be emailed" do + @user.should_be_emailed?.should be_false + end +end + +describe User, "when emails have bounced" do + fixtures :users + + it "should record bounces" do + User.record_bounce_for_email("bob@localhost", "The reason we think the email bounced (e.g. a bounce message)") + + user = User.find_user_by_email("bob@localhost") + user.email_bounced_at.should_not be_nil + user.email_bounce_message.should == "The reason we think the email bounced (e.g. a bounce message)" + end +end diff --git a/spec/script/handle-mail-replies_spec.rb b/spec/script/handle-mail-replies_spec.rb new file mode 100644 index 000000000..eae0b516b --- /dev/null +++ b/spec/script/handle-mail-replies_spec.rb @@ -0,0 +1,58 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require "external_command" + +def mail_reply_test(email_filename) + Dir.chdir RAILS_ROOT do + xc = ExternalCommand.new("script/handle-mail-replies", "--test") + xc.run(load_file_fixture(email_filename)) + + xc.err.should == "" + return xc + end +end + +describe "When filtering" do + it "should detect an Exim bounce" do + r = mail_reply_test("track-response-exim-bounce.email") + r.status.should == 1 + r.out.should == "user@example.com\n" + end + + it "should pass on a non-bounce message" do + r = mail_reply_test("incoming-request-bad-uuencoding.email") + r.status.should == 0 + r.out.should == "" + end + + it "should detect a multipart bounce" do + r = mail_reply_test("track-response-multipart-report.email") + r.status.should == 1 + r.out.should == "FailedUser@example.com\n" + end + + it "should detect a generic out-of-office" do + r = mail_reply_test("track-response-generic-oof.email") + r.status.should == 2 + end + + it "should detect an Exchange-style out-of-office" do + r = mail_reply_test("track-response-exchange-oof-1.email") + r.status.should == 2 + end + + it "should detect a Lotus Domino-style out-of-office" do + r = mail_reply_test("track-response-lotus-oof-1.email") + r.status.should == 2 + end + + it "should detect a Messagelabs-style out-of-office" do + r = mail_reply_test("track-response-messagelabs-oof-1.email") + r.status.should == 2 + end + + it "should detect an out-of-office that has an X-POST-MessageClass header" do + r = mail_reply_test("track-response-messageclass-oof.email") + r.status.should == 2 + end +end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 42c5ff6bf..2ddf839da 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -148,7 +148,7 @@ if $tempfilecount.nil? end def load_raw_emails_data(raw_emails) - raw_email = raw_emails(:useless_raw_email) + raw_email = raw_emails(:useless_raw_email) begin raw_email.destroy_file_representation! rescue Errno::ENOENT diff --git a/spec/views/public_body/show.rhtml_spec.rb b/spec/views/public_body/show.rhtml_spec.rb index f859b0679..cd81888eb 100644 --- a/spec/views/public_body/show.rhtml_spec.rb +++ b/spec/views/public_body/show.rhtml_spec.rb @@ -48,7 +48,7 @@ describe "when viewing a body" do it "should tell total number of requests" do render "public_body/show" - response.should include_text("4 Freedom of Information requests made") + response.should include_text("4 Freedom of Information requests") end it "should cope with no results" do @@ -68,10 +68,10 @@ describe "when viewing a body" do @pb.stub!(:get_tag_values).and_return(['98765', '12345']) render "public_body/show" - response.should have_tag("div#request_sidebar") do + response.should have_tag("div#header_right") do with_tag("a[href*=?]", /charity-commission.gov.uk.*RegisteredCharityNumber=98765$/) end - response.should have_tag("div#request_sidebar") do + response.should have_tag("div#header_right") do with_tag("a[href*=?]", /charity-commission.gov.uk.*RegisteredCharityNumber=12345$/) end end @@ -81,7 +81,7 @@ describe "when viewing a body" do @pb.stub!(:get_tag_values).and_return(['SC1234']) render "public_body/show" - response.should have_tag("div#request_sidebar") do + response.should have_tag("div#header_right") do with_tag("a[href*=?]", /www.oscr.org.uk.*id=SC1234$/) end end @@ -89,7 +89,7 @@ describe "when viewing a body" do it "should not link to Charity Commission site if we don't have number" do render "public_body/show" - response.should have_tag("div#request_sidebar") do + response.should have_tag("div#header_right") do without_tag("a[href*=?]", /charity-commission.gov.uk/) end end diff --git a/spec/views/request/_after_actions.rhtml_spec.rb b/spec/views/request/_after_actions.rhtml_spec.rb index a92ef2dda..c73f35d33 100644 --- a/spec/views/request/_after_actions.rhtml_spec.rb +++ b/spec/views/request/_after_actions.rhtml_spec.rb @@ -79,30 +79,5 @@ describe 'when displaying actions that can be taken with regard to a request' do it 'should display a link for the request owner to request a review' do expect_owner_link('Request an internal review') end - - describe 'when there is no last response' do - - before do - assigns[:last_response] = nil - end - - it 'should display a link for the request owner to send a follow up' do - expect_owner_link('Send follow up to test public body') - end - - end - - describe 'when there is a last response' do - before do - assigns[:last_response] = mock_model(IncomingMessage, - :valid_to_reply_to? => false) - end - - it 'should display a link for the request owner to reply to the last response' do - expect_owner_link('Reply to test public body') - end - - end - -end
\ No newline at end of file +end |