aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/purge_request_spec.rb9
-rw-r--r--spec/models/request_mailer_spec.rb34
2 files changed, 27 insertions, 16 deletions
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 5edc8edb6..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',
@@ -344,16 +366,4 @@ describe RequestMailer, 'requires_admin' do
mail.body.should include('http://test.host/en/admin/request/show/123')
end
-
- context 'has an ADMIN_BASE_URL set' do
- before(:each) do
- Configuration::should_receive(:admin_base_url).and_return('http://our.proxy.server/admin/alaveteli/')
- end
-
- it 'body should contain the full admin URL' do
- mail = RequestMailer.deliver_requires_admin(@info_request)
-
- mail.body.should include('http://our.proxy.server/admin/alaveteli/request/show/123')
- end
- end
end