aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/request_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/request_controller_spec.rb')
-rw-r--r--spec/controllers/request_controller_spec.rb58
1 files changed, 57 insertions, 1 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index db5592be1..12ea0cd0a 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -119,6 +119,62 @@ describe RequestController, "when listing recent requests" do
end
+describe RequestController, "when changing things that appear on the request page" do
+
+ integrate_views
+
+ before(:each) do
+ FakeWeb.last_request = nil
+ end
+
+ 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)
+ FakeWeb.last_request.path.should include(ir.url_title)
+ end
+ it "should purge the downstream cache when a comment is added" do
+ ir = info_requests(:fancy_dog_request)
+ ir.should_receive(:purge_in_cache)
+ new_comment = info_requests(:fancy_dog_request).add_comment('I also love making annotations.', users(:bob_smith_user))
+ 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
+ FakeWeb.last_request.path.should include(ir.url_title)
+ end
+ it "should purge the downstream cache when the request is categorised" do
+ ir = info_requests(:fancy_dog_request)
+ ir.should_receive(:purge_in_cache)
+ ir.set_described_state('waiting_clarification')
+ 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!
+ FakeWeb.last_request.path.should include(ir.url_title)
+ 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"
+ FakeWeb.last_request.should == nil
+ ir.user.save!
+ FakeWeb.last_request.path.should include(ir.url_title)
+ 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 AdminController 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.should_receive(:purge_in_cache)
+ ir.prominence = 'hidden'
+ ir.save!
+ end
+end
+
describe RequestController, "when showing one request" do
before(:each) do
@@ -186,7 +242,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! }