aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/admin_request_controller_spec.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-08-23 17:49:01 +0100
committerLouise Crow <louise.crow@gmail.com>2012-08-23 17:49:01 +0100
commit5ea4882f38bcf18016c82c1e6119c4df5237e96e (patch)
treea393c38b8b4273eee7f4a693c6f4c7a7bd55266f /spec/controllers/admin_request_controller_spec.rb
parentdb8bb7fa5440855420b8f3ce24611a766e52f89e (diff)
parenta311a1892507aacec5bfb2837dd10f5257dfb42c (diff)
Merge remote-tracking branch 'origin/release/0.6.4' into wdtk
Conflicts: app/views/request/show.rhtml spec/models/info_request_spec.rb
Diffstat (limited to 'spec/controllers/admin_request_controller_spec.rb')
-rw-r--r--spec/controllers/admin_request_controller_spec.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb
index eb6f7aebc..252818452 100644
--- a/spec/controllers/admin_request_controller_spec.rb
+++ b/spec/controllers/admin_request_controller_spec.rb
@@ -220,6 +220,56 @@ describe AdminRequestController, "when administering the holding pen" do
post :hide_request, :id => ir.id, :explanation => "Foo", :reason => "vexatious"
end
+ describe 'when hiding an external request' do
+
+ before do
+ @controller.stub!(:expire_for_request)
+ @info_request = mock_model(InfoRequest, :prominence= => nil,
+ :log_event => nil,
+ :set_described_state => nil,
+ :save! => nil,
+ :user => nil,
+ :user_name => 'External User',
+ :is_external? => true)
+ InfoRequest.stub!(:find).with(@info_request.id.to_s).and_return(@info_request)
+ @default_params = { :id => @info_request.id,
+ :explanation => 'Foo',
+ :reason => 'vexatious' }
+ end
+
+ def make_request(params=@default_params)
+ post :hide_request, params
+ end
+
+ it 'should redirect the the admin page for the request' do
+ make_request
+ response.should redirect_to(:controller => 'admin_request',
+ :action => 'show',
+ :id => @info_request.id)
+ end
+
+ it 'should set the request prominence to "requester_only"' do
+ @info_request.should_receive(:prominence=).with('requester_only')
+ @info_request.should_receive(:save!)
+ make_request
+ end
+
+ it 'should not send a notification email' do
+ ContactMailer.should_not_receive(:deliver_from_admin_message)
+ make_request
+ end
+
+ it 'should add a notice to the flash saying that the request has been hidden' do
+ make_request
+ response.flash[:notice].should == "This external request has been hidden"
+ end
+
+ it 'should expire the file cache for the request' do
+ @controller.should_receive(:expire_for_request)
+ make_request
+ end
+ end
+
end
end