diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin_censor_rule_controller_spec.rb | 10 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 5 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 4 | ||||
-rw-r--r-- | spec/fixtures/files/incoming-request-empty.email | 8 | ||||
-rw-r--r-- | spec/models/purge_request_spec.rb | 9 | ||||
-rw-r--r-- | spec/models/request_mailer_spec.rb | 22 | ||||
-rw-r--r-- | spec/script/mailin_spec.rb (renamed from spec/script/mailin-spec.rb) | 10 | ||||
-rw-r--r-- | spec/spec_helper.rb | 3 |
8 files changed, 60 insertions, 11 deletions
diff --git a/spec/controllers/admin_censor_rule_controller_spec.rb b/spec/controllers/admin_censor_rule_controller_spec.rb index 8893a858b..fb9ddf594 100644 --- a/spec/controllers/admin_censor_rule_controller_spec.rb +++ b/spec/controllers/admin_censor_rule_controller_spec.rb @@ -2,10 +2,14 @@ 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 } - + before do + basic_auth_login @request + PurgeRequest.destroy_all + end + + it "should create a censor rule and purge the corresponding request from varnish" do - ir = info_requests(:fancy_dog_request) + ir = info_requests(:fancy_dog_request) post :create, :censor_rule => { :text => "meat", :replacement => "tofu", diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 29ece18cb..5f4012737 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -67,6 +67,11 @@ describe PublicBodyController, "when showing a body" do ActionController::Routing::Routes.filters = old_filters end + it "should remember the filter (view) setting on redirecting" do + get :show, :show_locale => "es", :url_name => "tgq", :view => 'successful' + response.should redirect_to show_public_body_successful_url(:url_name => "etgq") + end + it "should redirect to newest name if you use historic name of public body in URL" do get :show, :url_name => "hdink", :view => 'all' response.should redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh") diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 6f25b605a..21dd0853a 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -121,7 +121,9 @@ end describe RequestController, "when changing things that appear on the request page" do - integrate_views + before do + PurgeRequest.destroy_all + end it "should purge the downstream cache when mail is received" do ir = info_requests(:fancy_dog_request) diff --git a/spec/fixtures/files/incoming-request-empty.email b/spec/fixtures/files/incoming-request-empty.email new file mode 100644 index 000000000..890a14f21 --- /dev/null +++ b/spec/fixtures/files/incoming-request-empty.email @@ -0,0 +1,8 @@ +From: EMAIL_FROM +To: FOI Person <EMAIL_TO> +Bcc: +Subject: Re: Nothing to see here. +Reply-To: +In-Reply-To: <471f1eae5d1cb_7347..fdbe67386163@cat.tmail> + + diff --git a/spec/models/purge_request_spec.rb b/spec/models/purge_request_spec.rb index 94fe01317..7b67fca52 100644 --- a/spec/models/purge_request_spec.rb +++ b/spec/models/purge_request_spec.rb @@ -1,12 +1,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'fakeweb' -describe PurgeRequest, "purging things" do +describe PurgeRequest, "purging things" do before do + PurgeRequest.destroy_all FakeWeb.last_request = nil end - it 'should issue purge requests to the server' do + 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") @@ -16,7 +17,7 @@ describe PurgeRequest, "purging things" do PurgeRequest.all().count.should == 0 end - it 'should fail silently for a misconfigured server' do + 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" @@ -29,4 +30,4 @@ describe PurgeRequest, "purging things" do PurgeRequest.all().count.should == 0 end end - + diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index ac30c4844..dd5a322fb 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe RequestMailer, " when receiving incoming mail" do @@ -327,6 +328,27 @@ describe RequestMailer, 'when sending mail when someone has updated an old uncla end + +describe RequestMailer, 'when sending a new response email' do + + before do + @user = mock_model(User, :name_and_email => 'test name and email') + @public_body = mock_model(PublicBody, :name => 'Test public body') + @info_request = mock_model(InfoRequest, :user => @user, + :law_used_full => 'Freedom of Information', + :title => 'Here is a character that needs quoting …', + :public_body => @public_body, + :display_status => 'Refused.', + :url_title => 'test_request') + @incoming_message = mock_model(IncomingMessage, :info_request => @info_request) + end + + it 'should not error when sending mails requests with characters requiring quoting in the subject' do + @mail = RequestMailer.create_new_response(@info_request, @incoming_message) + end + +end + describe RequestMailer, 'requires_admin' do before(:each) do user = mock_model(User, :name_and_email => 'Bruce Jones', diff --git a/spec/script/mailin-spec.rb b/spec/script/mailin_spec.rb index d80789635..f0bca2297 100644 --- a/spec/script/mailin-spec.rb +++ b/spec/script/mailin_spec.rb @@ -4,7 +4,11 @@ require "external_command" def mailin_test(email_filename) Dir.chdir Rails.root do xc = ExternalCommand.new("script/mailin") - xc.run(load_file_fixture(email_filename)) + mail = load_file_fixture(email_filename) + ir = info_requests(:boring_request) + mail.gsub!('EMAIL_TO', ir.incoming_email) + mail.gsub!('EMAIL_FROM', 'responder@localhost') + xc.run(mail) xc.err.should == "" return xc end @@ -13,9 +17,9 @@ end describe "When importing mail into the application" do it "should not produce any output and should return a 0 code on importing a plain email" do - r = mailin_test("incoming-request-plain.email") + r = mailin_test("incoming-request-empty.email") r.status.should == 0 r.out.should == "" end -end
\ No newline at end of file +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 561a75da6..b760c6385 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -222,6 +222,9 @@ if $tempfilecount.nil? end def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET') self.original_process(action, parameters, session, flash, http_method) + # Don't try validating the admin interface. + # TODO: Make the admin interface valid html5 + return if @request.parameters["controller"] =~ /admin_/ # don't validate auto-generated HTML return if @request.query_parameters["action"] == "get_attachment_as_html" # XXX Is there a better way to check this than calling a private method? |