diff options
Diffstat (limited to 'spec')
33 files changed, 160 insertions, 55 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 diff --git a/spec/fixtures/fake-authority-type.csv b/spec/fixtures/files/fake-authority-type.csv index 4aa618ad1..4aa618ad1 100644 --- a/spec/fixtures/fake-authority-type.csv +++ b/spec/fixtures/files/fake-authority-type.csv diff --git a/spec/fixtures/humberside-police-odd-mime-type.email b/spec/fixtures/files/humberside-police-odd-mime-type.email index 5514b29da..5514b29da 100644 --- a/spec/fixtures/humberside-police-odd-mime-type.email +++ b/spec/fixtures/files/humberside-police-odd-mime-type.email diff --git a/spec/fixtures/incoming-request-attach-attachments.email b/spec/fixtures/files/incoming-request-attach-attachments.email index efcf1a4d1..efcf1a4d1 100644 --- a/spec/fixtures/incoming-request-attach-attachments.email +++ b/spec/fixtures/files/incoming-request-attach-attachments.email diff --git a/spec/fixtures/files/incoming-request-attachment-unknown-extension.email b/spec/fixtures/files/incoming-request-attachment-unknown-extension.email new file mode 100644 index 000000000..b3485ec2d --- /dev/null +++ b/spec/fixtures/files/incoming-request-attachment-unknown-extension.email @@ -0,0 +1,20 @@ +From: EMAIL_FROM +To: FOI Person <EMAIL_TO> +Subject: Same attachment twice +Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" +Content-Disposition: inline + + +--Q68bSM7Ycu6FN28Q +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline + + + +--Q68bSM7Ycu6FN28Q +Content-Type: application/x-nonsense +Content-Disposition: attachment; filename="hello.qwglhm" + +This is an unusual sort of file. + +--Q68bSM7Ycu6FN28Q diff --git a/spec/fixtures/incoming-request-bad-uuencoding.email b/spec/fixtures/files/incoming-request-bad-uuencoding.email index c1288a253..c1288a253 100644 --- a/spec/fixtures/incoming-request-bad-uuencoding.email +++ b/spec/fixtures/files/incoming-request-bad-uuencoding.email diff --git a/spec/fixtures/incoming-request-oft-attachments.email b/spec/fixtures/files/incoming-request-oft-attachments.email index 13ba77680..13ba77680 100644 --- a/spec/fixtures/incoming-request-oft-attachments.email +++ b/spec/fixtures/files/incoming-request-oft-attachments.email diff --git a/spec/fixtures/incoming-request-plain.email b/spec/fixtures/files/incoming-request-plain.email index 8aca7707b..8aca7707b 100644 --- a/spec/fixtures/incoming-request-plain.email +++ b/spec/fixtures/files/incoming-request-plain.email diff --git a/spec/fixtures/incoming-request-tnef-attachments.email b/spec/fixtures/files/incoming-request-tnef-attachments.email index db93c1b8f..db93c1b8f 100644 --- a/spec/fixtures/incoming-request-tnef-attachments.email +++ b/spec/fixtures/files/incoming-request-tnef-attachments.email diff --git a/spec/fixtures/incoming-request-two-same-name.email b/spec/fixtures/files/incoming-request-two-same-name.email index f1024d607..f1024d607 100644 --- a/spec/fixtures/incoming-request-two-same-name.email +++ b/spec/fixtures/files/incoming-request-two-same-name.email diff --git a/spec/fixtures/multiple-unquoted-display-names.email b/spec/fixtures/files/multiple-unquoted-display-names.email index e3a742c83..e3a742c83 100644 --- a/spec/fixtures/multiple-unquoted-display-names.email +++ b/spec/fixtures/files/multiple-unquoted-display-names.email diff --git a/spec/fixtures/parrot.jpg b/spec/fixtures/files/parrot.jpg Binary files differindex 22fd8e4de..22fd8e4de 100644 --- a/spec/fixtures/parrot.jpg +++ b/spec/fixtures/files/parrot.jpg diff --git a/spec/fixtures/parrot.png b/spec/fixtures/files/parrot.png Binary files differindex 77442a3d5..77442a3d5 100644 --- a/spec/fixtures/parrot.png +++ b/spec/fixtures/files/parrot.png diff --git a/spec/fixtures/psni.pdf b/spec/fixtures/files/psni.pdf Binary files differindex daca3f4ec..daca3f4ec 100644 --- a/spec/fixtures/psni.pdf +++ b/spec/fixtures/files/psni.pdf diff --git a/spec/fixtures/tfl.pdf b/spec/fixtures/files/tfl.pdf Binary files differindex 695780a3c..695780a3c 100644 --- a/spec/fixtures/tfl.pdf +++ b/spec/fixtures/files/tfl.pdf diff --git a/spec/lib/external_command_scripts/output.sh b/spec/lib/external_command_scripts/output.sh new file mode 100755 index 000000000..0472c89a3 --- /dev/null +++ b/spec/lib/external_command_scripts/output.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +out_msg=${1:-out} +err_msg=${2:-} +repeats=${3:-10} +exit_status=${4:-0} + +n=0 +while [ "$n" -lt "$repeats" ] +do + if [ -n "$out_msg" ] + then + echo "$out_msg $n" + fi + if [ -n "$err_msg" ] + then + echo >&2 "$err_msg $n" + fi + n=$[$n + 1] +done + +exit "$exit_status" diff --git a/spec/lib/external_command_spec.rb b/spec/lib/external_command_spec.rb new file mode 100644 index 000000000..0ff1a9c0a --- /dev/null +++ b/spec/lib/external_command_spec.rb @@ -0,0 +1,40 @@ +# This is a test of the external_command library + +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') +script_dir = File.join(File.dirname(__FILE__), 'external_command_scripts') +output_script = File.join(script_dir, "output.sh") + +require 'external_command' + +describe "when running ExternalCommand" do + + it "should get correct status code for /bin/true" do + t = ExternalCommand.new("/bin/true").run() + t.status.should == 0 + t.out.should == "" + t.err.should == "" + end + + it "should get correct status code for /bin/false" do + f = ExternalCommand.new("/bin/false").run() + f.status.should == 1 + f.out.should == "" + f.err.should == "" + end + + it "should get stdout and stderr" do + f = ExternalCommand.new(output_script, "out", "err", "10", "23").run() + f.status.should == 23 + f.out.should == (0..9).map {|i| "out #{i}\n"}.join("") + f.err.should == (0..9).map {|i| "err #{i}\n"}.join("") + end + + it "should work with large amounts of data" do + f = ExternalCommand.new(output_script, "a longer output line", "a longer error line", "10000", "5").run() + f.status.should == 5 + f.out.should == (0..9999).map {|i| "a longer output line #{i}\n"}.join("") + f.err.should == (0..9999).map {|i| "a longer error line #{i}\n"}.join("") + end + +end + diff --git a/spec/lib/tmail_extensions_spec.rb b/spec/lib/tmail_extensions_spec.rb index 41e8c8f4e..c647fe522 100644 --- a/spec/lib/tmail_extensions_spec.rb +++ b/spec/lib/tmail_extensions_spec.rb @@ -23,8 +23,7 @@ describe "when using TMail" do end it 'should parse multiple to addresses with unqoted display names' do - example_file = File.join(Spec::Runner.configuration.fixture_path, 'multiple-unquoted-display-names.email') - mail = TMail::Mail.parse(File.read(example_file)) + mail = TMail::Mail.parse(load_file_fixture('multiple-unquoted-display-names.email')) mail.to.should == ["request-66666-caa77777@whatdotheyknow.com", "foi@example.com"] end diff --git a/spec/models/has_tag_string_tag_spec.rb b/spec/models/has_tag_string_tag_spec.rb index 9dfcf3daf..ba439acb8 100644 --- a/spec/models/has_tag_string_tag_spec.rb +++ b/spec/models/has_tag_string_tag_spec.rb @@ -1,7 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HasTagString::HasTagStringTag, " when fiddling with tag strings " do - fixtures :public_bodies + fixtures :public_bodies, :public_body_translations it "should be able to make a new tag and save it" do @tag = HasTagString::HasTagStringTag.new diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 1e2b21964..abbe94a47 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -109,7 +109,7 @@ describe IncomingMessage, " checking validity to reply to" do end describe IncomingMessage, " when censoring data" do - fixtures :incoming_messages, :raw_emails, :public_bodies, :info_requests, :users + fixtures :incoming_messages, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :users before do @test_data = "There was a mouse called Stilton, he wished that he was blue." @@ -199,7 +199,7 @@ describe IncomingMessage, " when censoring data" do end describe IncomingMessage, " when censoring whole users" do - fixtures :incoming_messages, :raw_emails, :public_bodies, :info_requests, :users + fixtures :incoming_messages, :raw_emails, :public_bodies, :public_body_translations, :info_requests, :users before do @test_data = "There was a mouse called Stilton, he wished that he was blue." diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 59868f647..96a4f5bc8 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -40,7 +40,7 @@ describe InfoRequest do describe " when emailing" do - fixtures :info_requests, :info_request_events, :public_bodies, :users + fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :comments before do @info_request = info_requests(:fancy_dog_request) @@ -120,7 +120,7 @@ describe InfoRequest do end describe "when calculating the status" do - fixtures :info_requests, :info_request_events, :holidays, :public_bodies + fixtures :info_requests, :info_request_events, :holidays, :public_bodies, :public_body_translations, :outgoing_messages before do @ir = info_requests(:naughty_chicken_request) @@ -160,7 +160,7 @@ describe InfoRequest do end describe "when calculating the status for a school" do - fixtures :info_requests, :info_request_events, :holidays, :public_bodies + fixtures :info_requests, :info_request_events, :holidays, :public_bodies, :public_body_translations before do @ir = info_requests(:naughty_chicken_request) diff --git a/spec/models/outgoing_mailer_spec.rb b/spec/models/outgoing_mailer_spec.rb index 71a46f8f8..3073c5ffd 100644 --- a/spec/models/outgoing_mailer_spec.rb +++ b/spec/models/outgoing_mailer_spec.rb @@ -4,7 +4,7 @@ describe OutgoingMailer, " when working out follow up addresses" do # This is done with fixtures as the code is a bit tangled with the way it # calls TMail. XXX untangle it and make these tests spread out and using # mocks. Put parts of the tests in spec/lib/tmail_extensions.rb - fixtures :info_requests, :incoming_messages, :raw_emails, :public_bodies + fixtures :info_requests, :incoming_messages, :raw_emails, :public_bodies, :public_body_translations it "should parse them right" do ir = info_requests(:fancy_dog_request) diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index f00138ab3..5bbf03d27 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -95,7 +95,7 @@ describe PublicBody, " using machine tags" do end describe PublicBody, "when finding_by_tags" do - fixtures :public_bodies + fixtures :public_bodies, :public_body_translations before do @geraldine = public_bodies(:geraldine_public_body) @@ -133,7 +133,7 @@ end describe PublicBody, " when saving" do before do - @public_body = PublicBody.new + @public_body = PublicBody.new end it "should not be valid without setting some parameters" do @@ -158,10 +158,22 @@ describe PublicBody, " when saving" do @public_body.last_edit_comment = "This is a test" @public_body.save! end + + it "should update first_letter" do + @public_body.name = "Testing Public Body" + @public_body.short_name = "TPB" + @public_body.request_email = "request@localhost" + @public_body.last_edit_editor = "*test*" + @public_body.last_edit_comment = "This is a test" + + @public_body.first_letter.should be_nil + @public_body.save! + @public_body.first_letter.should == 'T' + end end describe PublicBody, "when searching" do - fixtures :public_bodies, :public_body_versions + fixtures :public_bodies, :public_body_translations, :public_body_versions it "should find by existing url name" do body = PublicBody.find_by_url_name_with_historic('dfh') diff --git a/spec/models/raw_email_spec.rb b/spec/models/raw_email_spec.rb index 75066bbcc..6f3a8acd6 100644 --- a/spec/models/raw_email_spec.rb +++ b/spec/models/raw_email_spec.rb @@ -23,8 +23,8 @@ describe User, "manipulating a raw email" do # @raw_email.data = "This \\ that" # @raw_email.save! # @raw_email.reload -# STDERR.puts @raw_email.data -# STDERR.puts "This \\ that" +# $stderr.puts @raw_email.data +# $stderr.puts "This \\ that" # @raw_email.data.should == "This \\ that" # end diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index b9e845c1d..a8311e8f8 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -1,7 +1,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe RequestMailer, " when receiving incoming mail" do - fixtures :info_requests, :incoming_messages, :raw_emails, :users, :public_bodies + fixtures :info_requests, :incoming_messages, :raw_emails, :users, :public_bodies, :public_body_translations it "should append it to the appropriate request" do ir = info_requests(:fancy_dog_request) diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb index 4649c4def..828904d02 100644 --- a/spec/models/track_mailer_spec.rb +++ b/spec/models/track_mailer_spec.rb @@ -129,9 +129,9 @@ describe TrackMailer do deliveries = ActionMailer::Base.deliveries if deliveries.size > 1 # debugging if there is an error deliveries.each do |d| - STDERR.puts "------------------------------" - STDERR.puts d.body - STDERR.puts "------------------------------" + $stderr.puts "------------------------------" + $stderr.puts d.body + $stderr.puts "------------------------------" end end deliveries.size.should == 1 diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index 00a88be99..79ffc4839 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -34,7 +34,7 @@ describe User, " when indexing users with Xapian" do end describe PublicBody, " when indexing public bodies with Xapian" do - fixtures :public_bodies, :incoming_messages, :outgoing_messages, :raw_emails, :comments + fixtures :public_bodies, :public_body_translations, :incoming_messages, :outgoing_messages, :raw_emails, :comments it "should search index the main name field" do rebuild_xapian_index @@ -69,7 +69,7 @@ describe PublicBody, " when indexing public bodies with Xapian" do end describe PublicBody, " when indexing requests by body they are to" do - fixtures :public_bodies, :info_request_events, :info_requests, :raw_emails, :comments + fixtures :public_bodies, :public_body_translations, :info_request_events, :info_requests, :raw_emails, :comments it "should find requests to the body" do rebuild_xapian_index @@ -290,7 +290,7 @@ describe InfoRequest, " when indexing requests by tag" do end describe PublicBody, " when indexing authorities by tag" do - fixtures :public_bodies, :incoming_messages, :outgoing_messages, :raw_emails, :comments + fixtures :public_bodies, :public_body_translations, :incoming_messages, :outgoing_messages, :raw_emails, :comments it "should find request by tag, even when changes" do rebuild_xapian_index diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f0f50d61e..87a89f755 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -53,7 +53,7 @@ end # XXX No idea what namespace/class/module to put this in def receive_incoming_mail(email_name, email_to, email_from = 'geraldinequango@localhost') - email_name = File.join(Spec::Runner.configuration.fixture_path, email_name) + email_name = file_fixture_name(email_name) content = File.read(email_name) content.gsub!('EMAIL_TO', email_to) content.gsub!('EMAIL_FROM', email_from) @@ -61,7 +61,7 @@ def receive_incoming_mail(email_name, email_to, email_from = 'geraldinequango@lo end def file_fixture_name(file_name) - return File.join(Spec::Runner.configuration.fixture_path, file_name) + return File.join(Spec::Runner.configuration.fixture_path, "files", file_name) end def load_file_fixture(file_name) |