aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/general_controller_spec.rb4
-rw-r--r--spec/controllers/request_controller_spec.rb18
-rw-r--r--spec/controllers/track_controller_spec.rb2
-rw-r--r--spec/controllers/user_controller_spec.rb5
-rw-r--r--spec/lib/tmail_extensions_spec.rb1
-rw-r--r--spec/models/incoming_message_spec.rb1
-rw-r--r--spec/models/info_request_spec.rb4
-rw-r--r--spec/models/public_body_spec.rb24
-rw-r--r--spec/models/user_spec.rb8
-rw-r--r--spec/spec_helper.rb8
-rw-r--r--spec/views/public_body/show.rhtml_spec.rb2
-rw-r--r--spec/views/request/_after_actions.rhtml_spec.rb2
-rw-r--r--spec/views/request/_describe_state.rhtml_spec.rb2
-rw-r--r--spec/views/request/list.rhtml_spec.rb2
-rw-r--r--spec/views/request/show.rhtml_spec.rb2
-rw-r--r--spec/views/request_game/play.rhtml_spec.rb2
16 files changed, 49 insertions, 38 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb
index a8f8bc901..40a676d61 100644
--- a/spec/controllers/general_controller_spec.rb
+++ b/spec/controllers/general_controller_spec.rb
@@ -74,13 +74,13 @@ describe GeneralController, "when searching" do
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
- ActionController::Routing::Routes.add_filters(['conditionallyprependlocale'])
+ ActionController::Routing::Routes.add_filters('conditionallyprependlocale')
get :frontpage
response.should have_text(home_link_regex)
end
it "should generate URLs without a locale prepended when there's only one locale set" do
- ActionController::Routing::Routes.add_filters(['conditionallyprependlocale'])
+ ActionController::Routing::Routes.add_filters('conditionallyprependlocale')
old_available_locales = FastGettext.default_available_locales
available_locales = ['en']
FastGettext.default_available_locales = available_locales
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 32e14cd52..3420d212e 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -807,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
@@ -985,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)
@@ -1032,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
@@ -1060,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
@@ -1085,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
@@ -1116,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
@@ -1153,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
@@ -1207,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
@@ -1250,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
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 7fcc81017..90d13495f 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -58,7 +58,7 @@ describe TrackController, "when sending alerts for a track" do
deliveries.size.should == 1
mail = deliveries[0]
mail.body.should =~ /Alter your subscription/
- mail.to_addrs.to_s.should include(users(:silly_name_user).email)
+ mail.to_addrs.first.to_s.should include(users(:silly_name_user).email)
mail.body =~ /(http:\/\/.*\/c\/(.*))/
mail_url = $1
mail_token = $2
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index fdc3961a1..399b275a7 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'json'
@@ -260,8 +261,8 @@ describe UserController, "when sending another user a message" do
mail = deliveries[0]
mail.body.should include("Bob Smith has used #{MySociety::Config.get('SITE_NAME')} to send you the message below")
mail.body.should include("Just a test!")
- #mail.to_addrs.to_s.should == users(:silly_name_user).name_and_email # XXX fix some nastiness with quoting name_and_email
- mail.from_addrs.to_s.should == users(:bob_smith_user).name_and_email
+ #mail.to_addrs.first.to_s.should == users(:silly_name_user).name_and_email # XXX fix some nastiness with quoting name_and_email
+ mail.from_addrs.first.to_s.should == users(:bob_smith_user).name_and_email
end
end
diff --git a/spec/lib/tmail_extensions_spec.rb b/spec/lib/tmail_extensions_spec.rb
index ffb8cb178..6a55c34da 100644
--- a/spec/lib/tmail_extensions_spec.rb
+++ b/spec/lib/tmail_extensions_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
# This is a test of the set_content_type monkey patch in
# lib/tmail_extensions.rb
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index 3bec7aefd..1a4baca0b 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe IncomingMessage, " when dealing with incoming mail" do
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index f7afc4e97..409d48ede 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -380,8 +380,8 @@ describe InfoRequest do
before do
Time.stub!(:now).and_return(Time.utc(2007, 11, 9, 23, 59))
- @mock_comment_event = mock_model(InfoRequestEvent, :created_at => Time.now - 23.days, :event_type => 'comment')
- @mock_response_event = mock_model(InfoRequestEvent, :created_at => Time.now - 22.days, :event_type => 'response')
+ @mock_comment_event = safe_mock_model(InfoRequestEvent, :created_at => Time.now - 23.days, :event_type => 'comment')
+ @mock_response_event = safe_mock_model(InfoRequestEvent, :created_at => Time.now - 22.days, :event_type => 'response')
@info_request = InfoRequest.new(:prominence => 'normal',
:awaiting_description => true,
:info_request_events => [@mock_response_event, @mock_comment_event])
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 4304de2ed..09edb395f 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -302,8 +302,8 @@ describe PublicBody, " when loading CSV files" do
notes.size.should == 4
notes.should == [
"line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"\}",
- "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"tag_string\":\"scottish\",\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\"\}",
- "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"tag_string\":\"fake aTag\",\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\"\}",
+ "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"\}",
+ "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"\}",
"Notes: Some bodies are in database, but not in CSV file:\n Department for Humpadinking\n Geraldine Quango\nYou may want to delete them manually.\n"
]
@@ -316,7 +316,7 @@ describe PublicBody, " when loading CSV files" do
PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == []
PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['scottish']
- PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['fake', 'aTag']
+ PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['aTag', 'fake']
# Import again to check the 'add' tag functionality works
new_tags_file = load_file_fixture('fake-authority-add-tags.rb')
@@ -324,8 +324,8 @@ describe PublicBody, " when loading CSV files" do
# Check tags were added successfully
PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == ['aTag']
- PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['scottish', 'aTag']
- PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['fake', 'aTag']
+ PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['aTag', 'scottish']
+ PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['aTag', 'fake']
end
it "should import tags successfully when the import tag is set" do
@@ -334,8 +334,8 @@ describe PublicBody, " when loading CSV files" do
# Check new bodies were imported successfully
PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == ['fake']
- PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['scottish', 'fake']
- PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['fake', 'aTag']
+ PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['fake', 'scottish']
+ PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['aTag', 'fake']
# Import again to check the 'replace' tag functionality works
new_tags_file = load_file_fixture('fake-authority-add-tags.rb')
@@ -344,7 +344,7 @@ describe PublicBody, " when loading CSV files" do
# Check tags were added successfully
PublicBody.find_by_name('North West Fake Authority').tag_array_for_search.should == ['aTag']
PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search.should == ['aTag']
- PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['fake', 'aTag']
+ PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search.should == ['aTag', 'fake']
end
it "should create bodies with names in multiple locales" do
@@ -357,9 +357,9 @@ describe PublicBody, " when loading CSV files" do
notes.should == [
"line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"}",
"line 2: creating new authority 'North West Fake Authority' (locale: es):\n\t{\"name\":\"Autoridad del Nordeste\"}",
- "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"tag_string\":\"scottish\",\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\"}",
+ "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"}",
"line 3: creating new authority 'Scottish Fake Authority' (locale: es):\n\t{\"name\":\"Autoridad Escocesa\"}",
- "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"tag_string\":\"fake aTag\",\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\"}",
+ "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"}",
"line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: es):\n\t{\"name\":\"Autoridad Irlandesa\"}",
"Notes: Some bodies are in database, but not in CSV file:\n Department for Humpadinking\n Geraldine Quango\nYou may want to delete them manually.\n"
]
@@ -385,8 +385,8 @@ describe PublicBody, " when loading CSV files" do
notes.size.should == 4
notes.should == [
"line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"}",
- "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"tag_string\":\"scottish\",\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\"}",
- "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"tag_string\":\"fake aTag\",\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\"}",
+ "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"}",
+ "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"}",
"Notes: Some bodies are in database, but not in CSV file:\n Department for Humpadinking\n Geraldine Quango\nYou may want to delete them manually.\n"
]
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index f77e39ab4..e0a6c649e 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -152,10 +152,10 @@ end
describe User, "when reindexing referencing models" do
before do
- @request_event = mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
- @request = mock_model(InfoRequest, :info_request_events => [@request_event])
- @comment_event = mock_model(InfoRequestEvent, :xapian_mark_needs_index => true)
- @comment = mock_model(Comment, :info_request_events => [@comment_event])
+ @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
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 83ebef937..20e630a26 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -144,6 +144,14 @@ if $tempfilecount.nil?
end
end
+# to_ary differs in Ruby 1.8 and 1.9
+# @see http://yehudakatz.com/2010/01/02/the-craziest-fing-bug-ive-ever-seen/
+def safe_mock_model(model, args = {})
+ mock = mock_model(model, args)
+ mock.should_receive(:to_ary).any_number_of_times
+ mock
+end
+
def load_raw_emails_data(raw_emails)
raw_email = raw_emails(:useless_raw_email)
begin
diff --git a/spec/views/public_body/show.rhtml_spec.rb b/spec/views/public_body/show.rhtml_spec.rb
index cd81888eb..a37d8be0d 100644
--- a/spec/views/public_body/show.rhtml_spec.rb
+++ b/spec/views/public_body/show.rhtml_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)
describe "when viewing a body" do
before do
diff --git a/spec/views/request/_after_actions.rhtml_spec.rb b/spec/views/request/_after_actions.rhtml_spec.rb
index c73f35d33..6a56e7a71 100644
--- a/spec/views/request/_after_actions.rhtml_spec.rb
+++ b/spec/views/request/_after_actions.rhtml_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)
describe 'when displaying actions that can be taken with regard to a request' do
diff --git a/spec/views/request/_describe_state.rhtml_spec.rb b/spec/views/request/_describe_state.rhtml_spec.rb
index 9fb776db3..ccf653b1b 100644
--- a/spec/views/request/_describe_state.rhtml_spec.rb
+++ b/spec/views/request/_describe_state.rhtml_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)
describe 'when showing the form for describing the state of a request' do
diff --git a/spec/views/request/list.rhtml_spec.rb b/spec/views/request/list.rhtml_spec.rb
index 60a28eec5..1f86ec641 100644
--- a/spec/views/request/list.rhtml_spec.rb
+++ b/spec/views/request/list.rhtml_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)
describe "when listing recent requests" do
diff --git a/spec/views/request/show.rhtml_spec.rb b/spec/views/request/show.rhtml_spec.rb
index ca4663afc..adb244f47 100644
--- a/spec/views/request/show.rhtml_spec.rb
+++ b/spec/views/request/show.rhtml_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)
describe 'when viewing an information request' do
diff --git a/spec/views/request_game/play.rhtml_spec.rb b/spec/views/request_game/play.rhtml_spec.rb
index e90861e34..24fb6d75d 100644
--- a/spec/views/request_game/play.rhtml_spec.rb
+++ b/spec/views/request_game/play.rhtml_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)
describe 'when viewing the request game' do