aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/request_controller_spec.rb63
-rw-r--r--spec/fixtures/files/forward-quoting-example-2.email318
-rw-r--r--spec/fixtures/files/forward-quoting-example.email73
-rw-r--r--spec/fixtures/public_body_translations.yml7
-rw-r--r--spec/lib/timezone_fixes_spec.rb68
-rw-r--r--spec/models/incoming_message_spec.rb17
-rw-r--r--spec/models/track_thing_spec.rb9
-rw-r--r--spec/views/public_body/show.rhtml_spec.rb1
8 files changed, 530 insertions, 26 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 77f43b618..b0223588e 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -245,7 +245,7 @@ describe RequestController, "when showing one request" do
response.should have_tag('#anyone_actions', /Add an annotation/)
end
end
-
+
describe 'when the request does not allow comments' do
it 'should not have a comment link' do
get :show, { :url_title => 'spam_1' },
@@ -253,7 +253,7 @@ describe RequestController, "when showing one request" do
response.should_not have_tag('#anyone_actions', /Add an annotation/)
end
end
-
+
describe 'when the request is being viewed by an admin' do
describe 'if the request is awaiting description' do
@@ -1709,15 +1709,17 @@ describe RequestController, "sending overdue request alerts" do
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
+ it "should send not actually send the overdue alert if the user is banned but should
+ record it as sent" do
user = info_requests(:naughty_chicken_request).user
user.ban_text = 'Banned'
user.save!
-
+ UserInfoRequestSentAlert.find_all_by_user_id(user.id).count.should == 0
RequestMailer.alert_overdue_requests
deliveries = ActionMailer::Base.deliveries
deliveries.size.should == 0
+ UserInfoRequestSentAlert.find_all_by_user_id(user.id).count.should > 0
end
it "should send a very overdue alert mail to creators of very overdue requests" do
@@ -1746,6 +1748,59 @@ describe RequestController, "sending overdue request alerts" do
assigns[:info_request].should == info_requests(:naughty_chicken_request)
end
+ it "should not resend alerts to people who've already received them" do
+ chicken_request = info_requests(:naughty_chicken_request)
+ chicken_request.outgoing_messages[0].last_sent_at = Time.now() - 60.days
+ chicken_request.outgoing_messages[0].save!
+ RequestMailer.alert_overdue_requests
+ chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/}
+ chicken_mails.size.should == 1
+ RequestMailer.alert_overdue_requests
+ chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/}
+ chicken_mails.size.should == 1
+ end
+
+ it 'should send alerts for requests where the last event forming the initial request is a followup
+ being sent following a request for clarification' do
+ chicken_request = info_requests(:naughty_chicken_request)
+ chicken_request.outgoing_messages[0].last_sent_at = Time.now() - 60.days
+ chicken_request.outgoing_messages[0].save!
+ RequestMailer.alert_overdue_requests
+ chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/}
+ chicken_mails.size.should == 1
+
+ # Request is waiting clarification
+ chicken_request.set_described_state('waiting_clarification')
+
+ # Followup message is sent
+ outgoing_message = OutgoingMessage.new(:status => 'ready',
+ :message_type => 'followup',
+ :info_request_id => chicken_request.id,
+ :body => 'Some text',
+ :what_doing => 'normal_sort')
+ outgoing_message.send_message
+ outgoing_message.save!
+
+ chicken_request = InfoRequest.find(chicken_request.id)
+
+ # Last event forming the request is now the followup
+ chicken_request.last_event_forming_initial_request.event_type.should == 'followup_sent'
+
+ # This isn't overdue, so no email
+ RequestMailer.alert_overdue_requests
+ chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/}
+ chicken_mails.size.should == 1
+
+ # Make the followup older
+ outgoing_message.last_sent_at = Time.now() - 60.days
+ outgoing_message.save!
+
+ # Now it should be alerted on
+ RequestMailer.alert_overdue_requests
+ chicken_mails = ActionMailer::Base.deliveries.select{|x| x.body =~ /chickens/}
+ chicken_mails.size.should == 2
+ end
+
end
describe RequestController, "sending unclassified new response reminder alerts" do
diff --git a/spec/fixtures/files/forward-quoting-example-2.email b/spec/fixtures/files/forward-quoting-example-2.email
new file mode 100644
index 000000000..936de3ddb
--- /dev/null
+++ b/spec/fixtures/files/forward-quoting-example-2.email
@@ -0,0 +1,318 @@
+From foi@example.com Wed May 28 14:14:39 2008
+To: FOI Person <EMAIL_TO>
+Subject: RE: Freedom of Information request
+Date: Wed, 28 May 2008 14:16:55 +0100
+MIME-Version: 1.0
+Content-Type: multipart/alternative;
+ boundary="----=_NextPart_000_008E_01C8C0CD.7BC69660"
+
+This is a multi-part message in MIME format.
+
+------=_NextPart_000_008E_01C8C0CD.7BC69660
+Content-Type: text/plain;
+ charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+Dear Mr Smith
+
+Some information
+
+Yours sincerely
+
+Foi Officer
+
+Please note that my email address has changed to foi@example.com
+
+
+From: Foi Officer [mailto:foi@example.com] On Behalf Of Foi Officer
+Sent: 19 May 2008 12:24
+To: Bob Smith
+Subject: RE: Freedom of Information request
+
+Dear Mr Smith
+
+Some information
+
+Please note that my email address has changed to foi@example.com
+
+
+-----Original Message-----
+From: Bob Smith [mailto:request-xxx-xxxxx@whatdotheyknow.com]
+Sent: 18 May 2008 14:22
+To: FOI requests at Example
+Subject: Freedom of Information request
+ Dear Sir or Madam,
+
+ Some information?
+
+ Yours faithfully,
+ Bob Smith
+ -------------------------------------------------------------------
+ Is this the wrong address for Freedom of Information
+ requests to Example? If so please let us know
+ by emailing xxx@whatdotheyknow.com - we'll make sure future ones go
+ to the right place.
+ -------------------------------------------------------------------
+
+
+------=_NextPart_000_008E_01C8C0CD.7BC69660
+Content-Type: text/html;
+ charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
+<meta name=ProgId content=Word.Document>
+<meta name=Generator content="Microsoft Word 11">
+<meta name=Originator content="Microsoft Word 11">
+<link rel=File-List href="cid:filelist.xml@01C8C0CD.7B3EA1B0">
+<link rel=Edit-Time-Data href="cid:editdata.mso">
+<!--[if !mso]>
+<style>
+v\:* {behavior:url(#default#VML);}
+o\:* {behavior:url(#default#VML);}
+w\:* {behavior:url(#default#VML);}
+.shape {behavior:url(#default#VML);}
+</style>
+<![endif]-->
+<title>RE: Freedom of Information request </title>
+<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
+ name="Street"/>
+<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
+ name="address"/>
+<!--[if gte mso 9]><xml>
+ <o:OfficeDocumentSettings>
+ <o:DoNotRelyOnCSS/>
+ </o:OfficeDocumentSettings>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:WordDocument>
+ <w:DisplayBackgroundShape/>
+ <w:SpellingState>Clean</w:SpellingState>
+ <w:GrammarState>Clean</w:GrammarState>
+ <w:DocumentKind>DocumentEmail</w:DocumentKind>
+ <w:EnvelopeVis/>
+ <w:ValidateAgainstSchemas/>
+ <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
+ <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
+ <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
+ <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
+ </w:WordDocument>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
+ </w:LatentStyles>
+</xml><![endif]--><!--[if !mso]>
+<style>
+st1\:*{behavior:url(#default#ieooui) }
+</style>
+<![endif]-->
+<style>
+<!--
+ /* Font Definitions */
+ @font-face
+ {font-family:Tahoma;
+ panose-1:2 11 6 4 3 5 4 4 2 4;
+ mso-font-charset:0;
+ mso-generic-font-family:swiss;
+ mso-font-pitch:variable;
+ mso-font-signature:1627421319 -2147483648 8 0 66047 0;}
+ /* Style Definitions */
+ p.MsoNormal, li.MsoNormal, div.MsoNormal
+ {mso-style-parent:"";
+ margin:0in;
+ margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:12.0pt;
+ font-family:"Times New Roman";
+ mso-fareast-font-family:"Times New Roman";}
+a:link, span.MsoHyperlink
+ {color:blue;
+ text-decoration:underline;
+ text-underline:single;}
+a:visited, span.MsoHyperlinkFollowed
+ {color:blue;
+ text-decoration:underline;
+ text-underline:single;}
+p
+ {mso-margin-top-alt:auto;
+ margin-right:0in;
+ mso-margin-bottom-alt:auto;
+ margin-left:0in;
+ mso-pagination:widow-orphan;
+ font-size:12.0pt;
+ font-family:"Times New Roman";
+ mso-fareast-font-family:"Times New Roman";}
+span.EmailStyle18
+ {mso-style-type:personal-reply;
+ mso-style-noshow:yes;
+ mso-ansi-font-size:10.0pt;
+ mso-bidi-font-size:10.0pt;
+ font-family:Arial;
+ mso-ascii-font-family:Arial;
+ mso-hansi-font-family:Arial;
+ mso-bidi-font-family:Arial;
+ color:navy;}
+span.SpellE
+ {mso-style-name:"";
+ mso-spl-e:yes;}
+span.GramE
+ {mso-style-name:"";
+ mso-gram-e:yes;}
+@page Section1
+ {size:595.3pt 841.9pt;
+ margin:1.0in 1.0in 1.0in 1.0in;
+ mso-header-margin:35.3pt;
+ mso-footer-margin:35.3pt;
+ mso-paper-source:0;}
+div.Section1
+ {page:Section1;}
+-->
+</style>
+<!--[if gte mso 10]>
+<style>
+ /* Style Definitions */
+ table.MsoNormalTable
+ {mso-style-name:"Table Normal";
+ mso-tstyle-rowband-size:0;
+ mso-tstyle-colband-size:0;
+ mso-style-noshow:yes;
+ mso-style-parent:"";
+ mso-padding-alt:0in 5.4pt 0in 5.4pt;
+ mso-para-margin:0in;
+ mso-para-margin-bottom:.0001pt;
+ mso-pagination:widow-orphan;
+ font-size:10.0pt;
+ font-family:"Times New Roman";
+ mso-ansi-language:#0400;
+ mso-fareast-language:#0400;
+ mso-bidi-language:#0400;}
+</style>
+<![endif]--><!--[if gte mso 9]><xml>
+ <o:shapedefaults v:ext="edit" spidmax="1026" />
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <o:shapelayout v:ext="edit">
+ <o:idmap v:ext="edit" data="1" />
+ </o:shapelayout></xml><![endif]-->
+</head>
+
+<body lang=EN-GB link=blue vlink=blue style='tab-interval:.5in'>
+
+<div class=Section1>
+
+<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
+10.0pt;font-family:Arial;color:navy'>Dear Mr Smith<o:p></o:p></span></font></p>
+
+<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
+10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>
+
+<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
+10.0pt;font-family:Arial;color:navy'>Some information.</p>
+
+<div>
+
+<p class=MsoNormal><strong><b><font size=2 color=navy face=Arial><span
+style='font-size:10.0pt;font-family:Arial;color:navy;mso-no-proof:yes'>Please
+note that my email address has changed to <a href="mailto:foi@example.com">foi@example.com</a></span></font></b></strong><font
+color=navy><span style='color:navy;mso-no-proof:yes'><o:p></o:p></span></font></p>
+
+<p class=MsoNormal><font size=3 color=navy face="Times New Roman"><span
+style='font-size:12.0pt;color:navy;mso-no-proof:yes'>&nbsp;<o:p></o:p></span></font></p>
+
+</div>
+
+<div>
+
+<div class=MsoNormal align=center style='text-align:center'><font size=3
+face="Times New Roman"><span lang=EN-US style='font-size:12.0pt;mso-ansi-language:
+EN-US'>
+
+<hr size=2 width="100%" align=center tabindex=-1>
+
+</span></font></div>
+
+<p class=MsoNormal><b><font size=2 face=Tahoma><span lang=EN-US
+style='font-size:10.0pt;font-family:Tahoma;mso-ansi-language:EN-US;font-weight:
+bold'>From:</span></font></b><font size=2 face=Tahoma><span lang=EN-US
+style='font-size:10.0pt;font-family:Tahoma;mso-ansi-language:EN-US'> Foi Officer
+[mailto:foi@example.com] <b><span style='font-weight:bold'>On Behalf Of </span></b>Foi
+Officer<br>
+<b><span style='font-weight:bold'>Sent:</span></b> 19 May 2008 12:24<br>
+<b><span style='font-weight:bold'>To:</span></b> Bob Smith<br>
+<b><span style='font-weight:bold'>Subject:</span></b> RE: Freedom of
+Information request </span></font><span lang=EN-US style='mso-ansi-language:
+EN-US'><o:p></o:p></span></p>
+
+</div>
+
+<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
+12.0pt'><o:p>&nbsp;</o:p></span></font></p>
+
+<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>Dear Mr
+Smith</span></font> <o:p></o:p></p>
+
+<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>Some information. </span></font><o:p></o:p></p>
+
+
+<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>Yours
+sincerely</span></font> <o:p></o:p></p>
+
+<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>Foi Officer</span></font> <o:p></o:p></p>
+
+
+<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>-----Original
+Message-----</span></font> <br>
+<font size=2><span style='font-size:10.0pt'>From: Bob Smith [<a
+href="mailto:request-xxx-xxxx@whatdotheyknow.com">mailto:request-xxx-xxxxx@whatdotheyknow.com</a>]
+</span></font><br>
+<font size=2><span style='font-size:10.0pt'>Sent: 18 May 2008 14:22</span></font>
+<br>
+<font size=2><span style='font-size:10.0pt'>To: FOI requests at Example</span></font> <br>
+<font size=2><span style='font-size:10.0pt'>Subject: Freedom of Information
+request</span></font>
+<o:p></o:p></p>
+
+<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;
+Dear Sir or Madam,</span></font> <o:p></o:p></p>
+
+<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;
+Some information?</span></font> <font
+color=navy><span style='color:navy'><span
+style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></font><o:p></o:p></p>
+
+p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;
+Yours faithfully,</span></font> <o:p></o:p></p>
+
+<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;
+Bob Smith</span></font> <o:p></o:p></p>
+
+<p><font size=2 face="Times New Roman"><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;
+-------------------------------------------------------------------</span></font>
+<br>
+<font size=2><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp; Is
+this the wrong address for Freedom of Information</span></font> <br>
+<font size=2><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp; requests
+to Example? If so please let us know</span></font> <br>
+<font size=2><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp; by
+emailing xxxx@whatdotheyknow.com - we'll make sure future ones go</span></font>
+<br>
+<font size=2><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp; to the
+right place.</span></font> <br>
+<font size=2><span style='font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;
+-------------------------------------------------------------------</span></font>
+<o:p></o:p></p>
+
+<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
+12.0pt'><o:p>&nbsp;</o:p></span></font></p>
+
+</div>
+
+
+
+
+</FONT></DIV></body></html>
+
+------=_NextPart_000_008E_01C8C0CD.7BC69660--
+
+
+
diff --git a/spec/fixtures/files/forward-quoting-example.email b/spec/fixtures/files/forward-quoting-example.email
new file mode 100644
index 000000000..80b29c533
--- /dev/null
+++ b/spec/fixtures/files/forward-quoting-example.email
@@ -0,0 +1,73 @@
+From foi@example.com Thu Apr 17 16:45:16 2008
+Return-path: <foi@example.com>
+Envelope-to: request-xxx-xxxxx@whatdotheyknow.com
+Delivery-date: Thu, 17 Apr 2008 16:45:16 +0100
+To: FOI Person <EMAIL_TO>
+Subject: Re: Freedom of Information request
+MIME-Version: 1.0
+From: FOI Officer <foi@example.com>
+Date: Thu, 17 Apr 2008 16:44:53 +0100
+Content-Type: multipart/alternative;
+ boundary="=_alternative 0056816D8025742E_="
+
+This is a multipart message in MIME format.
+
+--=_alternative 0056816D8025742E_=
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+17/04/08
+
+Dear Mr Requester
+
+Some text.
+
+Bob Smith <request-xxx-xxxxx@whatdotheyknow.com>
+17/04/08 15:57
+
+To
+FOI requests <foi@example.com>
+cc
+
+Subject
+Freedom of Information request
+
+
+
+--=_alternative 0056816D8025742E_=
+Content-Type: text/html; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+
+
+<br><font size=2 face="sans-serif">17/04/08</font>
+<br>
+<br><font size=2 face="sans-serif">Dear Mr Requester</font>
+<br>
+<br><font size=2 face="Arial"><b>Some text.</font>
+<br>
+<br>
+<br>
+<table width=100%>
+<tr valign=top>
+<td width=40%><font size=1 face="sans-serif"><b> Bob Smith &lt;request-xxx-xxxxx@whatdotheyknow.com&gt;</b>
+</font>
+<p><font size=1 face="sans-serif">17/04/08 15:57</font>
+<td width=59%>
+<table width=100%>
+<tr>
+<td>
+<div align=right><font size=1 face="sans-serif">To</font></div>
+<td valign=top><font size=1 face="sans-serif">FOI requests at &lt;foi@example.com&gt;</font>
+<tr>
+<td>
+<div align=right><font size=1 face="sans-serif">cc</font></div>
+<td valign=top>
+<tr>
+<td>
+<div align=right><font size=1 face="sans-serif">Subject</font></div>
+<td valign=top><font size=1 face="sans-serif">Freedom of Information request</font></table>
+<br>
+
+
+--=_alternative 0056816D8025742E_=--
+
diff --git a/spec/fixtures/public_body_translations.yml b/spec/fixtures/public_body_translations.yml
index f3453e853..24b14c470 100644
--- a/spec/fixtures/public_body_translations.yml
+++ b/spec/fixtures/public_body_translations.yml
@@ -9,6 +9,7 @@ geraldine_es_public_body_translation:
locale: es
notes: ""
publication_scheme: ""
+ disclosure_log: ""
geraldine_en_public_body_translation:
name: Geraldine Quango
@@ -21,6 +22,7 @@ geraldine_en_public_body_translation:
locale: en
notes: ""
publication_scheme: ""
+ disclosure_log: ""
humpadink_es_public_body_translation:
name: "El Department for Humpadinking"
@@ -33,6 +35,7 @@ humpadink_es_public_body_translation:
locale: es
notes: Baguette
publication_scheme: ""
+ disclosure_log: ""
humpadink_en_public_body_translation:
name: "Department for Humpadinking"
@@ -45,6 +48,7 @@ humpadink_en_public_body_translation:
locale: en
notes: An albatross told me!!!
publication_scheme: ""
+ disclosure_log: ""
forlorn_en_public_body_translation:
name: "Department of Loneliness"
@@ -57,6 +61,7 @@ forlorn_en_public_body_translation:
locale: en
notes: A very lonely public body that no one has corresponded with
publication_scheme: ""
+ disclosure_log: ""
silly_walks_en_public_body_translation:
id: 6
@@ -69,6 +74,7 @@ silly_walks_en_public_body_translation:
url_name: msw
notes: You know the one.
publication_scheme: ""
+ disclosure_log: ""
sensible_walks_en_public_body_translation:
id: 7
@@ -81,3 +87,4 @@ sensible_walks_en_public_body_translation:
url_name: sensible_walks
notes: I bet you’ve never heard of it.
publication_scheme: ""
+ disclosure_log: ""
diff --git a/spec/lib/timezone_fixes_spec.rb b/spec/lib/timezone_fixes_spec.rb
index 8dd1ff480..a2bea5f64 100644
--- a/spec/lib/timezone_fixes_spec.rb
+++ b/spec/lib/timezone_fixes_spec.rb
@@ -1,68 +1,100 @@
# This is a test of the monkey patches in timezone_fixes.rb
# We use MailServerLogDone here just as a totally random model that has a datetime type.
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "when doing things with timezones" do
- it "should preserve time objects with local time conversion to default timezone UTC" do
+ it "should preserve time objects with local time conversion to default timezone UTC
+ and return them as UTC times when config.time_zone is UTC" do
with_env_tz 'America/New_York' do
with_active_record_default_timezone :utc do
time = Time.local(2000)
mail_server_log_done = MailServerLogDone.create('last_stat' => time, 'filename' => 'dummy')
+ raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).read_attribute(:last_stat)
saved_time = MailServerLogDone.find(mail_server_log_done.id).last_stat
assert_equal time, saved_time
+ assert_equal saved_time, raw_saved_time
+ # Time is created in EST by local method (using ENV['TZ'])
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "EST"], time.to_a
+ # Due to :utc active_record_default_timezone, everything saved as UTC
+ assert_equal [0, 0, 5, 1, 1, 2000, 6, 1, false, "UTC"], raw_saved_time.to_a
+ # As config.time_zone is UTC (from config default), times returned in UTC
assert_equal [0, 0, 5, 1, 1, 2000, 6, 1, false, "UTC"], saved_time.to_a
end
end
end
- it "should preserve time objects with time with zone conversion to default timezone UTC" do
+ it "should preserve time objects with time with zone conversion to default timezone UTC
+ and return them as local times in the zone set by Time.use_zone" do
+
with_env_tz 'America/New_York' do
with_active_record_default_timezone :utc do
Time.use_zone 'Central Time (US & Canada)' do
time = Time.zone.local(2000)
mail_server_log_done = MailServerLogDone.create('last_stat' => time, 'filename' => 'dummy')
+ raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).read_attribute(:last_stat)
saved_time = MailServerLogDone.find(mail_server_log_done.id).last_stat
assert_equal time, saved_time
+ assert_equal saved_time, raw_saved_time
+ # Time is created in CST by Time.local (as Time.zone has been set)
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "CST"], time.to_a
- assert_equal [0, 0, 6, 1, 1, 2000, 6, 1, false, "UTC"], saved_time.to_a
+ # Due to :utc active_record_default_timezone, everything saved as UTC
+ assert_equal [0, 0, 6, 1, 1, 2000, 6, 1, false, "UTC"], raw_saved_time.to_a
+ # Times returned in CST due to Time.use_zone and ActiveRecord::time_zone_aware_attributes
+ # being true
+ assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "CST"], saved_time.to_a
end
end
end
end
- # XXX Couldn't get this test to work - but the other tests seem to detect presence of
- # the monkey patch, so they will do for now.
- #it "should preserve time objects with UTC time conversion to default timezone local" do
- # with_env_tz 'America/New_York' do
- # time = Time.utc(2000)
- # mail_server_log_done = MailServerLogDone.create('last_stat' => time, 'filename' => 'dummy')
- # saved_time = MailServerLogDone.find(mail_server_log_done.id).last_stat
- # assert_equal time, saved_time
- # assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"], time.to_a
- # assert_equal [0, 0, 19, 31, 12, 1999, 5, 365, false, "EST"], saved_time.to_a
- # end
- #end
+ it "should preserve time objects with UTC time conversion to default timezone local
+ and return then as UTC times when config.time_zone is UTC" do
+ with_env_tz 'America/New_York' do
+ with_active_record_default_timezone :local do
+ time = Time.utc(2000)
+ mail_server_log_done = MailServerLogDone.create('last_stat' => time, 'filename' => 'dummy')
+ raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).read_attribute(:last_stat)
+ saved_time = MailServerLogDone.find(mail_server_log_done.id).last_stat
+ assert_equal time, saved_time
+ assert_equal saved_time, raw_saved_time
+ # Time is created in UTC by Time.utc method
+ assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"], time.to_a
+ # Due to :local active_record_default_timezone, saved as EST
+ assert_equal [0, 0, 19, 31, 12, 1999, 5, 365, false, "EST"], raw_saved_time.to_a
+ # As config.time_zone is UTC (from config default), times returned in UTC
+ assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"], saved_time.to_a
+ end
+ end
+ end
- it "should preserve time objects with time with zone conversion to default timezone local" do
+ it "should preserve time objects with time with zone conversion to default timezone local
+ and return them as local times in the zone set by Time.use_zone" do
with_env_tz 'America/New_York' do
with_active_record_default_timezone :local do
Time.use_zone 'Central Time (US & Canada)' do
time = Time.zone.local(2000)
mail_server_log_done = MailServerLogDone.create('last_stat' => time, 'filename' => 'dummy')
+ raw_saved_time = MailServerLogDone.find(mail_server_log_done.id).read_attribute(:last_stat)
saved_time = MailServerLogDone.find(mail_server_log_done.id).last_stat
assert_equal time, saved_time
+ assert_equal saved_time, raw_saved_time
+ # Time is created in CST by Time.zone.local
assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "CST"], time.to_a
- assert_equal [0, 0, 1, 1, 1, 2000, 6, 1, false, "EST"], saved_time.to_a
+ # Due to :local active_record_default_timezone, saved as EST
+ assert_equal [0, 0, 1, 1, 1, 2000, 6, 1, false, "EST"], raw_saved_time.to_a
+ # Due to Time.use_zone, and ActiveRecord::time_zone_aware_attributes
+ # being true, time returned in CST
+ assert_equal [0, 0, 0, 1, 1, 2000, 6, 1, false, "CST"], saved_time.to_a
end
end
end
end
+
protected
+
def with_env_tz(new_tz = 'US/Eastern')
old_tz, ENV['TZ'] = ENV['TZ'], new_tz
yield
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index 69a5da0e9..b038c43d9 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -154,6 +154,23 @@ describe IncomingMessage, " folding quoted parts of emails" do
text.should == "\n\nFOLDED_QUOTED_SECTION"
end
+ it 'should fold an example of another kind of forward quoting' do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('forward-quoting-example.email', ir.incoming_email)
+ message = ir.incoming_messages[1]
+ message.get_main_body_text_folded.should match(/FOLDED_QUOTED_SECTION/)
+ end
+
+ it 'should fold a further example of forward quoting' do
+ ir = info_requests(:fancy_dog_request)
+ receive_incoming_mail('forward-quoting-example-2.email', ir.incoming_email)
+ message = ir.incoming_messages[1]
+ body_text = message.get_main_body_text_folded
+ body_text.should match(/FOLDED_QUOTED_SECTION/)
+ # check that the quoted section incorporates both quoted messages
+ body_text.should_not match('Subject: RE: Freedom of Information request')
+ end
+
end
describe IncomingMessage, " checking validity to reply to" do
diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb
index 345629bd6..c42eb5e8b 100644
--- a/spec/models/track_thing_spec.rb
+++ b/spec/models/track_thing_spec.rb
@@ -35,10 +35,11 @@ describe TrackThing, "when tracking changes" do
end
it "will make some sane descriptions of search-based tracks" do
- tests = [['bob variety:user', "users matching text 'bob'"],
- ['bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)', "comments or requests which are successful or unsuccessful matching text 'bob'"],
- ['(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)', 'requests which are awaiting a response']]
- for query, description in tests
+ tests = { 'bob variety:user' => "users matching text 'bob'",
+ 'bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)' => "comments or requests which are successful or unsuccessful matching text 'bob'",
+ '(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)' => 'requests which are awaiting a response',
+ ' (variety:sent OR variety:followup_sent OR variety:response OR variety:comment)' => 'all requests or comments' }
+ tests.each do |query, description|
track_thing = TrackThing.create_track_for_search_query(query)
track_thing.track_query_description.should == description
end
diff --git a/spec/views/public_body/show.rhtml_spec.rb b/spec/views/public_body/show.rhtml_spec.rb
index a42516d72..b68b3f43b 100644
--- a/spec/views/public_body/show.rhtml_spec.rb
+++ b/spec/views/public_body/show.rhtml_spec.rb
@@ -11,6 +11,7 @@ describe "when viewing a body" do
:eir_only? => nil,
:info_requests => [1, 2, 3, 4], # out of sync with Xapian
:publication_scheme => '',
+ :disclosure_log => '',
:calculated_home_page => '')
@pb.stub!(:override_request_email).and_return(nil)
@pb.stub!(:is_requestable?).and_return(true)