aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin_public_body_controller_spec.rb51
-rw-r--r--spec/controllers/general_controller_spec.rb120
-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/models/user_spec.rb98
-rw-r--r--spec/views/public_body/show.rhtml_spec.rb1
11 files changed, 692 insertions, 133 deletions
diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb
index be33802c5..504ddc5cc 100644
--- a/spec/controllers/admin_public_body_controller_spec.rb
+++ b/spec/controllers/admin_public_body_controller_spec.rb
@@ -166,6 +166,13 @@ describe AdminPublicBodyController, "when administering public bodies and paying
config['SKIP_ADMIN_AUTH'] = true
end
+ def setup_emergency_credentials(username, password)
+ config = MySociety::Config.load_default()
+ config['SKIP_ADMIN_AUTH'] = false
+ config['ADMIN_USERNAME'] = username
+ config['ADMIN_PASSWORD'] = password
+ @request.env["HTTP_AUTHORIZATION"] = ""
+ end
it "disallows non-authenticated users to do anything" do
@request.env["HTTP_AUTHORIZATION"] = ""
@@ -180,19 +187,14 @@ describe AdminPublicBodyController, "when administering public bodies and paying
config = MySociety::Config.load_default()
config['SKIP_ADMIN_AUTH'] = true
@request.env["HTTP_AUTHORIZATION"] = ""
-
n = PublicBody.count
post :destroy, { :id => public_bodies(:forlorn_public_body).id }
PublicBody.count.should == n - 1
session[:using_admin].should == 1
end
- it "doesn't let people with bad credentials log in" do
- config = MySociety::Config.load_default()
- config['SKIP_ADMIN_AUTH'] = false
- config['ADMIN_USERNAME'] = 'biz'
- config['ADMIN_PASSWORD'] = 'fuz'
- @request.env["HTTP_AUTHORIZATION"] = ""
+ it "doesn't let people with bad emergency account credentials log in" do
+ setup_emergency_credentials('biz', 'fuz')
n = PublicBody.count
basic_auth_login(@request, "baduser", "badpassword")
post :destroy, { :id => public_bodies(:forlorn_public_body).id }
@@ -201,12 +203,8 @@ describe AdminPublicBodyController, "when administering public bodies and paying
session[:using_admin].should == nil
end
- it "allows people with good credentials log in using HTTP Basic Auth" do
- config = MySociety::Config.load_default()
- config['SKIP_ADMIN_AUTH'] = false
- config['ADMIN_USERNAME'] = 'biz'
- config['ADMIN_PASSWORD'] = 'fuz'
- @request.env["HTTP_AUTHORIZATION"] = ""
+ it "allows people with good emergency account credentials log in using HTTP Basic Auth" do
+ setup_emergency_credentials('biz', 'fuz')
n = PublicBody.count
basic_auth_login(@request, "biz", "fuz")
post :show, { :id => public_bodies(:humpadink_public_body).id, :emergency => 1}
@@ -235,6 +233,33 @@ describe AdminPublicBodyController, "when administering public bodies and paying
PublicBody.count.should == n
session[:using_admin].should == nil
end
+
+ describe 'when asked for the admin current user' do
+
+ it 'returns the emergency account name for someone who logged in with the emergency account' do
+ setup_emergency_credentials('biz', 'fuz')
+ basic_auth_login(@request, "biz", "fuz")
+ post :show, { :id => public_bodies(:humpadink_public_body).id, :emergency => 1 }
+ controller.send(:admin_current_user).should == 'biz'
+ end
+
+ it 'returns the current user url_name for a superuser' do
+ session[:user_id] = users(:admin_user).id
+ @request.env["HTTP_AUTHORIZATION"] = ""
+ post :show, { :id => public_bodies(:humpadink_public_body).id }
+ controller.send(:admin_current_user).should == users(:admin_user).url_name
+ end
+
+ it 'returns the REMOTE_USER value from the request environment when skipping admin auth' do
+ config = MySociety::Config.load_default()
+ config['SKIP_ADMIN_AUTH'] = true
+ @request.env["HTTP_AUTHORIZATION"] = ""
+ @request.env["REMOTE_USER"] = "i_am_admin"
+ post :show, { :id => public_bodies(:humpadink_public_body).id }
+ controller.send(:admin_current_user).should == "i_am_admin"
+ end
+
+ end
end
describe AdminPublicBodyController, "when administering public bodies with i18n" do
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index cebcaf6ab..935f8eab6 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -33,12 +33,22 @@ describe GeneralController, 'when getting the blog feed' do
end
-describe GeneralController, "when searching" do
+describe GeneralController, "when showing the frontpage" do
+
integrate_views
- before(:each) do
- load_raw_emails_data
- rebuild_xapian_index
+ before do
+ public_body = mock_model(PublicBody, :name => "Example Public Body",
+ :url_name => 'example_public_body')
+ info_request = mock_model(InfoRequest, :public_body => public_body,
+ :title => 'Example Request',
+ :url_title => 'example_request')
+ info_request_event = mock_model(InfoRequestEvent, :created_at => Time.now,
+ :info_request => info_request,
+ :described_at => Time.now,
+ :search_text_main => 'example text')
+ xapian_result = mock('xapian result', :results => [{:model => info_request_event}])
+ controller.stub!(:perform_search).and_return(xapian_result)
end
it "should render the front page successfully" do
@@ -87,11 +97,6 @@ describe GeneralController, "when searching" do
response.should be_success
end
- it "should redirect from search query URL to pretty URL" do
- post :search_redirect, :query => "mouse" # query hidden in POST parameters
- response.should redirect_to(:action => 'search', :combined => "mouse", :view => "all") # URL /search/:query/all
- end
-
describe "when using different locale settings" do
home_link_regex = /href=".*\/en\//
it "should generate URLs with a locale prepended when there's more than one locale set" do
@@ -133,23 +138,41 @@ describe GeneralController, "when searching" do
I18n.available_locales = old_i18n_available_locales
end
end
+end
+describe GeneralController, "when showing the front page with fixture data" do
describe 'when constructing the list of recent requests' do
+
before(:each) do
- load_raw_emails_data
- rebuild_xapian_index
+ rebuild_xapian_index
end
- it 'should list the newest successful request first' do
- # Make sure the newest is listed first even if an older one
- # has a newer comment or was reclassified more recently:
- # https://github.com/mysociety/alaveteli/issues/370
- #
- # This is a deliberate behaviour change, in that the
- # previous behaviour (showing more-recently-reclassified
- # requests first) was intentional.
- get :frontpage
- assigns[:request_events].first.info_request.should == info_requests(:another_boring_request)
+ describe 'when there are fewer than five successful requests' do
+
+ it 'should list the most recently sent and successful requests by the creation date of the
+ request event' do
+ # Make sure the newest response is listed first even if a request
+ # with an older response has a newer comment or was reclassified more recently:
+ # https://github.com/mysociety/alaveteli/issues/370
+ #
+ # This is a deliberate behaviour change, in that the
+ # previous behaviour (showing more-recently-reclassified
+ # requests first) was intentional.
+ get :frontpage
+
+ request_events = assigns[:request_events]
+ previous = nil
+ request_events.each do |event|
+ if previous
+ previous.created_at.should be >= event.created_at
+ end
+ ['sent', 'response'].include?(event.event_type).should be_true
+ if event.event_type == 'response'
+ ['successful', 'partially_successful'].include?(event.calculated_state).should be_true
+ end
+ previous = event
+ end
+ end
end
it 'should coalesce duplicate requests' do
@@ -158,37 +181,44 @@ describe GeneralController, "when searching" do
end
end
- describe 'when using xapian search' do
+end
- # rebuild xapian index after fixtures loaded
- before(:each) do
- load_raw_emails_data
- rebuild_xapian_index
- end
+describe GeneralController, 'when using xapian search' do
- it "should find info request when searching for '\"fancy dog\"'" do
- get :search, :combined => ['"fancy dog"']
- response.should render_template('search')
- assigns[:xapian_requests].matches_estimated.should == 1
- assigns[:xapian_requests].results.size.should == 1
- assigns[:xapian_requests].results[0][:model].should == info_request_events(:useless_outgoing_message_event)
+ integrate_views
+
+ # rebuild xapian index after fixtures loaded
+ before(:each) do
+ load_raw_emails_data
+ rebuild_xapian_index
+ end
+
+ it "should redirect from search query URL to pretty URL" do
+ post :search_redirect, :query => "mouse" # query hidden in POST parameters
+ response.should redirect_to(:action => 'search', :combined => "mouse", :view => "all") # URL /search/:query/all
+ end
- assigns[:xapian_requests].words_to_highlight == ["fancy", "dog"]
- end
+ it "should find info request when searching for '\"fancy dog\"'" do
+ get :search, :combined => ['"fancy dog"']
+ response.should render_template('search')
+ assigns[:xapian_requests].matches_estimated.should == 1
+ assigns[:xapian_requests].results.size.should == 1
+ assigns[:xapian_requests].results[0][:model].should == info_request_events(:useless_outgoing_message_event)
- it "should find public body and incoming message when searching for 'geraldine quango'" do
- get :search, :combined => ['geraldine quango']
- response.should render_template('search')
+ assigns[:xapian_requests].words_to_highlight == ["fancy", "dog"]
+ end
- assigns[:xapian_requests].matches_estimated.should == 1
- assigns[:xapian_requests].results.size.should == 1
- assigns[:xapian_requests].results[0][:model].should == info_request_events(:useless_incoming_message_event)
+ it "should find public body and incoming message when searching for 'geraldine quango'" do
+ get :search, :combined => ['geraldine quango']
+ response.should render_template('search')
- assigns[:xapian_bodies].matches_estimated.should == 1
- assigns[:xapian_bodies].results.size.should == 1
- assigns[:xapian_bodies].results[0][:model].should == public_bodies(:geraldine_public_body)
- end
+ assigns[:xapian_requests].matches_estimated.should == 1
+ assigns[:xapian_requests].results.size.should == 1
+ assigns[:xapian_requests].results[0][:model].should == info_request_events(:useless_incoming_message_event)
+ assigns[:xapian_bodies].matches_estimated.should == 1
+ assigns[:xapian_bodies].results.size.should == 1
+ assigns[:xapian_bodies].results[0][:model].should == public_bodies(:geraldine_public_body)
end
it "should filter results based on end of URL being 'all'" do
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/models/user_spec.rb b/spec/models/user_spec.rb
index 03b2f34f9..e31c3f1b5 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1,42 +1,42 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-describe User, "making up the URL name" do
+describe User, "making up the URL name" do
before do
@user = User.new
end
- it 'should remove spaces, and make lower case' do
+ it 'should remove spaces, and make lower case' do
@user.name = 'Some Name'
@user.url_name.should == 'some_name'
end
- it 'should not allow a numeric name' do
+ it 'should not allow a numeric name' do
@user.name = '1234'
@user.url_name.should == 'user'
end
end
-describe User, "showing the name" do
+describe User, "showing the name" do
before do
@user = User.new
@user.name = 'Some Name '
end
- it 'should strip whitespace' do
+ it 'should strip whitespace' do
@user.name.should == 'Some Name'
end
- it 'should show if user has been banned' do
+ it 'should show if user has been banned' do
@user.ban_text = "Naughty user"
@user.name.should == 'Some Name (Account suspended)'
end
end
-
+
describe User, " when authenticating" do
before do
- @empty_user = User.new
+ @empty_user = User.new
@full_user = User.new
@full_user.name = "Sensible User"
@@ -71,7 +71,7 @@ end
describe User, " when saving" do
before do
- @user = User.new
+ @user = User.new
end
it "should not save without setting some parameters" do
@@ -80,7 +80,7 @@ describe User, " when saving" do
it "should not save with misformatted email" do
@user.name = "Mr. Silly"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "mousefooble"
@user.should have(1).error_on(:email)
end
@@ -88,58 +88,58 @@ describe User, " when saving" do
it "should not allow an email address as a name" do
@user.name = "silly@example.com"
@user.email = "silly@example.com"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.should have(1).error_on(:name)
end
it "should not save with no password" do
@user.name = "Mr. Silly"
- @user.password = ""
+ @user.password = ""
@user.email = "silly@localhost"
@user.should have(1).error_on(:hashed_password)
end
it "should save with reasonable name, password and email" do
@user.name = "Mr. Reasonable"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "reasonable@localhost"
@user.save!
end
it "should let you make two users with same name" do
@user.name = "Mr. Flobble"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "flobble@localhost"
@user.save!
- @user2 = User.new
+ @user2 = User.new
@user2.name = "Mr. Flobble"
- @user2.password = "insecurepassword"
+ @user2.password = "insecurepassword"
@user2.email = "flobble2@localhost"
@user2.save!
end
-
+
it 'should mark the model for reindexing in xapian if the no_xapian_reindex flag is set to false' do
@user.name = "Mr. First"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "reasonable@localhost"
@user.no_xapian_reindex = false
@user.should_receive(:xapian_mark_needs_index)
@user.save!
end
-
+
it 'should mark the model for reindexing in xapian if the no_xapian_reindex flag is not set' do
@user.name = "Mr. Second"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "reasonable@localhost"
@user.no_xapian_reindex = nil
@user.should_receive(:xapian_mark_needs_index)
@user.save!
end
-
- it 'should not mark the model for reindexing in xapian if the no_xapian_reindex flag is set' do
+
+ it 'should not mark the model for reindexing in xapian if the no_xapian_reindex flag is set' do
@user.name = "Mr. Third"
- @user.password = "insecurepassword"
+ @user.password = "insecurepassword"
@user.email = "reasonable@localhost"
@user.no_xapian_reindex = true
@user.should_not_receive(:xapian_mark_needs_index)
@@ -149,47 +149,47 @@ describe User, " when saving" do
end
-describe User, "when reindexing referencing models" do
+describe User, "when reindexing referencing models" do
- before do
+ before do
@request_event = safe_mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
@request = safe_mock_model(InfoRequest, :info_request_events => [@request_event])
@comment_event = safe_mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
@comment = safe_mock_model(Comment, :info_request_events => [@comment_event])
@user = User.new(:comments => [@comment], :info_requests => [@request])
end
-
- it 'should reindex events associated with that user\'s comments when URL changes' do
+
+ it 'should reindex events associated with that user\'s comments when URL changes' do
@user.stub!(:changes).and_return({'url_name' => 1})
@comment_event.should_receive(:xapian_mark_needs_index)
@user.reindex_referencing_models
end
-
- it 'should reindex events associated with that user\'s requests when URL changes' do
+
+ it 'should reindex events associated with that user\'s requests when URL changes' do
@user.stub!(:changes).and_return({'url_name' => 1})
@request_event.should_receive(:xapian_mark_needs_index)
@user.reindex_referencing_models
end
-
- describe 'when no_xapian_reindex is set' do
- before do
+
+ describe 'when no_xapian_reindex is set' do
+ before do
@user.no_xapian_reindex = true
end
-
- it 'should not reindex events associated with that user\'s comments when URL changes' do
+
+ it 'should not reindex events associated with that user\'s comments when URL changes' do
@user.stub!(:changes).and_return({'url_name' => 1})
@comment_event.should_not_receive(:xapian_mark_needs_index)
@user.reindex_referencing_models
end
-
- it 'should not reindex events associated with that user\'s requests when URL changes' do
+
+ it 'should not reindex events associated with that user\'s requests when URL changes' do
@user.stub!(:changes).and_return({'url_name' => 1})
@request_event.should_not_receive(:xapian_mark_needs_index)
@user.reindex_referencing_models
end
-
+
end
-
+
end
describe User, "when checking abilities" do
@@ -208,26 +208,26 @@ describe User, "when checking abilities" do
end
-describe User, 'when asked if a user owns every request' do
-
- before do
+describe User, 'when asked if a user owns every request' do
+
+ before do
@mock_user = mock_model(User)
end
-
- it 'should return false if no user is passed' do
+
+ it 'should return false if no user is passed' do
User.owns_every_request?(nil).should be_false
end
-
- it 'should return true if the user has "requires admin" power' do
+
+ it 'should return true if the user has "requires admin" power' do
@mock_user.stub!(:owns_every_request?).and_return true
User.owns_every_request?(@mock_user).should be_true
end
-
- it 'should return false if the user does not have "requires admin" power' do
+
+ it 'should return false if the user does not have "requires admin" power' do
@mock_user.stub!(:owns_every_request?).and_return false
User.owns_every_request?(@mock_user).should be_false
end
-
+
end
describe User, " when making name and email address" do
@@ -296,7 +296,7 @@ describe User, "when emails have bounced" do
it "should record bounces" do
User.record_bounce_for_email("bob@localhost", "The reason we think the email bounced (e.g. a bounce message)")
-
+
user = User.find_user_by_email("bob@localhost")
user.email_bounced_at.should_not be_nil
user.email_bounce_message.should == "The reason we think the email bounced (e.g. a bounce message)"
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)