diff options
Diffstat (limited to 'spec/controllers/request_controller_spec.rb')
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 494713a4a..3420d212e 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1,9 +1,10 @@ +# -*- coding: utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'json' describe RequestController, "when listing recent requests" do - fixtures :info_requests, :outgoing_messages, :users, :info_request_events, :public_bodies, :public_body_translations, :incoming_messages, :raw_emails, :comments + fixtures :users, :public_bodies, :public_body_translations, :public_body_versions, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:each) do load_raw_emails_data(raw_emails) @@ -51,7 +52,7 @@ end describe RequestController, "when showing one request" do - 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 + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data(raw_emails) @@ -137,6 +138,13 @@ describe RequestController, "when showing one request" do response.should have_text(/First hello/) end + it "should convert message body to UTF8" do + ir = info_requests(:fancy_dog_request) + receive_incoming_mail('iso8859_2_raw_email.email', ir.incoming_email) + get :show, :url_title => 'why_do_you_have_such_a_fancy_dog' + response.should have_text(/tënde/u) + end + it "should generate valid HTML verson of plain text attachments " do ir = info_requests(:fancy_dog_request) receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email) @@ -232,17 +240,16 @@ describe RequestController, "when showing one request" do get :download_entire_request, :url_title => title assigns[:url_path].should have_text(/#{title}.zip$/) response.location.should have_text(/#{assigns[:url_path]}/) - assigns[:url_path].should_not == old_path zipfile = Zip::ZipFile.open(File.join(File.dirname(__FILE__), "../../cache/zips", assigns[:url_path])) { |zipfile| zipfile.count.should == 4 -zipfile.entries.each {|x| puts x.name} } + assigns[:url_path].should_not == old_path end end end describe RequestController, "when changing prominence of a request" do - fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data(raw_emails) @@ -358,7 +365,7 @@ end describe RequestController, "when creating a new request" do integrate_views - fixtures :info_requests, :outgoing_messages, :public_bodies, :public_body_translations, :users + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before do @user = users(:bob_smith_user) @@ -542,7 +549,7 @@ end describe RequestController, "when viewing an individual response for reply/followup" do integrate_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 + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data(raw_emails) @@ -589,7 +596,7 @@ end describe RequestController, "when classifying an information 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 :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do @dog_request = info_requests(:fancy_dog_request) @@ -800,7 +807,7 @@ describe RequestController, "when classifying an information request" do deliveries.size.should == 1 mail = deliveries[0] mail.body.should =~ /as needing admin/ - mail.from_addrs.to_s.should == @request_owner.name_and_email + mail.from_addrs.first.to_s.should == @request_owner.name_and_email end it 'should say it is showing advice as to what to do next' do @@ -925,7 +932,7 @@ end describe RequestController, "when sending a followup message" do integrate_views - fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data(raw_emails) @@ -978,7 +985,7 @@ describe RequestController, "when sending a followup message" do deliveries.size.should == 1 mail = deliveries[0] mail.body.should =~ /What a useless response! You suck./ - mail.to_addrs.to_s.should == "FOI Person <foiperson@localhost>" + mail.to_addrs.first.to_s.should == "FOI Person <foiperson@localhost>" response.should redirect_to(:action => 'show', :url_title => info_requests(:fancy_dog_request).url_title) @@ -1008,7 +1015,7 @@ end describe RequestController, "sending overdue request alerts" do integrate_views - fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data(raw_emails) @@ -1025,7 +1032,7 @@ describe RequestController, "sending overdue request alerts" do deliveries.size.should == 1 mail = deliveries[0] mail.body.should =~ /promptly, as normally/ - mail.to_addrs.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email + mail.to_addrs.first.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email mail.body =~ /(http:\/\/.*\/c\/(.*))/ mail_url = $1 @@ -1053,7 +1060,7 @@ describe RequestController, "sending overdue request alerts" do deliveries.size.should == 1 mail = deliveries[0] mail.body.should =~ /promptly, as normally/ - mail.to_addrs.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email + mail.to_addrs.first.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email end it "should send not actually send the overdue alert if the user is banned" do @@ -1078,7 +1085,7 @@ describe RequestController, "sending overdue request alerts" do deliveries.size.should == 1 mail = deliveries[0] mail.body.should =~ /required by law/ - mail.to_addrs.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email + mail.to_addrs.first.to_s.should == info_requests(:naughty_chicken_request).user.name_and_email mail.body =~ /(http:\/\/.*\/c\/(.*))/ mail_url = $1 @@ -1096,7 +1103,7 @@ end describe RequestController, "sending unclassified new response reminder alerts" do integrate_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 + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data(raw_emails) @@ -1109,7 +1116,7 @@ describe RequestController, "sending unclassified new response reminder alerts" deliveries.size.should == 3 # sufficiently late it sends reminders too mail = deliveries[0] mail.body.should =~ /To let us know/ - mail.to_addrs.to_s.should == info_requests(:fancy_dog_request).user.name_and_email + mail.to_addrs.first.to_s.should == info_requests(:fancy_dog_request).user.name_and_email mail.body =~ /(http:\/\/.*\/c\/(.*))/ mail_url = $1 mail_token = $2 @@ -1127,7 +1134,7 @@ end describe RequestController, "clarification required alerts" do integrate_views - fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data(raw_emails) end @@ -1146,7 +1153,7 @@ describe RequestController, "clarification required alerts" do deliveries.size.should == 1 mail = deliveries[0] mail.body.should =~ /asked you to explain/ - mail.to_addrs.to_s.should == info_requests(:fancy_dog_request).user.name_and_email + mail.to_addrs.first.to_s.should == info_requests(:fancy_dog_request).user.name_and_email mail.body =~ /(http:\/\/.*\/c\/(.*))/ mail_url = $1 mail_token = $2 @@ -1181,7 +1188,7 @@ end describe RequestController, "comment alerts" do integrate_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 + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things # all needed as integrating views before(:each) do load_raw_emails_data(raw_emails) end @@ -1200,7 +1207,7 @@ describe RequestController, "comment alerts" do deliveries = ActionMailer::Base.deliveries mail = deliveries[0] mail.body.should =~ /has annotated your/ - mail.to_addrs.to_s.should == info_requests(:fancy_dog_request).user.name_and_email + mail.to_addrs.first.to_s.should == info_requests(:fancy_dog_request).user.name_and_email mail.body =~ /(http:\/\/.*)/ mail_url = $1 @@ -1243,7 +1250,7 @@ describe RequestController, "comment alerts" do deliveries.size.should == 1 mail = deliveries[0] mail.body.should =~ /There are 2 new annotations/ - mail.to_addrs.to_s.should == info_requests(:fancy_dog_request).user.name_and_email + mail.to_addrs.first.to_s.should == info_requests(:fancy_dog_request).user.name_and_email mail.body =~ /(http:\/\/.*)/ mail_url = $1 @@ -1256,7 +1263,7 @@ end describe RequestController, "when viewing comments" do integrate_views - fixtures :users, :raw_emails, :incoming_messages, :info_requests + fixtures :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:each) do load_raw_emails_data(raw_emails) end @@ -1279,7 +1286,7 @@ end describe RequestController, "authority uploads a response from the web interface" do - fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:all) do # domain after the @ is used for authentication of FOI officers, so to test it @@ -1366,7 +1373,7 @@ end describe RequestController, "when showing JSON version for API" do - fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things before(:each) do load_raw_emails_data(raw_emails) @@ -1386,7 +1393,7 @@ describe RequestController, "when showing JSON version for API" do end describe RequestController, "when doing type ahead searches" do - fixtures :info_requests, :info_request_events, :public_bodies, :public_body_translations, :users, :incoming_messages, :raw_emails, :outgoing_messages, :comments + fixtures :public_bodies, :public_body_translations, :public_body_versions, :users, :info_requests, :raw_emails, :incoming_messages, :outgoing_messages, :comments, :info_request_events, :track_things it "should return nothing for the empty query string" do get :search_typeahead, :q => "" |