aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/request_controller_spec.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-03-09 11:48:38 +0000
committerSeb Bacon <seb.bacon@gmail.com>2012-03-13 13:55:47 +0000
commit76de470b1424be57934e58275a6116afb8eb9b3c (patch)
tree6ed9df78a8acac8278776c831ae6eb08383d935c /spec/controllers/request_controller_spec.rb
parent17373088052029db46f6f8a6243901e442f6015c (diff)
first stab at sending PURGE requests to upstream varnish for request pages. Next step: making it asynchronous, e.g. with a queue of things to purge via a cron job.
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! }