diff options
Diffstat (limited to 'spec')
20 files changed, 1098 insertions, 50 deletions
diff --git a/spec/controllers/admin_censor_rule_controller_spec.rb b/spec/controllers/admin_censor_rule_controller_spec.rb new file mode 100644 index 000000000..8893a858b --- /dev/null +++ b/spec/controllers/admin_censor_rule_controller_spec.rb @@ -0,0 +1,19 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe AdminCensorRuleController, "when making censor rules from the admin interface" do + integrate_views + before { basic_auth_login @request } + + it "should create a censor rule and purge the corresponding request from varnish" do + ir = info_requests(:fancy_dog_request) + post :create, :censor_rule => { + :text => "meat", + :replacement => "tofu", + :last_edit_comment => "none", + :info_request => ir + } + PurgeRequest.all().first.model_id.should == ir.id + end + + +end diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb index 1e82a0ba4..171cb21b5 100644 --- a/spec/controllers/admin_public_body_controller_spec.rb +++ b/spec/controllers/admin_public_body_controller_spec.rb @@ -4,10 +4,6 @@ describe AdminPublicBodyController, "when administering public bodies" do integrate_views before do - username = MySociety::Config.get('ADMIN_USERNAME', '') - password = MySociety::Config.get('ADMIN_PASSWORD', '') - basic_auth_login @request - @old_filters = ActionController::Routing::Routes.filters ActionController::Routing::Routes.filters = RoutingFilter::Chain.new end @@ -80,19 +76,29 @@ describe AdminPublicBodyController, "when administering public bodies and paying integrate_views + before do + config = MySociety::Config.load_default() + config['SKIP_ADMIN_AUTH'] = false + basic_auth_login @request + end + after do + config = MySociety::Config.load_default() + config['SKIP_ADMIN_AUTH'] = true + end + + it "disallows non-authenticated users to do anything" do @request.env["HTTP_AUTHORIZATION"] = "" n = PublicBody.count post :destroy, { :id => 3 } - response.code.should == "401" + response.should redirect_to(:controller=>'user', :action=>'signin', :token=>PostRedirect.get_last_post_redirect.token) PublicBody.count.should == n session[:using_admin].should == nil end - it "skips admin authorisation when no username/password set" do + it "skips admin authorisation when SKIP_ADMIN_AUTH set" do config = MySociety::Config.load_default() - config['ADMIN_USERNAME'] = '' - config['ADMIN_PASSWORD'] = '' + config['SKIP_ADMIN_AUTH'] = true @request.env["HTTP_AUTHORIZATION"] = "" n = PublicBody.count @@ -101,30 +107,44 @@ describe AdminPublicBodyController, "when administering public bodies and paying session[:using_admin].should == 1 end - it "skips admin authorisation when no username set" do + it "doesn't let people with bad credentials log in" do config = MySociety::Config.load_default() - config['ADMIN_USERNAME'] = '' + config['SKIP_ADMIN_AUTH'] = false + config['ADMIN_USERNAME'] = 'biz' config['ADMIN_PASSWORD'] = 'fuz' @request.env["HTTP_AUTHORIZATION"] = "" - n = PublicBody.count + basic_auth_login(@request, "baduser", "badpassword") post :destroy, { :id => public_bodies(:forlorn_public_body).id } - PublicBody.count.should == n - 1 - session[:using_admin].should == 1 + response.should redirect_to(:controller=>'user', :action=>'signin', :token=>PostRedirect.get_last_post_redirect.token) + PublicBody.count.should == n + session[:using_admin].should == nil end - it "forces authorisation when password and username set" do + + it "allows people with good credentials log in using HTTP Basic Auth" do config = MySociety::Config.load_default() + config['SKIP_ADMIN_AUTH'] = false config['ADMIN_USERNAME'] = 'biz' config['ADMIN_PASSWORD'] = 'fuz' @request.env["HTTP_AUTHORIZATION"] = "" n = PublicBody.count - basic_auth_login(@request, "baduser", "badpassword") + basic_auth_login(@request, "biz", "fuz") + post :show, { :id => public_bodies(:humpadink_public_body).id, :emergency => 1} + session[:using_admin].should == 1 + n = PublicBody.count post :destroy, { :id => public_bodies(:forlorn_public_body).id } - response.code.should == "401" - PublicBody.count.should == n - session[:using_admin].should == nil + session[:using_admin].should == 1 + PublicBody.count.should == n - 1 end + it "allows superusers to do stuff" do + session[:user_id] = users(:admin_user).id + @request.env["HTTP_AUTHORIZATION"] = "" + n = PublicBody.count + post :destroy, { :id => public_bodies(:forlorn_public_body).id } + PublicBody.count.should == n - 1 + session[:using_admin].should == 1 + end end @@ -132,12 +152,6 @@ end describe AdminPublicBodyController, "when administering public bodies with i18n" do integrate_views - before do - username = MySociety::Config.get('ADMIN_USERNAME', '') - password = MySociety::Config.get('ADMIN_PASSWORD', '') - basic_auth_login @request - end - it "shows the index page" do get :index end @@ -201,10 +215,6 @@ describe AdminPublicBodyController, "when creating public bodies with i18n" do integrate_views before do - username = MySociety::Config.get('ADMIN_USERNAME', '') - password = MySociety::Config.get('ADMIN_PASSWORD', '') - basic_auth_login @request - @old_filters = ActionController::Routing::Routes.filters ActionController::Routing::Routes.filters = RoutingFilter::Chain.new end diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index ece1fe389..b0468822a 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -86,6 +86,27 @@ describe AdminRequestController, "when administering the holding pen" do response.should redirect_to(:controller=>'admin_request', :action=>'show', :id=>101) InfoRequest.holding_pen_request.incoming_messages.length.should == 0 end + it "allows redelivery to more than one request" do + ir1 = info_requests(:fancy_dog_request) + ir1.allow_new_responses_from = 'nobody' + ir1.handle_rejected_responses = 'holding_pen' + ir1.save! + ir1.incoming_messages.length.should == 1 + ir2 = info_requests(:another_boring_request) + ir2.incoming_messages.length.should == 1 + + receive_incoming_mail('incoming-request-plain.email', ir1.incoming_email, "frob@nowhere.com") + InfoRequest.holding_pen_request.incoming_messages.length.should == 1 + + new_im = InfoRequest.holding_pen_request.incoming_messages[0] + post :redeliver_incoming, :redeliver_incoming_message_id => new_im.id, :url_title => "#{ir1.url_title},#{ir2.url_title}" + ir1.reload + ir1.incoming_messages.length.should == 2 + ir2.reload + ir2.incoming_messages.length.should == 2 + response.should redirect_to(:controller=>'admin_request', :action=>'show', :id=>ir2.id) + InfoRequest.holding_pen_request.incoming_messages.length.should == 0 + end it "guesses a misdirected request" do ir = info_requests(:fancy_dog_request) @@ -110,4 +131,26 @@ describe AdminRequestController, "when administering the holding pen" do assert_equal File.exists?(raw_email), false end + it "shows a suitable default 'your email has been hidden' message" do + ir = info_requests(:fancy_dog_request) + get :show, :id => ir.id + assigns[:request_hidden_user_explanation].should include(ir.user.name) + assigns[:request_hidden_user_explanation].should include("vexatious") + get :show, :id => ir.id, :reason => "not_foi" + assigns[:request_hidden_user_explanation].should_not include("vexatious") + assigns[:request_hidden_user_explanation].should include("not a valid FOI") + end + + it "hides requests and sends a notification email that it has done so" do + ir = info_requests(:fancy_dog_request) + post :hide_request, :id => ir.id, :explanation => "Foo", :reason => "vexatious" + ir.reload + ir.prominence.should == "requester_only" + ir.described_state.should == "vexatious" + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 1 + mail = deliveries[0] + mail.body.should =~ /Foo/ + end + end diff --git a/spec/controllers/admin_user_controller_spec.rb b/spec/controllers/admin_user_controller_spec.rb index c2d645fd2..cf3665c9f 100644 --- a/spec/controllers/admin_user_controller_spec.rb +++ b/spec/controllers/admin_user_controller_spec.rb @@ -2,9 +2,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe AdminUserController, "when administering users" do integrate_views - before do - basic_auth_login @request - end it "shows the index/list page" do get :index diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 81f4ed6d5..8a08ab7d0 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -215,5 +215,10 @@ describe GeneralController, "when searching" do assigns[:xapian_users].results.map{|x|x[:model]}.should == [u] end + it "should show tracking links for requests-only searches" do + get :search, :combined => ['"bob"', "requests"] + response.body.should include('Track this search') + end + end diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index e6eca0781..9eca43aee 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -1,7 +1,5 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -require 'json' - describe PublicBodyController, "when showing a body" do integrate_views diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 9add32f1e..c70284748 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -require 'json' - describe RequestController, "when listing recent requests" do before(:each) do @@ -66,6 +64,14 @@ describe RequestController, "when listing recent requests" do assigns[:cache_tag].size.should <= 32 end + it "should vary the cache tag with locale" do + get :list, :view => 'all', :request_date_after => '13/10/2007', :request_date_before => '01/11/2007' + en_tag = assigns[:cache_tag] + session[:locale] = :es + get :list, :view => 'all', :request_date_after => '13/10/2007', :request_date_before => '01/11/2007' + assigns[:cache_tag].should_not == en_tag + end + it "should list internal_review requests as unresolved ones" do get :list, :view => 'awaiting' @@ -119,10 +125,72 @@ describe RequestController, "when listing recent requests" do end +describe RequestController, "when changing things that appear on the request page" do + + integrate_views + + it "should purge the downstream cache when mail is received" do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('incoming-request-plain.email', ir.incoming_email) + PurgeRequest.all().first.model_id.should == ir.id + end + it "should purge the downstream cache when a comment is added" do + ir = info_requests(:fancy_dog_request) + new_comment = info_requests(:fancy_dog_request).add_comment('I also love making annotations.', users(:bob_smith_user)) + PurgeRequest.all().first.model_id.should == ir.id + end + it "should purge the downstream cache when a followup is made" do + session[:user_id] = users(:bob_smith_user).id + ir = info_requests(:fancy_dog_request) + post :show_response, :outgoing_message => { :body => "What a useless response! You suck.", :what_doing => 'normal_sort' }, :id => ir.id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_followup => 1 + PurgeRequest.all().first.model_id.should == ir.id + end + it "should purge the downstream cache when the request is categorised" do + ir = info_requests(:fancy_dog_request) + ir.set_described_state('waiting_clarification') + PurgeRequest.all().first.model_id.should == ir.id + end + it "should purge the downstream cache when the authority data is changed" do + ir = info_requests(:fancy_dog_request) + ir.public_body.name = "Something new" + ir.public_body.save! + PurgeRequest.all().map{|x| x.model_id}.should =~ ir.public_body.info_requests.map{|x| x.id} + end + it "should purge the downstream cache when the user details are changed" do + ir = info_requests(:fancy_dog_request) + ir.user.name = "Something new" + ir.user.save! + PurgeRequest.all().map{|x| x.model_id}.should =~ ir.user.info_requests.map{|x| x.id} + end + it "should purge the downstream cache when censor rules have changed" do + # XXX really, CensorRules should execute expiry logic as part + # of the after_save of the model. Currently this is part of + # the AdminCensorRuleController logic, so must be tested from + # there. Leaving this stub test in place as a reminder + end + it "should purge the downstream cache when something is hidden by an admin" do + ir = info_requests(:fancy_dog_request) + ir.prominence = 'hidden' + ir.save! + PurgeRequest.all().first.model_id.should == ir.id + end + it "should not create more than one entry for any given resourcce" do + ir = info_requests(:fancy_dog_request) + ir.prominence = 'hidden' + ir.save! + PurgeRequest.all().count.should == 1 + ir = info_requests(:fancy_dog_request) + ir.prominence = 'hidden' + ir.save! + PurgeRequest.all().count.should == 1 + end +end + describe RequestController, "when showing one request" do before(:each) do load_raw_emails_data + FileUtils.rm_rf File.join(File.dirname(__FILE__), "../../cache/zips") end it "should be successful" do @@ -186,7 +254,7 @@ describe RequestController, "when showing one request" do describe 'when handling incoming mail' do integrate_views - + it "should receive incoming messages, send email to creator, and show them" do ir = info_requests(:fancy_dog_request) ir.incoming_messages.each { |x| x.parse_raw_email! } @@ -222,7 +290,6 @@ describe RequestController, "when showing one request" do get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt'], :skip_cache => 1 response.content_type.should == "text/plain" response.should have_text(/Second hello/) - get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 3, :file_name => ['hello.txt'], :skip_cache => 1 response.content_type.should == "text/plain" response.should have_text(/First hello/) @@ -351,6 +418,15 @@ describe RequestController, "when showing one request" do response.should have_text(/an unusual sort of file/) end + it "should apply a content-disposition header" do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('incoming-request-attachment-unknown-extension.email', ir.incoming_email) + ir.reload + get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.qwglhm'], :skip_cache => 1 + response.headers.should include("Content-Disposition") + response.headers["Content-Disposition"].should include('hello.qwglhm') + end + it "should not download attachments with wrong file name" do ir = info_requests(:fancy_dog_request) receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) @@ -559,7 +635,7 @@ end # XXX do this for invalid ids # it "should render 404 file" do -# response.should render_template("#{RAILS_ROOT}/public/404.html") +# response.should render_template("#{Rails.root}/public/404.html") # response.headers["Status"].should == "404 Not Found" # end @@ -984,6 +1060,7 @@ describe RequestController, "when classifying an information request" do session[:user_id] = @admin_user.id @dog_request = info_requests(:fancy_dog_request) InfoRequest.stub!(:find).and_return(@dog_request) + @dog_request.stub!(:each).and_return([@dog_request]) end it 'should update the status of the request' do @@ -1025,6 +1102,7 @@ describe RequestController, "when classifying an information request" do @dog_request.user = @admin_user @dog_request.save! InfoRequest.stub!(:find).and_return(@dog_request) + @dog_request.stub!(:each).and_return([@dog_request]) end it 'should update the status of the request' do @@ -1061,6 +1139,7 @@ describe RequestController, "when classifying an information request" do @request_owner = users(:bob_smith_user) session[:user_id] = @request_owner.id @dog_request.awaiting_description.should == true + @dog_request.stub!(:each).and_return([@dog_request]) end it "should successfully classify response if logged in as user controlling request" do @@ -1128,6 +1207,7 @@ describe RequestController, "when classifying an information request" do @request_owner = users(:bob_smith_user) session[:user_id] = @request_owner.id @dog_request = info_requests(:fancy_dog_request) + @dog_request.stub!(:each).and_return([@dog_request]) InfoRequest.stub!(:find).and_return(@dog_request) @old_filters = ActionController::Routing::Routes.filters ActionController::Routing::Routes.filters = RoutingFilter::Chain.new @@ -1737,6 +1817,71 @@ describe RequestController, "when doing type ahead searches" do get :search_typeahead, :q => "dog -chicken" assigns[:xapian_requests].results.size.should == 1 end +end + +describe RequestController, "when showing similar requests" do + integrate_views + + it "should work" do + get :similar, :url_title => info_requests(:badger_request).url_title + response.should render_template("request/similar") + assigns[:info_request].should == info_requests(:badger_request) + end + + it "should show similar requests" do + badger_request = info_requests(:badger_request) + get :similar, :url_title => badger_request.url_title + + # Xapian seems to think *all* the requests are similar + assigns[:xapian_object].results.map{|x|x[:model].info_request}.should =~ InfoRequest.all.reject {|x| x == badger_request} + end + + it "should 404 for non-existent paths" do + lambda { + get :similar, :url_title => "there_is_really_no_such_path_owNAFkHR" + }.should raise_error(ActiveRecord::RecordNotFound) + end + +end + + +describe RequestController, "when reporting a request" do + integrate_views + + it "should mark a request as having been reported" do + ir = info_requests(:badger_request) + title = ir.url_title + get :show, :url_title => title + assigns[:info_request].attention_requested.should == false + get :report_request, :url_title => title + get :show, :url_title => title + assigns[:info_request].attention_requested.should == true + assigns[:info_request].described_state.should == "attention_requested" + end + + it "should not allow a request to be reported twice" do + title = info_requests(:badger_request).url_title + get :report_request, :url_title => title + get :show, :url_title => title + response.body.should include("has been reported") + get :report_request, :url_title => title + get :show, :url_title => title + response.body.should include("has already been reported") + end + + it "should let users know a request has been reported" do + title = info_requests(:badger_request).url_title + get :show, :url_title => title + response.body.should include("Offensive?") + get :report_request, :url_title => title + get :show, :url_title => title + response.body.should_not include("Offensive?") + response.body.should include("This request has been reported") + info_requests(:badger_request).set_described_state("successful") + get :show, :url_title => title + response.body.should_not include("This request has been reported") + response.body.should include("The site administrators have reviewed this request") + end end diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index 1bafd0c8f..2be382258 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe ServicesController, "when using web services" do @@ -16,15 +17,16 @@ describe ServicesController, "when using web services" do config['ISO_COUNTRY_CODE'] = "DE" controller.stub!(:country_from_ip).and_return('ZZ') get :other_country_message - response.body.should match(/outside Germany/) + response.body.should match(/outside Deutschland/) 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') + controller.stub!(:country_from_ip).and_return('ES') + request.env['HTTP_ACCEPT_LANGUAGE'] = "es" get :other_country_message - response.body.should match(/within Germany/) + response.body.should match(/Puede hacer solicitudes de información en España/) end diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index 5d299caa5..1d38b3055 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -1,9 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -require 'json' - describe TrackController, "when making a new track on a request" do - before do + before(:each) do @ir = mock_model(InfoRequest, :url_title => 'myrequest', :title => 'My request') @track_thing = mock_model(TrackThing, :save! => true, @@ -11,12 +9,15 @@ describe TrackController, "when making a new track on a request" do :track_medium= => nil, :tracking_user_id= => nil) TrackThing.stub!(:create_track_for_request).and_return(@track_thing) + TrackThing.stub!(:create_track_for_search_query).and_return(@track_thing) TrackThing.stub!(:find_by_existing_track).and_return(nil) InfoRequest.stub!(:find_by_url_title).and_return(@ir) @user = mock_model(User) User.stub!(:find).and_return(@user) @user.stub!(:locale).and_return("en") + @user.stub!(:receive_email_alerts).and_return(true) + @user.stub!(:url_name).and_return("bob") end it "should require login when making new track" do @@ -25,13 +26,20 @@ describe TrackController, "when making a new track on a request" do response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token) end - it "should save the track and redirect if you are logged in" do + it "should save a request track and redirect if you are logged in" do session[:user_id] = @user.id @track_thing.should_receive(:save!) get :track_request, :url_title => @ir.url_title, :feed => 'track' response.should redirect_to(:controller => 'request', :action => 'show', :url_title => @ir.url_title) end + it "should save a search track and redirect to the right place" do + session[:user_id] = @user.id + @track_thing.should_receive(:save!) + get :track_search_query, :query_array => ["bob variety:sent"], :feed => 'track' + response.should redirect_to(:controller => 'general', :action => 'search', :combined => ["bob", "requests"]) + end + end describe TrackController, "when sending alerts for a track" do diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 40649b6e1..7a6c9ac0d 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -1,8 +1,6 @@ # coding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -require 'json' - # XXX Use route_for or params_from to check /c/ links better # http://rspec.rubyforge.org/rspec-rails/1.1.12/classes/Spec/Rails/Example/ControllerExampleGroup.html @@ -632,6 +630,41 @@ describe UserController, "when showing JSON version for API" do end +describe UserController, "when viewing the wall" do + integrate_views + + before(:each) do + rebuild_xapian_index + end + + it "should show users stuff on their wall, most recent first" do + user = users(:silly_name_user) + ire = info_request_events(:useless_incoming_message_event) + ire.created_at = DateTime.new(2001,1,1) + session[:user_id] = user.id + get :wall, :url_name => user.url_name + assigns[:feed_results][0].should_not == ire + + ire.created_at = Time.now + ire.save! + get :wall, :url_name => user.url_name + assigns[:feed_results][0].should == ire + end + it "should show other users' activities on their walls" do + user = users(:silly_name_user) + ire = info_request_events(:useless_incoming_message_event) + get :wall, :url_name => user.url_name + assigns[:feed_results][0].should_not == ire + end + it "should allow users to turn their own email alerts on and off" do + user = users(:silly_name_user) + session[:user_id] = user.id + user.receive_email_alerts.should == true + get :set_receive_email_alerts, :receive_email_alerts => 'false', :came_from => "/" + user.reload + user.receive_email_alerts.should_not == true + end +end diff --git a/spec/fixtures/files/track-response-ms-bounce.email b/spec/fixtures/files/track-response-ms-bounce.email new file mode 100644 index 000000000..405799d19 --- /dev/null +++ b/spec/fixtures/files/track-response-ms-bounce.email @@ -0,0 +1,168 @@ +Delivered-To: mysociety.robin@gmail.com +Received: by 10.216.93.2 with SMTP id k2csp112824wef; + Tue, 1 May 2012 07:34:18 -0700 (PDT) +Received: by 10.180.86.197 with SMTP id r5mr1890784wiz.21.1335882857831; + Tue, 01 May 2012 07:34:17 -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 m57si21571764wee.109.2012.05.01.07.34.17 + (version=TLSv1/SSLv3 cipher=OTHER); + Tue, 01 May 2012 07:34:17 -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.72) + (envelope-from <MAILER-DAEMON@wildfire.ukcod.org.uk>) + id 1SPE9b-0004QG-IC + for team_delivery@whatdotheyknow.com; Tue, 01 May 2012 15:34:11 +0100 +Received: from majestic.ukcod.org.uk ([89.238.145.68]:41415) + by wildfire.ukcod.org.uk with esmtp (Exim 4.72) + id 1SPE9a-0004PY-Pt + for foi-track@wildfire.ukcod.org.uk; Tue, 01 May 2012 15:34:11 +0100 +Received: from 83-216-147-106.lancas785.adsl.metronet.co.uk ([83.216.147.106]:41706 helo=SERVER1.example.internal) + by majestic.ukcod.org.uk with esmtp (Exim 4.72) + id 1SPE9P-00024F-Vz + for track@whatdotheyknow.com; Tue, 01 May 2012 15:34:00 +0100 +Received: from server.example.internal (192.168.0.2) by + SERVER1.example.internal (192.168.0.3) with Microsoft SMTP Server id + 14.1.323.3; Tue, 1 May 2012 15:43:04 +0100 +From: <postmaster@example.org.uk> +To: <track@whatdotheyknow.com> +Date: Tue, 1 May 2012 11:42:55 +0100 +MIME-Version: 1.0 +X-DSNContext: 7ac7e7f9 - 374 - 00000004 - C00402D1 +Message-ID: <5C10braWX00000031@server.example.internal> +Subject: Delivery Status Notification (Delay) +Content-Type: multipart/mixed; + boundary="_c3f90810-77af-49ee-88c2-d3a2f6212326_" + +--_c3f90810-77af-49ee-88c2-d3a2f6212326_ +Content-Type: multipart/report; report-type=delivery-status; + boundary="_12a1cb74-57e4-4506-a3d9-c4b591d5a63f_" + +--_12a1cb74-57e4-4506-a3d9-c4b591d5a63f_ +Content-Type: text/plain; charset="unicode-1-1-utf-7" + +This is an automatically generated Delivery Status Notification. + +THIS IS A WARNING MESSAGE ONLY. + +YOU DO NOT NEED TO RESEND YOUR MESSAGE. + +Delivery to the following recipients has been delayed. + + username@example.org.uk + + + + +--_12a1cb74-57e4-4506-a3d9-c4b591d5a63f_ +Content-Type: message/delivery-status + +Reporting-MTA: dns;server.example.internal +Received-From-MTA: dns;wildfire.ukcod.org.uk +Arrival-Date: Mon, 30 Apr 2012 23:24:59 +0100 + +Final-Recipient: rfc822;username@example.org.uk +Action: delayed +Status: 4.4.7 +Will-Retry-Until: Wed, 2 May 2012 23:24:59 +0100 + +--_12a1cb74-57e4-4506-a3d9-c4b591d5a63f_ +Content-Type: message/rfc822 + +Received: from wildfire.ukcod.org.uk ([89.238.145.74]) by + server.example.internal with Microsoft SMTPSVC(6.0.3790.4675); Mon, 30 + Apr 2012 23:24:59 +0100 +Received: from foi by wildfire.ukcod.org.uk with local (Exim 4.72) + (envelope-from <track@whatdotheyknow.com>) id 1SOysI-0003iJ-1S for + username@example.org.uk; Mon, 30 Apr 2012 23:15:19 +0100 +Message-ID: <E1SOysI-0003iJ-1S@wildfire.ukcod.org.uk> +Date: Mon, 30 Apr 2012 23:15:17 +0100 +From: WhatDoTheyKnow <track@whatdotheyknow.com> +To: User Name <username@example.org.uk> +Subject: Your WhatDoTheyKnow email alert +MIME-Version: 1.0 +Precedence: bulk +Auto-Submitted: auto-generated +Return-Path: track@whatdotheyknow.com +X-OriginalArrivalTime: 30 Apr 2012 22:24:59.0309 (UTC) FILETIME=[1416D5D0:01CD2720] +X-MS-Exchange-Organization-AVStamp-AVG: 10.0.1424 [2113.1.1/4831];0; +X-MS-Exchange-Organization-AVStamp-Mailbox: AVGESE;6944;0; +Content-Type: multipart/mixed; + boundary="_c03afbbc-87c9-4022-a9f2-fec3c53e1fef_" + +--_c03afbbc-87c9-4022-a9f2-fec3c53e1fef_ +Content-Type: text/plain; charset="utf-8" + +FOI requests to 'Lancashire Constabulary' +========================================= + +-- Copy of Information from Comments made in FOI -- +Jim Ebbs sent a request to Lancashire Constabulary (30 April 2012) + "My previous FOI related to Section 20 of the 1989 Chidrens Act + legislation and parents having parental control of their children. + In your response..." +http://www.whatdotheyknow.com/request/copy_of_information_from_comment#outgoing-199196 + + +FOI requests to 'Lancashire County Council' +=========================================== + +-- Telecommunications Contracts -- +Lancashire County Council sent a response to Wendy (30 April 2012) + "Dear Wendy, Please accept my apologies for not having provided you + with a response before the statutory time limit. I am still in the + process of de..." +http://www.whatdotheyknow.com/request/telecommunications_contracts_20#incoming-277652 + +-- Adult's and childreen's social care IT systems -- +Lancashire County Council sent a response to will johnson (30 April 2012) + "Dear Mr Johnson,  Request for information under the Freedom of + Information Act 2000  Further to your email dated 2^nd April, in + which you re..." +http://www.whatdotheyknow.com/request/adults_and_childreens_social_car#incoming-277643 + + +FOI requests to 'Lancaster City Council' +======================================== + +-- Empty Commercial Property -- +Lancaster City Council sent a response to Paul Norris (30 April 2012) + "Dear Mr Norris Please find attached a spreadheet with the + information you requested for. If you are not happy with this + response please contact me i..." +http://www.whatdotheyknow.com/request/empty_commercial_property_93#incoming-277913 + + +Alter your subscription +======================= + + +http://www.whatdotheyknow.com/c/huz3dzb3gtyq5y47r4r + +-- the WhatDoTheyKnow team + + +--_c03afbbc-87c9-4022-a9f2-fec3c53e1fef_ +Content-Type: text/plain; x-avg=cert; charset="windows-1252" +Content-Disposition: inline; filename="AVG certification.txt" +Content-Description: "AVG certification" +Content-Transfer-Encoding: quoted-printable + +The message does not contain any threats +AVG for MS Exchange Server (10.0.1424 - 2113/4831)= + +--_c03afbbc-87c9-4022-a9f2-fec3c53e1fef_-- + +--_12a1cb74-57e4-4506-a3d9-c4b591d5a63f_-- + +--_c3f90810-77af-49ee-88c2-d3a2f6212326_ +Content-Type: text/plain; x-avg=cert; charset="windows-1252" +Content-Disposition: inline; filename="AVG certification.txt" +Content-Description: "AVG certification" +Content-Transfer-Encoding: quoted-printable + +The message does not contain any threats +AVG for MS Exchange Server (10.0.1424 - 2113/4831)= + +--_c3f90810-77af-49ee-88c2-d3a2f6212326_-- diff --git a/spec/fixtures/files/track-response-webshield-bounce.email b/spec/fixtures/files/track-response-webshield-bounce.email new file mode 100644 index 000000000..1fd0f68ef --- /dev/null +++ b/spec/fixtures/files/track-response-webshield-bounce.email @@ -0,0 +1,513 @@ +Delivered-To: mysociety.robin@gmail.com +Received: by 10.216.93.2 with SMTP id k2csp412wef; + Sat, 28 Apr 2012 15:10:07 -0700 (PDT) +Received: by 10.216.200.90 with SMTP id y68mr994412wen.49.1335651006883; + Sat, 28 Apr 2012 15:10:06 -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 bw9si8451394wib.28.2012.04.28.15.10.06 + (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 28 Apr 2012 15:10:06 -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.72) + (envelope-from <MAILER-DAEMON@wildfire.ukcod.org.uk>) + id 1SOFq3-0002Lx-HQ + for team_delivery@whatdotheyknow.com; Sat, 28 Apr 2012 23:09:59 +0100 +Received: from majestic.ukcod.org.uk ([89.238.145.68]:48989) + by wildfire.ukcod.org.uk with esmtp (Exim 4.72) + id 1SOFq2-0002La-Pq + for foi-track@wildfire.ukcod.org.uk; Sat, 28 Apr 2012 23:09:59 +0100 +Received: from mailproxy1.example.co.uk ([93.174.8.200]:65135) + by majestic.ukcod.org.uk with esmtp (Exim 4.72) + id 1SOFps-0001uQ-4T + for track@whatdotheyknow.com; Sat, 28 Apr 2012 23:09:48 +0100 +Message-Id: <f8b79b$go3iov@mailproxy1.example.co.uk> +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154271" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:37 +0100 +From: Webshield SMTP V4.5 MR3 Mail Service +Date: Sat Apr 28 23:09:37 2012 +To: <track@whatdotheyknow.com> +Subject: Returned Mail: Error During Delivery + + ---- Failed Recipients ---- + +<failed.user@example.co.uk> +Mail Loop Detected + + +Requested action aborted: Mail loop detected + + ---- Contents of the undelivered mail ---- + +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650976813; Sat, 28 Apr 2012 23:09:36 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154267" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:36 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650976250; Sat, 28 Apr 2012 23:09:36 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154266" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:36 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650975812; Sat, 28 Apr 2012 23:09:35 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154264" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:35 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650975250; Sat, 28 Apr 2012 23:09:35 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154263" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:35 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650974469; Sat, 28 Apr 2012 23:09:34 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154259" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:34 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650973250; Sat, 28 Apr 2012 23:09:33 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154255" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:33 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650972250; Sat, 28 Apr 2012 23:09:32 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154253" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:32 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650971250; Sat, 28 Apr 2012 23:09:31 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154250" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:31 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650970797; Sat, 28 Apr 2012 23:09:30 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154247" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:30 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650970250; Sat, 28 Apr 2012 23:09:30 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154246" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:30 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650969797; Sat, 28 Apr 2012 23:09:29 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154244" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:29 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650969250; Sat, 28 Apr 2012 23:09:29 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154243" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:29 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650968250; Sat, 28 Apr 2012 23:09:28 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154241" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:28 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650967250; Sat, 28 Apr 2012 23:09:27 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154238" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:27 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650966250; Sat, 28 Apr 2012 23:09:26 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154236" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:26 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650965828; Sat, 28 Apr 2012 23:09:25 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154235" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:25 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650965250; Sat, 28 Apr 2012 23:09:25 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154234" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:25 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650964781; Sat, 28 Apr 2012 23:09:24 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154233" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:24 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650964250; Sat, 28 Apr 2012 23:09:24 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154231" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:24 +0100 +Received: From mailproxy1.example.co.uk ([192.168.80.80]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 1335650963281; Sat, 28 Apr 2012 23:09:23 +0100 +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="562154222" +Received: from unknown (HELO so-itws3.so.ad.example.co.uk) ([10.56.10.5]) + by mailproxy1.example.co.uk with SMTP; 28 Apr 2012 23:09:18 +0100 +Received: From mailproxy2.example.co.uk ([192.168.80.81]) by so-itws3.so.ad.example.co.uk (WebShield SMTP v4.5 MR3) + id 133565095893; Sat, 28 Apr 2012 23:09:18 +0100 +X-SBRS: 2.9 +X-SG: DEFAULT +X-IronPort-Anti-Spam-Filtered: true +X-IronPort-Anti-Spam-Result: AnQDAGtpnE9Z7pFKgWdsb2JhbAA8B4Mpgj+sMSIBARYmJ4F8AQgBCwIgJhgQAQEVIAYCCQgHDgICAw0sFgsYhUMBAYItARkHpjJSkUqBL4EliDMFB4JeghmBGASMYYEwmxiBUwgLAw +X-IronPort-AV: E=Sophos;i="4.75,497,1330905600"; + d="scan'208";a="514125909" +Received: from wildfire.ukcod.org.uk ([89.238.145.74]) + by mailproxy2.example.co.uk with ESMTP; 28 Apr 2012 23:09:12 +0100 +Received: from foi by wildfire.ukcod.org.uk with local (Exim 4.72) + (envelope-from <track@whatdotheyknow.com>) + id 1SOFpI-0002Iz-6a + for failed.user@example.co.uk; Sat, 28 Apr 2012 23:09:12 +0100 +Message-Id: <E1SOFpI-0002Iz-6a@wildfire.ukcod.org.uk> +Date: Sat, 28 Apr 2012 23:09:10 +0100 +From: WhatDoTheyKnow <track@whatdotheyknow.com> +To: Failed User <failed.user@example.co.uk> +Subject: Your WhatDoTheyKnow email alert +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Precedence: bulk +Auto-Submitted: auto-generated + +Successful Freedom of Information requests +========================================== + +-- geographical address for PO Box 1244, Enfield, EN1 9UF -- +Royal Mail Group Limited sent a response to Mr Mahmood (16 March 2012) + "Dear Mr Mahmood, Please find attached a response to your recent + Freedom of Information Request. Yours Sincerely Kate Fearn Company + Secretary's..." +http://www.whatdotheyknow.com/request/geographical_address_for_po_box_3#incoming-264886 + +-- Foi About Animal Testin -- +University of Strathclyde sent a response to Mr Jonathon Proctor (27 April 2012) + "Dear Mr Proctor,  FOI Request Reference – 2012/050  Thank you + for your email of 03 April 2012 requesting information under the + Freedom of I..." +http://www.whatdotheyknow.com/request/foi_about_animal_testin#incoming-277502 + +-- School's Spend on Recruitment Advertising -- +Staffordshire County Council sent a response to Robert Saunders ( 3 April 2012) + "Dear Mr Saunders Re: Freedom of Information Act 2000 Thank you for + your request for information. We have completed the search of our + records and pl..." +http://www.whatdotheyknow.com/request/schools_spend_on_recruitment_adv_8#incoming-270606 + +-- WBC - Enforcement Team Dog Mess -- +Wirral Metropolitan Borough Council sent a response to Pete Sheffield (26 April 2012) + "Hello Pete Sheffield  Thank you for your request below, Wirral + Council is able to supply the following recorded information, I + have included res..." +http://www.whatdotheyknow.com/request/wbc_enforcement_team_dog_mess#incoming-277027 + +-- City Garden Project technical feasibility study -- +Aberdeen City Council sent a response to Kenneth Watt (24 April 2012) + "Dear Mr Watt Thank you for your information request of 17 April + 2012, made under the Freedom of Information (Scotland) Act 2002 + (FOISA). Aberdeen C..." +http://www.whatdotheyknow.com/request/city_garden_project_technical_fe#incoming-276087 + +-- Government grant -- +Lambeth Borough Council sent a response to Ed Clarke (17 April 2012) + "Dear Ed Clarke, Thank you for your FOI request under reference + 156969 Please accept my apologies for the late response. You asked + " What was the to..." +http://www.whatdotheyknow.com/request/government_grant#incoming-274144 + +-- Advertising Policy -- +Humber Bridge Board sent a response to Mr. A. Wilson (24 April 2012) + "Dear Mr Wilson Thank you for your email of 23rd April 2012. As the + Humber Bridge Board is not a Public Body it is not formally subject + to the Freedo..." +http://www.whatdotheyknow.com/request/advertising_policy#incoming-276348 + +-- Number of roads/estates/areas in the process of being adopted by Oxfordshire County Council -- +Oxfordshire County Council sent a response to Alex Lalvani (17 April 2012) + "Dear Mr. Lalvani  Please find below the definition of an + ‘agreement’ as requested by you further to our response to your + Freedom of Information..." +http://www.whatdotheyknow.com/request/number_of_roadsestatesareas_in_t#incoming-273742 + +-- Correct Diagnosis of Lyme Disease -- +Health Protection Agency sent a response to jacqui butterworth (24 April 2012) + "Dear Ms Butterworth I would like to apologise, for not responding + to the last point you raised in your email of 29th March, regarding + information y..." +http://www.whatdotheyknow.com/request/correct_diagnosis_of_lyme_diseas#incoming-276391 + +-- Genesis -- +Camden Borough Council sent a response to salim (24 April 2012) + "Camden Council - Information request (FOI/EIR) - Housing and adult + social care Our reference: 7706354 + -------------------------------------------..." +http://www.whatdotheyknow.com/request/genesis#incoming-276075 + +-- Missing Persons -- +Humberside Police sent a response to Otis Holmes ( 1 March 2012) + "Your Ref:  Our Ref: F-2012-351  1 March 2012 Dear Mr Holmes, + Please find attached my response to your recent Freedom of + Information requ..." +http://www.whatdotheyknow.com/request/missing_persons_2#incoming-260422 + +-- A reply to my two previous emails -- +Blackpool Borough Council sent a response to Debbie Tomkinson ( 8 December 2011) + "Dear Debbie FREEDOM OF INFORMATION ACT 2000 - INFORMATION REQUEST + I am writing in response to your email of 09.11.12. You were + previously employed..." +http://www.whatdotheyknow.com/request/a_reply_to_my_two_previous_email#incoming-234255 + +-- Expenditure of public funds by Police & CPS on persecution of World War 2 Veteran Norman Scarth -- +Ministry of Justice sent a response to Norman Scarth (24 April 2012) + "Dear Mr Scarth,  Please find herewith our reply to your Freedom + of Information request dated 3rd April 2012.   Mrs K Smith  Mrs + K Smith R..." +http://www.whatdotheyknow.com/request/expenditure_of_public_funds_by_p#incoming-276263 + +-- Security screening at Edinburgh Airport -- +UK Border Agency sent a response to S Gray ( 5 April 2012) + "Sent on behalf of Anne Webber  Dear Mr Gray,  Please find + attached the FOI response.  Kind Regards  Sue  Sue Dinham + Cyclame..." +http://www.whatdotheyknow.com/request/security_screening_at_edinburgh#incoming-271223 + +-- Inverness business improvement district (BID) -- +Highland Council sent a response to Laurel Bush (27 April 2012) + "Dear Mr Bush,  Please find attached the response from William + Gilfillan, in relation to the above Freedom of Information request + dated 26 April..." +http://www.whatdotheyknow.com/request/inverness_business_improvement_d_2#incoming-277507 + +-- Waiting times in Contact Applications -- +Children and Family Court Advisory Support Service sent a response to Philip J Measures (24 April 2012) + "Dear Sir Please find atatched a response to your recent request + for an internal review. Any additioanl information will be provided + by 8th May 2012...." +http://www.whatdotheyknow.com/request/waiting_times_in_contact_applica#incoming-276410 + +-- Payments to companies on behalf of directors -- +Moorfields Eye Hospital NHS Foundation Trust sent a response to Alex Miller ( 5 March 2012) + "Dear Alex Miller  In response to your clarification of 8.2.12, + payments made to permanent managers  and directors employed at the + Trust  are pai..." +http://www.whatdotheyknow.com/request/payments_to_companies_on_behalf#incoming-261184 + +-- Personal Injury Claims -- +Leeds City Council sent a response to Ben Stanley ( 3 April 2012) + "Dear Ben Stanley Please accept my apologies regarding the in + responding to your request. Please see attached letter in respect + of your recent Free..." +http://www.whatdotheyknow.com/request/personal_injury_claims_10#incoming-270346 + +-- Beetham Tower West £750,000 payment. -- +Liverpool City Council sent a response to A Rudkin (24 April 2012) + "Please find attached response Regards, Kevin Symm Senior + Information Officer Legal Services Liverpool City Council Municipal + Buildings Dale St..." +http://www.whatdotheyknow.com/request/beetham_tower_west_750000_paymen_3#incoming-276145 + +-- Housing Benefit statistics -- +Leeds City Council sent a response to Peter Balderston (17 February 2012) + "Dear Mr Balderston, Please see attached letter in respect of your + recent Freedom of Information request. Please contact me if you + have any furthe..." +http://www.whatdotheyknow.com/request/housing_benefit_statistics_19#incoming-255605 + +-- Board Minutes - Accuracy & Completeness -- +Avon and Wiltshire Mental Health Partnership NHS Trust sent a response to Steven King (24 April 2012) + "Dear Mr King, Please see attached correspondence regarding your + Freedom of Information request: <<0718 Response Letter.doc>> Yours + sincerely,..." +http://www.whatdotheyknow.com/request/board_minutes_accuracy_completen#incoming-276314 + +-- Marked vehicle fleet list -- +Gloucestershire Constabulary sent a response to luke (27 April 2012) + "Dear Mr Staddon, Gloucestershire Constabulary Freedom of + Information request 2012.3788 On the 28th March 2012 you sent a + letter constituting a requ..." +http://www.whatdotheyknow.com/request/marked_vehicle_fleet_list_7#incoming-277276 + +-- Quality metrics for decisionmakers. -- +Department for Work and Pensions sent a response to Ian Stirling (26 April 2012) + "Dear Mr Stirling Please see attached response to your FoI request. + Kind regards DWP Central FoI Team Website: www.dwp.gov.uk Your + Reference: I St..." +http://www.whatdotheyknow.com/request/quality_metrics_for_decisionmake#incoming-276968 + +-- Stray Dogs -- +Wirral Metropolitan Borough Council sent a response to Carla Bottle (17 April 2012) + "Hello Carla  Thank you for your further enquiry, I can clarify  + Strays 76  and a further Handovers by owner (sick or aggressive) + 74..." +http://www.whatdotheyknow.com/request/stray_dogs_84#incoming-274073 + +-- Stray Dogs -- +Wakefield City Council sent a response to Carla Bottle (17 April 2012) + "Dear Carla, Freedom of Information Act 2000 - Request for + Information I am writing in respect of your recent enquiry for + information held by the Aut..." +http://www.whatdotheyknow.com/request/stray_dogs_149#incoming-273859 + +-- Stray Dogs -- +Solihull Metropolitan Borough Council sent a response to Carla Bottle (17 April 2012) + "Dear Ms Bottle Thank you for your email. Any dogs collected as + strays are taken to Birmingham Dogs Home, where they are detained + by the home on the..." +http://www.whatdotheyknow.com/request/stray_dogs_136#incoming-273886 + +-- Stray Dogs -- +Newham Borough Council sent a response to Carla Bottle (17 April 2012) + "Dear Ms Bottle, Thank you for your email received on 16/03/2012. + We attach our response under the disclosure provisions of the + Freedom of Information..." +http://www.whatdotheyknow.com/request/stray_dogs_152#incoming-273897 + +-- Stray Dogs -- +St Edmundsbury Borough Council sent a response to Carla Bottle (17 April 2012) + "Dear Carla, Thank you for your email following my response to your + Freedom of Information request. I can advise that the 15 dogs that + were 'rehomed..." +http://www.whatdotheyknow.com/request/stray_dogs_111#incoming-273946 + +-- Stray Dogs -- +Staffordshire Moorlands District Council sent a response to Carla Bottle (17 April 2012) + "E-mail:  [1][FOI #109668 email]    Dear Ms Bottle  Re: + Freedom of Information Act request – Stray Dogs  Thank you for + your e..." +http://www.whatdotheyknow.com/request/stray_dogs_108#incoming-274005 + +-- Stray Dogs -- +Southwark Borough Council sent a response to Carla Bottle (17 April 2012) + "Southwark Council - Information request (FOI/EIR) Our reference: + 214355 + --------------------------------------------------------------------------..." +http://www.whatdotheyknow.com/request/stray_dogs_155#incoming-274104 + +-- Residential Building Revaluation Costs -- +Camden Borough Council sent a response to Peter CAIN (17 April 2012) + "Dear Mr Cain  Herewith the reply of the Panel to your application + for an internal review  Yours sincerely  Peter Swingler Obo + Internal Revie..." +http://www.whatdotheyknow.com/request/residential_building_revaluation#incoming-274061 + +-- Stray Dogs -- +Waveney District Council sent a response to Carla Bottle (17 April 2012) + "Dear Ms Bottle, Freedom of Information Request - Ref No 9932 I am + writing in response to your recently submitted Freedom of + Information request reg..." +http://www.whatdotheyknow.com/request/stray_dogs_112#incoming-274145 + +-- Stray Dogs -- +Tamworth Borough Council sent a response to Carla Bottle (27 April 2012) + "Our Ref: FOI1264/DB/02 Please ask for: Derek Bolton Direct dial: + 01827 709 587 E-mail: [email address]  Ms C Bottle + Whatdotheyknow.com..." +http://www.whatdotheyknow.com/request/stray_dogs_110#incoming-277348 + +-- Stray Dogs -- +South Northamptonshire District Council sent a response to Carla Bottle (23 April 2012) + "South Northamptonshire Council Request Ref: 1013066  Springfields + Towcester Date: Apr 5 2012 Northants NN12 6AE" +http://www.whatdotheyknow.com/request/stray_dogs_89#incoming-275624 + +-- Stray Dogs -- +Selby District Council sent a response to Carla Bottle (23 April 2012) + "Dear Ms Bottle  I refer to your recent request for information + under the Freedom of Information Act. I have now had an opportunity + to check our..." +http://www.whatdotheyknow.com/request/stray_dogs_148#incoming-275917 + +-- DASS Carers Assesment Documents -- +Wirral Metropolitan Borough Council sent a response to Heston O Riley (26 April 2012) + "Hello Heston O Riley  Thank you for request below, apologies for + the slight delay, Wirral Council can now provide the information + you have r..." +http://www.whatdotheyknow.com/request/dass_carers_assesment_documents#incoming-277203 + +-- Traffic offences on Holland Park Barton Under Needwood -- +Staffordshire Police sent a response to Joanne Cooper (24 April 2012) + "Please see another response to your FOI request.   Apologies, but + please discard my first response.  The letter will give an + explanation. Regards..." +http://www.whatdotheyknow.com/request/traffic_offences_on_holland_park#incoming-276112 + +-- Percy Street - Capita report input -- +Newcastle upon Tyne City Council sent a response to Katja Leyendecker (16 April 2012) + "Katja, Firstly let me apologise for the tardy delivery of the + response, I have been on annual leave and did not return until this + morning. I'm afrai..." +http://www.whatdotheyknow.com/request/percy_street_capita_report_input#incoming-273690 + +-- AREa REView COMMITTee CHILd PROtection GUIDElines -- +Nottinghamshire County Council sent a response to Alison Stevens (27 April 2012) + "REF:C&IT/PFL/NCC-007511-11  Dear Ms Stevens  FREEDOM OF + INFORMATION ACT 2000 - INFORMATION REQUEST  In response to your + request for the..." +http://www.whatdotheyknow.com/request/area_review_committee_child_prot#incoming-277510 + +-- Atos HeathcarE Risk AsseSSMENTS -- +Department for Work and Pensions sent a response to Alison Stevens (27 April 2012) + "Dear Ms Stevens Please see attached response to your FoI request. + Kind regards DWP Central FoI Team To A Stevens C/o [FOI #107839 + email] DWP Centr..." +http://www.whatdotheyknow.com/request/atos_heathcare_risk_assessments#incoming-277463 + +-- SET(0) Postal Applications status D2c 2011 -- +UK Border Agency sent a response to S Pillai (29 March 2012) + "S Pillai  Please find the response to your request for + information under the Freedom of Information Act 2000, regarding + SET (O) applications...." +http://www.whatdotheyknow.com/request/set0_postal_applications_status#incoming-269113 + +-- re London Borough of Bromley -- +Local Government Ombudsmen sent a response to ROSEMARY CANTWELL (Account suspended) ( 3 April 2012) + "Dear Mrs Cantwell I have consulted colleagues and they inform me + that you have exhausted our internal complaints procedures and + there is nothing more..." +http://www.whatdotheyknow.com/request/re_london_borough_of_bromley#incoming-270360 + + +Alter your subscription +======================= + + +http://www.whatdotheyknow.com/c/abcdefghijklmnop23 + +-- the WhatDoTheyKnow team + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml index 8620fb3de..d6391c5e8 100644 --- a/spec/fixtures/users.yml +++ b/spec/fixtures/users.yml @@ -12,6 +12,7 @@ bob_smith_user: ban_text: '' locale: 'en' about_me: 'I like making requests about fancy dogs and naughty chickens and stuff.' + receive_email_alerts: true silly_name_user: id: "2" name: "Silly <em>Name</em>" @@ -26,6 +27,7 @@ silly_name_user: ban_text: '' locale: 'en' about_me: '' + receive_email_alerts: true admin_user: id: "3" name: Joe Admin @@ -40,6 +42,7 @@ admin_user: ban_text: '' locale: '' about_me: '' + receive_email_alerts: true unconfirmed_user: id: "4" name: "Unconfirmed" @@ -53,6 +56,7 @@ unconfirmed_user: admin_level: 'none' ban_text: '' about_me: '' + receive_email_alerts: true robin_user: id: 5 name: Robin Houston @@ -66,3 +70,4 @@ robin_user: admin_level: 'none' ban_text: '' about_me: 'I am the best' + receive_email_alerts: true diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb index b62f0a4c4..17a7b4aaa 100644 --- a/spec/integration/search_request_spec.rb +++ b/spec/integration/search_request_spec.rb @@ -12,6 +12,13 @@ describe "When searching" do response.body.should include(""mouse stilton"") end + it "should redirect requests with search in query string to URL-based page" do + url = '/search/all?query=bob' + request_via_redirect("post", url) + response.request.url.should_not include(url) + response.request.url.should include("/search/bob/all") + end + it "should correctly execute simple search" do request_via_redirect("post", "/search", :query => 'bob' diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index db0de78b2..e30916dff 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -401,3 +401,37 @@ describe PublicBody, " when loading CSV files" do PublicBody.count.should == original_count end end + +describe PublicBody do + describe "calculated home page" do + it "should return the home page verbatim if it's present" do + public_body = PublicBody.new + public_body.home_page = "http://www.example.com" + public_body.calculated_home_page.should == "http://www.example.com" + end + + it "should return the home page based on the request email domain if it has one" do + public_body = PublicBody.new + public_body.stub!(:request_email_domain).and_return "public-authority.com" + public_body.calculated_home_page.should == "http://www.public-authority.com" + end + + it "should return nil if there's no home page and the email domain can't be worked out" do + public_body = PublicBody.new + public_body.stub!(:request_email_domain).and_return nil + public_body.calculated_home_page.should be_nil + end + + it "should ensure home page URLs start with http://" do + public_body = PublicBody.new + public_body.home_page = "example.com" + public_body.calculated_home_page.should == "http://example.com" + end + + it "should not add http when https is present" do + public_body = PublicBody.new + public_body.home_page = "https://example.com" + public_body.calculated_home_page.should == "https://example.com" + end + end +end diff --git a/spec/models/purge_request_spec.rb b/spec/models/purge_request_spec.rb new file mode 100644 index 000000000..94fe01317 --- /dev/null +++ b/spec/models/purge_request_spec.rb @@ -0,0 +1,32 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require 'fakeweb' + +describe PurgeRequest, "purging things" do + before do + FakeWeb.last_request = nil + end + + it 'should issue purge requests to the server' do + req = PurgeRequest.new(:url => "/begone_from_here", + :model => "don't care", + :model_id => "don't care") + req.save() + PurgeRequest.all().count.should == 1 + PurgeRequest.purge_all() + PurgeRequest.all().count.should == 0 + end + + it 'should fail silently for a misconfigured server' do + FakeWeb.register_uri(:get, %r|brokenv|, :body => "BROKEN") + config = MySociety::Config.load_default() + config['VARNISH_HOST'] = "brokencache" + req = PurgeRequest.new(:url => "/begone_from_here", + :model => "don't care", + :model_id => "don't care") + req.save() + PurgeRequest.all().count.should == 1 + PurgeRequest.purge_all() + PurgeRequest.all().count.should == 0 + end +end + diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb index 4f5499a90..1bf77dab5 100644 --- a/spec/models/track_mailer_spec.rb +++ b/spec/models/track_mailer_spec.rb @@ -25,6 +25,7 @@ describe TrackMailer do :get_locale => 'en', :should_be_emailed? => true) User.stub!(:find).and_return([@user]) + @user.stub!(:receive_email_alerts).and_return(true) @user.stub!(:no_xapian_reindex=) end @@ -122,6 +123,7 @@ describe TrackMailer do :url_name => 'test-name', :should_be_emailed? => false) User.stub!(:find).and_return([@user]) + @user.stub!(:receive_email_alerts).and_return(true) @user.stub!(:no_xapian_reindex=) end @@ -131,6 +133,13 @@ describe TrackMailer do TrackMailer.alert_tracks end + it 'should not ask for any daily track things for the user if they have receive_email_alerts off but could otherwise be emailed' do + @user.stub(:should_be_emailed?).and_return(true) + @user.stub(:receive_email_alerts).and_return(false) + 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) diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb index bd122941a..345629bd6 100644 --- a/spec/models/track_thing_spec.rb +++ b/spec/models/track_thing_spec.rb @@ -36,7 +36,7 @@ describe TrackThing, "when tracking changes" do 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'"], + ['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)', "comments or requests which are successful or unsuccessful 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) @@ -44,5 +44,10 @@ describe TrackThing, "when tracking changes" do end end + it "will create an authority-based track when called using a 'bodies' postfix" do + track_thing = TrackThing.create_track_for_search_query('fancy dog', 'bodies') + track_thing.track_query.should =~ /variety:authority/ + end + end diff --git a/spec/script/handle-mail-replies_spec.rb b/spec/script/handle-mail-replies_spec.rb index 8ed83b31f..75a2aa6ad 100644 --- a/spec/script/handle-mail-replies_spec.rb +++ b/spec/script/handle-mail-replies_spec.rb @@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require "external_command" def mail_reply_test(email_filename) - Dir.chdir RAILS_ROOT do + Dir.chdir Rails.root do xc = ExternalCommand.new("script/handle-mail-replies", "--test") xc.run(load_file_fixture(email_filename)) @@ -18,6 +18,18 @@ describe "When filtering" do r.out.should == "user@example.com\n" end + it "should detect a WebShield delivery error message" do + r = mail_reply_test("track-response-webshield-bounce.email") + r.status.should == 1 + r.out.should == "failed.user@example.co.uk\n" + end + + it "should detect a MS Exchange non-permanent delivery error message" do + r = mail_reply_test("track-response-ms-bounce.email") + r.status.should == 1 + r.out.should == "" + end + it "should pass on a non-bounce message" do r = mail_reply_test("incoming-request-bad-uuencoding.email") r.status.should == 0 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c00da48bc..a98a5113d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,9 @@ config['ADMIN_PASSWORD'] = 'baz' # tests assume 20 days config['REPLY_LATE_AFTER_DAYS'] = 20 +# register a fake Varnish server +require 'fakeweb' +FakeWeb.register_uri(:purge, %r|varnish.localdomain|, :body => "OK") # Uncomment the next line to use webrat's matchers #require 'webrat/integrations/rspec-rails' @@ -43,7 +46,7 @@ Spec::Runner.configure do |config| # # You can also declare which fixtures to use (for example fixtures for test/fixtures): # - # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' + # config.fixture_path = Rails.root + '/spec/fixtures/' # # == Mock Framework # |