diff options
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 23 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 14 | ||||
-rw-r--r-- | spec/controllers/services_controller_spec.rb | 8 |
3 files changed, 45 insertions, 0 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 840b4bb28..130631ef6 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -70,6 +70,18 @@ describe PublicBodyController, "when showing a body" do get :show, :url_name => "dFh", :view => 'all' response.should redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh") end + + it 'keeps the search_params flash' do + # Make two get requests to simulate the flash getting swept after the + # first response. + search_params = { 'query' => 'Quango' } + get :show, { :url_name => 'dfh', :view => 'all' }, + nil, + { :search_params => search_params } + get :show, :url_name => 'dfh', :view => 'all' + expect(flash[:search_params]).to eq(search_params) + end + end describe PublicBodyController, "when listing bodies" do @@ -479,4 +491,15 @@ describe PublicBodyController, "when doing type ahead searches" do response.should render_template('public_body/_search_ahead') assigns[:xapian_requests].should be_nil end + + it 'remembers the search params' do + search_params = { + 'query' => 'Quango', + 'page' => '1', + 'bodies' => '1' + } + get :search_typeahead, search_params + expect(flash[:search_params]).to eq(search_params) + end + end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 2d3ccfa63..1a2992611 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -956,6 +956,20 @@ describe RequestController, "when searching for an authority" do }.should_not raise_error(StandardError) end end + + it "remembers the search params" do + session[:user_id] = @user.id + search_params = { + 'query' => 'Quango', + 'page' => '1', + 'bodies' => '1' + } + + get :select_authority, search_params + + expect(flash[:search_params]).to eq(search_params) + end + end describe RequestController, "when creating a new request" do diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index 248c97ad4..621dbaaac 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -12,6 +12,14 @@ describe ServicesController, "when returning a message for people in other count @old_locale = FastGettext.locale() end + it 'keeps the flash' do + # Make two get requests to simulate the flash getting swept after the + # first response. + get :other_country_message, nil, nil, :some_flash_key => 'abc' + get :other_country_message + expect(flash[:some_flash_key]).to eq('abc') + end + it "should show no alaveteli message when in the deployed country" do config = MySociety::Config.load_default() config['ISO_COUNTRY_CODE'] = "DE" |