aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/request_controller_spec.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-12-03 10:15:42 +0000
committerLouise Crow <louise.crow@gmail.com>2013-12-04 09:32:39 +0000
commit6c824047da0f5aa98e6ca08cf3aae391c5225efe (patch)
tree747e24c74fe03f8f5d975b6f85c348deef0a90cc /spec/controllers/request_controller_spec.rb
parentd75607f15efe0886ee008c4425b824b485e612bc (diff)
Add template for select_authorities
Should retain a list of selected public bodies across searches.
Diffstat (limited to 'spec/controllers/request_controller_spec.rb')
-rw-r--r--spec/controllers/request_controller_spec.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 1a95a5ac5..d29552b15 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -897,7 +897,7 @@ describe RequestController, "when handling prominence" do
expect_hidden('request/hidden_correspondence')
end
- it 'should download attachments for an admin user', :focus => true do
+ it 'should download attachments for an admin user' do
session[:user_id] = FactoryGirl.create(:admin_user).id
get :get_attachment, :incoming_message_id => @incoming_message.id,
:id => @info_request.id,
@@ -959,7 +959,7 @@ describe RequestController, "when handling prominence" do
response.should be_success
end
- it 'should download attachments for an admin user', :focus => true do
+ it 'should download attachments for an admin user' do
session[:user_id] = FactoryGirl.create(:admin_user).id
get :get_attachment, :incoming_message_id => @incoming_message.id,
:id => @info_request.id,
@@ -2514,6 +2514,8 @@ describe RequestController, "#select_authorities" do
context "when batch requests is enabled" do
before do
+ get_fixtures_xapian_index
+ load_raw_emails_data
AlaveteliConfiguration.stub!(:allow_batch_requests).and_return(true)
end
@@ -2528,6 +2530,34 @@ describe RequestController, "#select_authorities" do
response.should be_success
end
+ it 'should render the "select_authorities" template' do
+ get :select_authorities, {}, {:user_id => @user.id}
+ response.should render_template('request/select_authorities')
+ end
+
+ it 'should assign a list of search results to the view if passed a query' do
+ get :select_authorities, {:public_body_query => "Quango"}, {:user_id => @user.id}
+ assigns[:search_bodies].results.size.should == 1
+ assigns[:search_bodies].results[0][:model].name.should == public_bodies(:geraldine_public_body).name
+ end
+
+ it 'should assign a list of public bodies to the view if passed a list of ids' do
+ get :select_authorities, {:public_body_ids => [public_bodies(:humpadink_public_body).id]},
+ {:user_id => @user.id}
+ assigns[:public_bodies].size.should == 1
+ assigns[:public_bodies][0].name.should == public_bodies(:humpadink_public_body).name
+ end
+
+ it 'should subtract a list of public bodies to remove from the list of bodies assigned to
+ the view' do
+ get :select_authorities, {:public_body_ids => [public_bodies(:humpadink_public_body).id,
+ public_bodies(:geraldine_public_body).id],
+ :remove_public_body_ids => [public_bodies(:geraldine_public_body).id]},
+ {:user_id => @user.id}
+ assigns[:public_bodies].size.should == 1
+ assigns[:public_bodies][0].name.should == public_bodies(:humpadink_public_body).name
+ end
+
end
context "when the current user can't make batch requests" do