From c8fc7884e1e13e7a46ea720fe7fd4d47d095a67f Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 30 Oct 2014 12:47:58 +0000 Subject: RequestController#search_typeahead filter by body Action now supports the `request_from` param as per the Xapian filtering system to filter search typeaheads by public body --- spec/controllers/request_controller_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 6c0f4573e..ce91f7a83 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -2380,6 +2380,12 @@ describe RequestController, "when doing type ahead searches" do get :search_typeahead, :q => "dog -chicken" assigns[:xapian_requests].results.size.should == 1 end + + it 'can filter search results by public body' do + get :search_typeahead, :q => 'boring', :requested_from => 'dfh' + expect(assigns[:query]).to eq('requested_from:dfh boring') + end + end describe RequestController, "when showing similar requests" do -- cgit v1.2.3 From a9853bf1a41623df1b84656ce8dac6f01231f2cd Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 30 Oct 2014 14:58:40 +0000 Subject: RequestController#search_typaahead limit results Use the per_page parameter to limit the results returned --- spec/controllers/request_controller_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index ce91f7a83..4d0070470 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -2386,6 +2386,17 @@ describe RequestController, "when doing type ahead searches" do expect(assigns[:query]).to eq('requested_from:dfh boring') end + it 'defaults to 25 results per page' do + get :search_typeahead, :q => 'boring' + expect(assigns[:per_page]).to eq(25) + end + + it 'can limit the number of searches returned' do + get :search_typeahead, :q => 'boring', :per_page => '1' + expect(assigns[:per_page]).to eq(1) + expect(assigns[:xapian_requests].results.size).to eq(1) + end + end describe RequestController, "when showing similar requests" do -- cgit v1.2.3 From 224725e202d581d956e8958c521abb00de9935b1 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 27 Nov 2014 10:20:37 +0000 Subject: Refactor the application of masks and censor rules to messages. Seems more logical to make this one method that figures out what to do based on file type. Plus, incoming message does so many things, it seemed like having these related methods be separate would make them easier to read and understand. Also, email, mobile and login substitution texts weren't being translated. Finally, I think passing the censor rules and masks as arguments is a first step in some more decoupling of models. --- spec/controllers/request_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 4d0070470..ba558cc93 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -2447,7 +2447,7 @@ describe RequestController, "when caching fragments" do :info_request_id => 132, :id => 44, :get_attachments_for_display => nil, - :html_mask_stuff! => nil, + :apply_masks! => nil, :user_can_view? => true, :all_can_view? => true) attachment = FactoryGirl.build(:body_text, :filename => long_name) -- cgit v1.2.3 From c272afa68983f21ed72ee11d76ce0a07fdf5b36a Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 23 Dec 2014 14:50:46 +0000 Subject: Remove focus tag --- spec/controllers/request_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index ba558cc93..15e252501 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -2660,7 +2660,7 @@ describe RequestController, "#select_authorities" do end - context 'when asked for JSON', :focus => true do + context 'when asked for JSON' do it 'should be successful' do get :select_authorities, {:public_body_query => "Quan", :format => 'json'}, {:user_id => @user.id} -- cgit v1.2.3 From 99fb6b483cca96bd55a64bc1137e1070e01b32ba Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Wed, 7 Jan 2015 13:40:40 +0000 Subject: Use a partial to render request sent message --- spec/controllers/request_controller_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 2d3ccfa63..dc28f6dab 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1073,6 +1073,16 @@ describe RequestController, "when creating a new request" do response.redirect_url.should =~ /request\/why_is_your_quango_called_gerald\/new$/ end + it "sets the request_sent flash to true if successful" do + session[:user_id] = @user.id + post :new, :info_request => { :public_body_id => @body.id, + :title => "Why is your quango called Geraldine?", :tag_string => "" }, + :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }, + :submitted_new_request => 1, :preview => 0 + + expect(flash[:request_sent]).to be_true + end + it "should give an error if the same request is submitted twice" do session[:user_id] = @user.id -- cgit v1.2.3 From ebf549a966a9c559bfa76b66f4ab86a75c2c1c92 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 9 Jan 2015 12:02:53 +0000 Subject: Use a partial to render batch sent message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dropped the law_used_full interpolation: So I think there are two significant bits of context here. One is that the law_used_full attribute is derived from law_used, which in turn is set on InfoRequest initialisation based on the tags applied to the public body. So different requests in a batch could have different values for law_used_full - some of them might be to bodies that only accept environmental information requests. So using the value from the batch template is not really a good proxy for the whole collection. The second is that, in any case, the distinction between the two types of request is a UK-specific feature which should be moved to the UK theme (#2085). Given these two factors, I think the cleanest thing might be to drop law_used_full from this descriptive text, and just have it say "Your requests will be sent shortly", without specifying what law will be used. – Louise Crow (@crowbot) --- spec/controllers/request_controller_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index dc28f6dab..aeb27f918 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -2564,10 +2564,9 @@ describe RequestController, "#new_batch" do assigns[:existing_batch].should_not be_nil end - it 'should display a success notice' do + it 'sets the batch_sent flash to true' do make_request - notice_text = "

Your Freedom of Information requests will be sent shortly!" - flash[:notice].should match notice_text + expect(flash[:batch_sent]).to be_true end end -- cgit v1.2.3 From 1488f24e3f03fe46b222fa2fca4ae273d0b46ebf Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 8 Jan 2015 14:09:41 +0000 Subject: =?UTF-8?q?Add=20a=20=E2=80=9CBack=20to=20search=20results?= =?UTF-8?q?=E2=80=9D=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Store the search parameters in the flash when a search is made via the select_authority_path page. Stores the parameters for both POST and AJAX typeahead searches. The presence of stored search params renders the link on the PublicBodyController#show template. “keep”s the search params in PublicBodyController#show so that if the user clicks the browser’s back button the “Back to search results” link can still be rendered on the next search result they click. “keep”s all flash keys in ServicesController#other_country_message as it’s called through AJAX and ends up sweeping the flash. [1] [1] More details about this: http://mikenaberezny.com/2007/09/08/keep-the-flash-and-test-it-too/ --- spec/controllers/request_controller_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec/controllers/request_controller_spec.rb') 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 -- cgit v1.2.3