diff options
Diffstat (limited to 'spec/integration/search_request_spec.rb')
-rw-r--r-- | spec/integration/search_request_spec.rb | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb index 23a62e97b..699eb2c6c 100644 --- a/spec/integration/search_request_spec.rb +++ b/spec/integration/search_request_spec.rb @@ -1,4 +1,5 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +require File.expand_path(File.dirname(__FILE__) + '/alaveteli_dsl') describe "When searching" do @@ -8,24 +9,35 @@ describe "When searching" do end it "should not strip quotes from quoted query" do - request_via_redirect("post", "/search", :query => '"mouse stilton"') + request_via_redirect("get", "/search", :query => '"mouse stilton"') response.body.should include(""mouse stilton"") end it "should redirect requests with search in query string to URL-based page" do - post '/search/all?query=bob' + get '/search/all?query=bob' response.should redirect_to "/en/search/bob/all" end it "should correctly execute simple search" do - request_via_redirect("post", "/search", + request_via_redirect("get", "/search", :query => 'bob' ) response.body.should include("FOI requests") end + it "should not log a logged-in user out" do + with_forgery_protection do + user = FactoryGirl.create(:user) + user_session = login(user) + user_session.visit frontpage_path + user_session.fill_in "query", :with => 'test' + user_session.click_button "Search" + user_session.response.body.should include(user.name) + end + end + it "should correctly filter searches for requests" do - request_via_redirect("post", "/search/bob/requests") + request_via_redirect("get", "/search/bob/requests") response.body.should_not include("One person found") n = 4 # The number of requests that contain the word "bob" somewhere # in the email text. At present this is: @@ -39,13 +51,13 @@ describe "When searching" do response.body.should include("FOI requests 1 to #{n} of #{n}") end it "should correctly filter searches for users" do - request_via_redirect("post", "/search/bob/users") + request_via_redirect("get", "/search/bob/users") response.body.should include("One person found") response.body.should_not include("FOI requests 1 to") end it "should correctly filter searches for successful requests" do - request_via_redirect("post", "/search/requests", + request_via_redirect("get", "/search/requests", :query => "bob", :latest_status => ['successful']) n = 2 # The number of *successful* requests that contain the word "bob" somewhere @@ -56,12 +68,12 @@ describe "When searching" do end it "should correctly filter searches for comments" do - request_via_redirect("post", "/search/requests", + request_via_redirect("get", "/search/requests", :query => "daftest", :request_variety => ['comments']) response.body.should include("One FOI request found") - request_via_redirect("post", "/search/requests", + request_via_redirect("get", "/search/requests", :query => "daftest", :request_variety => ['response','sent']) response.body.should include("no results matching your query") |