aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/info_request_spec.rb4
-rw-r--r--spec/models/purge_request_spec.rb9
-rw-r--r--spec/models/request_mailer_spec.rb23
3 files changed, 16 insertions, 20 deletions
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index 544852f91..728a538f9 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -426,8 +426,8 @@ describe InfoRequest do
before do
Time.stub!(:now).and_return(Time.utc(2007, 11, 9, 23, 59))
- @mock_comment_event = safe_mock_model(InfoRequestEvent, :created_at => Time.now - 23.days, :event_type => 'comment')
- @mock_response_event = safe_mock_model(InfoRequestEvent, :created_at => Time.now - 22.days, :event_type => 'response')
+ @mock_comment_event = safe_mock_model(InfoRequestEvent, :created_at => Time.now - 23.days, :event_type => 'comment', :response? => false)
+ @mock_response_event = safe_mock_model(InfoRequestEvent, :created_at => Time.now - 22.days, :event_type => 'response', :response? => true)
@info_request = InfoRequest.new(:prominence => 'normal',
:awaiting_description => true,
:info_request_events => [@mock_response_event, @mock_comment_event])
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 20d401a63..40133eedc 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
@@ -27,7 +28,7 @@ describe RequestMailer, " when receiving incoming mail" do
receive_incoming_mail('incoming-request-plain.email', 'dummy@localhost')
ir.incoming_messages.size.should == 1
InfoRequest.holding_pen_request.incoming_messages.size.should == 1
- last_event = InfoRequest.holding_pen_request.incoming_messages[0].info_request.get_last_event
+ last_event = InfoRequest.holding_pen_request.incoming_messages[0].info_request.info_request_events.last
last_event.params[:rejected_reason].should == "Could not identify the request from the email address"
deliveries = ActionMailer::Base.deliveries
@@ -47,7 +48,7 @@ describe RequestMailer, " when receiving incoming mail" do
receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "")
ir.incoming_messages.size.should == 1
InfoRequest.holding_pen_request.incoming_messages.size.should == 1
- last_event = InfoRequest.holding_pen_request.incoming_messages[0].info_request.get_last_event
+ last_event = InfoRequest.holding_pen_request.incoming_messages[0].info_request.info_request_events.last
last_event.params[:rejected_reason].should =~ /there is no "From" address/
deliveries = ActionMailer::Base.deliveries
@@ -67,7 +68,7 @@ describe RequestMailer, " when receiving incoming mail" do
receive_incoming_mail('incoming-request-plain.email', ir.incoming_email, "frob@nowhere.com")
ir.incoming_messages.size.should == 1
InfoRequest.holding_pen_request.incoming_messages.size.should == 1
- last_event = InfoRequest.holding_pen_request.incoming_messages[0].info_request.get_last_event
+ last_event = InfoRequest.holding_pen_request.incoming_messages[0].info_request.info_request_events.last
last_event.params[:rejected_reason].should =~ /Only the authority can reply/
deliveries = ActionMailer::Base.deliveries
@@ -152,7 +153,7 @@ describe RequestMailer, " when receiving incoming mail" do
receive_incoming_mail('incoming-request-plain.email', ir.incoming_email)
ir.incoming_messages.size.should == 1
InfoRequest.holding_pen_request.incoming_messages.size.should == 1 # arrives in holding pen
- last_event = InfoRequest.holding_pen_request.incoming_messages[0].info_request.get_last_event
+ last_event = InfoRequest.holding_pen_request.incoming_messages[0].info_request.info_request_events.last
last_event.params[:rejected_reason].should =~ /allow new responses from nobody/
# should be a message to admin regarding holding pen
@@ -366,15 +367,9 @@ 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
+ it "body should contain the message from the user" do
+ mail = RequestMailer.deliver_requires_admin(@info_request, nil, "Something has gone wrong")
+ mail.body.should include 'Something has gone wrong'
end
+
end