diff options
Diffstat (limited to 'spec/integration')
-rw-r--r-- | spec/integration/admin_public_body_edit_spec.rb | 2 | ||||
-rw-r--r-- | spec/integration/alaveteli_dsl.rb | 9 | ||||
-rw-r--r-- | spec/integration/search_request_spec.rb | 28 | ||||
-rw-r--r-- | spec/integration/xapian_search_highlighting_spec.rb | 4 |
4 files changed, 34 insertions, 9 deletions
diff --git a/spec/integration/admin_public_body_edit_spec.rb b/spec/integration/admin_public_body_edit_spec.rb index aeec3e65a..21011b172 100644 --- a/spec/integration/admin_public_body_edit_spec.rb +++ b/spec/integration/admin_public_body_edit_spec.rb @@ -39,7 +39,7 @@ describe 'Editing a Public Body' do end end - it 'can add a translation for multiple locales', :focus => true do + it 'can add a translation for multiple locales' do @admin.visit edit_admin_body_path(@body) @admin.fill_in 'public_body_name__en', :with => 'New Quango EN' @admin.click_button 'Save' diff --git a/spec/integration/alaveteli_dsl.rb b/spec/integration/alaveteli_dsl.rb index 370628d98..d7485a094 100644 --- a/spec/integration/alaveteli_dsl.rb +++ b/spec/integration/alaveteli_dsl.rb @@ -74,5 +74,14 @@ def cache_directories_exist?(request) paths.any?{ |path| File.exist?(path) } end +def with_forgery_protection + orig = ActionController::Base.allow_forgery_protection + begin + ActionController::Base.allow_forgery_protection = true + yield if block_given? + ensure + ActionController::Base.allow_forgery_protection = orig + end +end 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") diff --git a/spec/integration/xapian_search_highlighting_spec.rb b/spec/integration/xapian_search_highlighting_spec.rb index 65a34cf91..b2994eb31 100644 --- a/spec/integration/xapian_search_highlighting_spec.rb +++ b/spec/integration/xapian_search_highlighting_spec.rb @@ -3,6 +3,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe 'highlighting search results' do include HighlightHelper + before do + get_fixtures_xapian_index + end + it 'ignores stopwords' do phrase = 'department of humpadinking' search = ActsAsXapian::Search.new([PublicBody], phrase, :limit => 1) |