aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/comment_controller_spec.rb2
-rw-r--r--spec/controllers/general_controller_spec.rb1
-rw-r--r--spec/controllers/public_body_controller_spec.rb13
-rw-r--r--spec/controllers/request_controller_spec.rb53
-rw-r--r--spec/controllers/track_controller_spec.rb2
-rw-r--r--spec/controllers/user_controller_spec.rb5
6 files changed, 44 insertions, 32 deletions
diff --git a/spec/controllers/comment_controller_spec.rb b/spec/controllers/comment_controller_spec.rb
index dfa5be73c..2b0f5eee2 100644
--- a/spec/controllers/comment_controller_spec.rb
+++ b/spec/controllers/comment_controller_spec.rb
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe CommentController, "when commenting on a request" do
integrate_views
- fixtures :info_requests, :outgoing_messages, :public_bodies, :users, :comments
+ fixtures :info_requests, :outgoing_messages, :public_bodies, :public_body_translations, :users, :comments
it "should give an error and render 'new' template when body text is just some whitespace" do
post :new, :url_title => info_requests(:naughty_chicken_request).url_title,
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index 9c9ab46f6..6a48f142a 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -5,6 +5,7 @@ describe GeneralController, "when searching" do
fixtures [ :info_requests,
:info_request_events,
:public_bodies,
+ :public_body_translations,
:users,
:raw_emails,
:outgoing_messages,
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index cef720069..8b84b89ec 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -4,7 +4,7 @@ require 'json'
describe PublicBodyController, "when showing a body" do
integrate_views
- fixtures :public_bodies, :public_body_versions, :public_body_translations
+ fixtures :public_bodies, :public_body_translations, :public_body_versions
it "should be successful" do
get :show, :url_name => "dfh"
@@ -31,6 +31,13 @@ describe PublicBodyController, "when showing a body" do
assigns[:public_body].notes.should == "Baguette"
end
+ it "should assign the body using same locale as that used in url_name even with wrongly set locale" do
+ PublicBody.with_locale(:en) do
+ get :show, {:url_name => "edfh", :locale => 'es'}
+ response.body.should include('Baguette')
+ end
+ end
+
it "should redirect to newest name if you use historic name of public body in URL" do
get :show, :url_name => "hdink"
response.should redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh")
@@ -44,7 +51,7 @@ end
describe PublicBodyController, "when listing bodies" do
integrate_views
- fixtures :public_bodies, :public_body_versions, :public_body_translations
+ fixtures :public_bodies, :public_body_translations, :public_body_versions
it "should be successful" do
get :list
@@ -114,7 +121,7 @@ end
describe PublicBodyController, "when showing JSON version for API" do
- fixtures :public_bodies
+ fixtures :public_bodies, :public_body_translations
it "should be successful" do
get :show, :url_name => "dfh", :format => "json"
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index b4b989c9f..ac44cb905 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -38,7 +38,7 @@ end
describe RequestController, "when showing one request" do
- fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
it "should be successful" do
get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
@@ -114,10 +114,19 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt']
response.content_type.should == "text/plain"
- response.should have_text(/Second hello/)
+ response.should have_text(/Second hello/)
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 3, :file_name => ['hello.txt']
response.content_type.should == "text/plain"
- response.should have_text(/First hello/)
+ response.should have_text(/First hello/)
+ end
+
+ it "should treat attachments with unknown extensions as binary" do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('incoming-request-attachment-unknown-extension.email', ir.incoming_email)
+
+ get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.qwglhm']
+ response.content_type.should == "application/octet-stream"
+ response.should have_text(/an unusual sort of file/)
end
it "should not download attachments with wrong file name" do
@@ -144,7 +153,7 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt']
response.content_type.should == "text/plain"
- response.should have_text(/xxxxxx hello/)
+ response.should have_text(/xxxxxx hello/)
end
it "should censor with rules on the user (rather than the request)" do
@@ -161,7 +170,7 @@ describe RequestController, "when showing one request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['hello.txt']
response.content_type.should == "text/plain"
- response.should have_text(/xxxxxx hello/)
+ response.should have_text(/xxxxxx hello/)
end
it "should censor attachment names" do
@@ -187,7 +196,7 @@ describe RequestController, "when showing one request" do
end
describe RequestController, "when changing prominence of a request" do
- fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
it "should not show hidden requests" do
ir = info_requests(:fancy_dog_request)
@@ -254,11 +263,11 @@ describe RequestController, "when changing prominence of a request" do
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2
response.content_type.should == "text/html"
- response.should_not have_text(/Second hello/)
+ response.should_not have_text(/Second hello/)
response.should render_template('request/hidden')
get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 3
response.content_type.should == "text/html"
- response.should_not have_text(/First hello/)
+ response.should_not have_text(/First hello/)
response.should render_template('request/hidden')
end
@@ -272,7 +281,7 @@ end
describe RequestController, "when creating a new request" do
integrate_views
- fixtures :info_requests, :outgoing_messages, :public_bodies, :users
+ fixtures :info_requests, :outgoing_messages, :public_bodies, :public_body_translations, :users
before do
@user = users(:bob_smith_user)
@@ -352,7 +361,6 @@ describe RequestController, "when creating a new request" do
deliveries.size.should == 1
mail = deliveries[0]
mail.body.should =~ /This is a silly letter. It is too short to be interesting./
- #STDERR.puts "=====" + mail.body + "======"
response.should redirect_to(:action => 'show', :url_title => ir.url_title)
end
@@ -459,7 +467,7 @@ end
describe RequestController, "when viewing an individual response for reply/followup" do
integrate_views
- fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
it "should ask for login if you are logged in as wrong person" do
session[:user_id] = users(:silly_name_user).id
@@ -486,7 +494,7 @@ end
describe RequestController, "when classifying an information request" do
- fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
before do
@dog_request = info_requests(:fancy_dog_request)
@@ -804,7 +812,7 @@ end
describe RequestController, "when sending a followup message" do
integrate_views
- fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
it "should require login" do
post :show_response, :outgoing_message => { :body => "What a useless response! You suck.", :what_doing => 'normal_sort' }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_followup => 1
@@ -854,7 +862,6 @@ describe RequestController, "when sending a followup message" do
mail = deliveries[0]
mail.body.should =~ /What a useless response! You suck./
mail.to_addrs.to_s.should == "FOI Person <foiperson@localhost>"
- #STDERR.puts "=====" + mail.body + "======"
response.should redirect_to(:action => 'show', :url_title => info_requests(:fancy_dog_request).url_title)
@@ -884,7 +891,7 @@ end
describe RequestController, "sending overdue request alerts" do
integrate_views
- fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
it "should send an overdue alert mail to creators of overdue requests" do
chicken_request = info_requests(:naughty_chicken_request)
@@ -968,7 +975,7 @@ end
describe RequestController, "sending unclassified new response reminder alerts" do
integrate_views
- fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
it "should send an alert" do
RequestMailer.alert_new_response_reminders
@@ -995,7 +1002,7 @@ end
describe RequestController, "clarification required alerts" do
integrate_views
- fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
it "should send an alert" do
ir = info_requests(:fancy_dog_request)
@@ -1046,7 +1053,7 @@ end
describe RequestController, "comment alerts" do
integrate_views
- fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments # all needed as integrating views
it "should send an alert (once and once only)" do
# delete ficture comment and make new one, so is in last month (as
@@ -1069,7 +1076,6 @@ describe RequestController, "comment alerts" do
# XXX check mail_url here somehow, can't call comment_url like this:
# mail_url.should == comment_url(comments(:silly_comment))
- #STDERR.puts mail.body
# check if we send again, no more go out
deliveries.clear
@@ -1113,7 +1119,6 @@ describe RequestController, "comment alerts" do
# XXX check mail_url here somehow, can't call comment_url like this:
# mail_url.should == comment_url(comments(:silly_comment))
- #STDERR.puts mail.body
end
end
@@ -1140,7 +1145,7 @@ end
describe RequestController, "authority uploads a response from the web interface" do
- fixtures :info_requests, :info_request_events, :public_bodies, :users
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users
before(:all) do
# domain after the @ is used for authentication of FOI officers, so to test it
@@ -1178,7 +1183,7 @@ describe RequestController, "authority uploads a response from the web interface
session[:user_id] = @normal_user.id
# post up a photo of the parrot
- parrot_upload = fixture_file_upload('parrot.png','image/png')
+ parrot_upload = fixture_file_upload('files/parrot.png','image/png')
post :upload_response, :url_title => 'why_do_you_have_such_a_fancy_dog',
:body => "Find attached a picture of a parrot",
:file_1 => parrot_upload,
@@ -1202,7 +1207,7 @@ describe RequestController, "authority uploads a response from the web interface
session[:user_id] = @foi_officer_user.id
# post up a photo of the parrot
- parrot_upload = fixture_file_upload('parrot.png','image/png')
+ parrot_upload = fixture_file_upload('files/parrot.png','image/png')
post :upload_response, :url_title => 'why_do_you_have_such_a_fancy_dog',
:body => "Find attached a picture of a parrot",
:file_1 => parrot_upload,
@@ -1227,7 +1232,7 @@ end
describe RequestController, "when showing JSON version for API" do
- fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments
+ fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments
it "should return data in JSON form" do
get :show, :url_title => 'why_do_you_have_such_a_fancy_dog', :format => 'json'
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 9fe3ebd42..8076d40c2 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -119,7 +119,7 @@ end
describe TrackController, "when viewing JSON version of a track feed" do
integrate_views
- fixtures :info_requests, :outgoing_messages, :incoming_messages, :raw_emails, :info_request_events, :users, :track_things, :comments, :public_bodies
+ fixtures :info_requests, :outgoing_messages, :incoming_messages, :raw_emails, :info_request_events, :users, :track_things, :comments, :public_bodies, :public_body_translations
before do
rebuild_xapian_index
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 81da94e67..93ea6de48 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -7,7 +7,7 @@ require 'json'
describe UserController, "when showing a user" do
integrate_views
- fixtures :users, :outgoing_messages, :incoming_messages, :raw_emails, :info_requests, :info_request_events, :comments, :public_bodies
+ fixtures :users, :outgoing_messages, :incoming_messages, :raw_emails, :info_requests, :info_request_events, :comments, :public_bodies, :public_body_translations
it "should be successful" do
get :show, :url_name => "bob_smith"
@@ -419,8 +419,7 @@ describe UserController, "when changing email address" do
"action"=>"signchangeemail",
"signchangeemail"=>{
"old_email"=>"bob@localhost",
- "new_email"=>"newbob@localhost",
- "password"=>"jonespassword"},
+ "new_email"=>"newbob@localhost"},
"controller"=>"user",
"locale"=>"en"}
post :signchangeemail, post_redirect.post_params