aboutsummaryrefslogtreecommitdiffstats
path: root/spec/integration
diff options
context:
space:
mode:
Diffstat (limited to 'spec/integration')
-rw-r--r--spec/integration/errors_spec.rb29
-rw-r--r--spec/integration/search_request_spec.rb49
-rw-r--r--spec/integration/view_request_spec.rb17
3 files changed, 39 insertions, 56 deletions
diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb
index bfb7e5fb5..ec2e1c376 100644
--- a/spec/integration/errors_spec.rb
+++ b/spec/integration/errors_spec.rb
@@ -2,22 +2,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "When rendering errors" do
- fixtures [
- :users,
- :public_bodies,
- :public_body_translations,
- :public_body_versions,
- :info_requests,
- :raw_emails,
- :outgoing_messages,
- :incoming_messages,
- :comments,
- :info_request_events,
- :track_things,
- ]
-
before(:each) do
- load_raw_emails_data(raw_emails)
+ load_raw_emails_data
ActionController::Base.consider_all_requests_local = false
end
@@ -45,5 +31,18 @@ describe "When rendering errors" do
get("/request/#{ir.url_title}")
response.code.should == "500"
end
+ it "should render a 403 for attempts at directory listing for attachments" do
+ # make a fake cache
+ foi_cache_path = File.join(File.dirname(__FILE__), '../../cache')
+ FileUtils.mkdir_p(File.join(foi_cache_path, "views/en/request/101/101/response/1/attach/html/1"))
+ get("/request/101/response/1/attach/html/1/" )
+ response.code.should == "403"
+ get("/request/101/response/1/attach/html" )
+ response.code.should == "403"
+ end
+ it "should render a 404 for non-existent 'details' pages for requests" do
+ get("/details/request/wobble" )
+ response.code.should == "404"
+ end
end
diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb
index 07839af32..b62f0a4c4 100644
--- a/spec/integration/search_request_spec.rb
+++ b/spec/integration/search_request_spec.rb
@@ -2,23 +2,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "When searching" do
- fixtures [
- :users,
- :public_bodies,
- :public_body_translations,
- :public_body_versions,
- :info_requests,
- :raw_emails,
- :outgoing_messages,
- :incoming_messages,
- :comments,
- :info_request_events,
- :track_things,
- ]
-
before(:each) do
- emails = raw_emails.clone
- load_raw_emails_data(emails)
+ load_raw_emails_data
+ rebuild_xapian_index
end
it "should not strip quotes from quoted query" do
@@ -34,33 +20,46 @@ describe "When searching" do
end
it "should correctly filter searches for requests" do
- request_via_redirect("post", "/search/bob/requests")
+ request_via_redirect("post", "/search/bob/requests")
response.body.should_not include("One person found")
- response.body.should include("FOI requests 1 to 2 of 2")
+ n = 4 # The number of requests that contain the word "bob" somewhere
+ # in the email text. At present this is:
+ # - fancy_dog_request
+ # - naughty_chicken_request
+ # - boring_request
+ # - another_boring_request
+ #
+ # In other words it is all requests made by Bob Smith
+ # except for badger_request, which he did not sign.
+ 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("post", "/search/bob/users")
response.body.should include("One person found")
- response.body.should_not include("FOI requests 1 to 2 of 2")
+ response.body.should_not include("FOI requests 1 to")
end
it "should correctly filter searches for successful requests" do
- request_via_redirect("post", "/search",
+ request_via_redirect("post", "/search/requests",
:query => "bob",
:latest_status => ['successful'])
- response.body.should include("no requests matching your query")
+ n = 2 # The number of *successful* requests that contain the word "bob" somewhere
+ # in the email text. At present this is:
+ # - boring_request
+ # - another_boring_request
+ response.body.should include("FOI requests 1 to #{n} of #{n}")
end
it "should correctly filter searches for comments" do
- request_via_redirect("post", "/search",
+ request_via_redirect("post", "/search/requests",
:query => "daftest",
:request_variety => ['comments'])
response.body.should include("One FOI request found")
- request_via_redirect("post", "/search",
+ request_via_redirect("post", "/search/requests",
:query => "daftest",
:request_variety => ['response','sent'])
- response.body.should include("no requests matching your query")
+ response.body.should include("no results matching your query")
end
end
diff --git a/spec/integration/view_request_spec.rb b/spec/integration/view_request_spec.rb
index cf1e4ca6c..442721890 100644
--- a/spec/integration/view_request_spec.rb
+++ b/spec/integration/view_request_spec.rb
@@ -2,23 +2,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "When viewing requests" do
- fixtures [
- :users,
- :public_bodies,
- :public_body_translations,
- :public_body_versions,
- :info_requests,
- :raw_emails,
- :outgoing_messages,
- :incoming_messages,
- :comments,
- :info_request_events,
- :track_things,
- ]
-
before(:each) do
- emails = raw_emails.clone
- load_raw_emails_data(emails)
+ load_raw_emails_data
end
it "should not make endlessly recursive JSON <link>s" do