aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/comment_controller_spec.rb2
-rw-r--r--spec/controllers/request_controller_spec.rb24
-rw-r--r--spec/controllers/track_controller_spec.rb6
-rw-r--r--spec/controllers/user_controller_spec.rb8
-rw-r--r--spec/helpers/date_time_helper_spec.rb71
-rw-r--r--spec/helpers/link_to_helper_spec.rb123
-rw-r--r--spec/models/customstates.rb2
-rw-r--r--spec/models/public_body_spec.rb2
-rw-r--r--spec/models/raw_email_spec.rb2
-rw-r--r--spec/models/user_spec.rb2
-rw-r--r--spec/spec_helper.rb2
11 files changed, 172 insertions, 72 deletions
diff --git a/spec/controllers/comment_controller_spec.rb b/spec/controllers/comment_controller_spec.rb
index 5e250f689..480c85ad7 100644
--- a/spec/controllers/comment_controller_spec.rb
+++ b/spec/controllers/comment_controller_spec.rb
@@ -26,7 +26,7 @@ describe CommentController, "when commenting on a request" do
post :new, params
post_redirect = PostRedirect.get_last_post_redirect
response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
- # post_redirect.post_params.should == params # XXX get this working. there's a : vs '' problem amongst others
+ # post_redirect.post_params.should == params # TODO: get this working. there's a : vs '' problem amongst others
end
it "should create the comment, and redirect to request page when input is good and somebody is logged in" do
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 070511fb0..48f37a45c 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -77,7 +77,7 @@ describe RequestController, "when changing things that appear on the request pag
PurgeRequest.all().count.should == 0
end
it "should purge the downstream cache when censor rules have changed" do
- # XXX really, CensorRules should execute expiry logic as part
+ # TODO: really, CensorRules should execute expiry logic as part
# of the after_save of the model. Currently this is part of
# the AdminCensorRuleController logic, so must be tested from
# there. Leaving this stub test in place as a reminder
@@ -643,7 +643,7 @@ describe RequestController, "when showing one request" do
ir = info_requests(:fancy_dog_request)
receive_incoming_mail('incoming-request-two-same-name.email', ir.incoming_email)
- # XXX this is horrid, but don't know a better way. If we
+ # TODO: this is horrid, but don't know a better way. If we
# don't do this, the info_request_event to which the
# info_request is attached still uses the unmodified
# version from the fixture.
@@ -900,7 +900,7 @@ describe RequestController, "when handling prominence" do
end
-# XXX do this for invalid ids
+# TODO: do this for invalid ids
# it "should render 404 file" do
# response.should render_template("#{Rails.root}/public/404.html")
# response.headers["Status"].should == "404 Not Found"
@@ -1004,7 +1004,7 @@ describe RequestController, "when creating a new request" do
post :new, params
post_redirect = PostRedirect.get_last_post_redirect
response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
- # post_redirect.post_params.should == params # XXX get this working. there's a : vs '' problem amongst others
+ # post_redirect.post_params.should == params # TODO: get this working. there's a : vs '' problem amongst others
end
it 'redirects to the frontpage if the action is sent the invalid
@@ -1804,7 +1804,7 @@ describe RequestController, "when sending a followup message" do
session[:user_id] = users(:bob_smith_user).id
post :show_response, :outgoing_message => { :body => "", :what_doing => 'normal_sort'}, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_followup => 1
- # XXX how do I check the error message here?
+ # TODO: how do I check the error message here?
response.should render_template('show_response')
end
@@ -1854,13 +1854,13 @@ describe RequestController, "when sending a followup message" do
# second time should give an error
post :show_response, :outgoing_message => { :body => "Stop repeating yourself!", :what_doing => 'normal_sort' }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message), :submitted_followup => 1
- # XXX how do I check the error message here?
+ # TODO: how do I check the error message here?
response.should render_template('show_response')
end
end
-# XXX Stuff after here should probably be in request_mailer_spec.rb - but then
+# TODO: Stuff after here should probably be in request_mailer_spec.rb - but then
# it can't check the URLs in the emails I don't think, ugh.
describe RequestController, "sending overdue request alerts" do
@@ -1889,7 +1889,7 @@ describe RequestController, "sending overdue request alerts" do
mail_token = $2
session[:user_id].should be_nil
- controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link
+ controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link
session[:user_id].should == info_requests(:naughty_chicken_request).user.id
response.should render_template('show_response')
@@ -1946,7 +1946,7 @@ describe RequestController, "sending overdue request alerts" do
mail_token = $2
session[:user_id].should be_nil
- controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link
+ controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link
session[:user_id].should == info_requests(:naughty_chicken_request).user.id
response.should render_template('show_response')
@@ -2028,12 +2028,12 @@ describe RequestController, "sending unclassified new response reminder alerts"
mail_token = $2
session[:user_id].should be_nil
- controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link
+ controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link
session[:user_id].should == info_requests(:fancy_dog_request).user.id
response.should render_template('show')
assigns[:info_request].should == info_requests(:fancy_dog_request)
- # XXX should check anchor tag here :) that it goes to last new response
+ # TODO: should check anchor tag here :) that it goes to last new response
end
end
@@ -2064,7 +2064,7 @@ describe RequestController, "clarification required alerts" do
mail_token = $2
session[:user_id].should be_nil
- controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link
+ controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link
session[:user_id].should == info_requests(:fancy_dog_request).user.id
response.should render_template('show_response')
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index d2b45b6bf..29f5c7fe1 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -122,11 +122,11 @@ describe TrackController, "when sending alerts for a track" do
mail.body.should =~ /This a the daftest comment the world has ever seen/ # comment text included
# Check subscription managing link
-# XXX We can't do this, as it is redirecting to another controller. I'm
+# TODO: We can't do this, as it is redirecting to another controller. I'm
# apparently meant to be writing controller unit tests here, not functional
# tests. Bah, I so don't care, bit of an obsessive constraint.
# session[:user_id].should be_nil
-# controller.test_code_redirect_by_email_token(mail_token, self) # XXX hack to avoid having to call User controller for email link
+# controller.test_code_redirect_by_email_token(mail_token, self) # TODO: hack to avoid having to call User controller for email link
# session[:user_id].should == users(:silly_name_user).id
#
# response.should render_template('users/show')
@@ -173,7 +173,7 @@ describe TrackController, "when viewing RSS feed for a track" do
get :track_request, :feed => 'feed', :url_title => track_thing.info_request.url_title
response.should render_template('track/atom_feed')
response.content_type.should == 'application/atom+xml'
- # XXX should check it is an atom.builder type being rendered, not sure how to
+ # TODO: should check it is an atom.builder type being rendered, not sure how to
assigns[:xapian_object].matches_estimated.should == 3
assigns[:xapian_object].results.size.should == 3
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index cf361d898..6ecdf1ad4 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -1,7 +1,7 @@
# coding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-# XXX Use route_for or params_from to check /c/ links better
+# TODO: Use route_for or params_from to check /c/ links better
# http://rspec.rubyforge.org/rspec-rails/1.1.12/classes/Spec/Rails/Example/ControllerExampleGroup.html
describe UserController, "when redirecting a show request to a canonical url" do
@@ -327,7 +327,7 @@ describe UserController, "when signing up" do
deliveries[0].body.should match(/when\s+you\s+already\s+have\s+an/)
end
- # XXX need to do bob@localhost signup and check that sends different email
+ # TODO: need to do bob@localhost signup and check that sends different email
end
describe UserController, "when signing out" do
@@ -380,7 +380,7 @@ describe UserController, "when sending another user a message" do
mail = deliveries[0]
mail.body.should include("Bob Smith has used #{AlaveteliConfiguration::site_name} to send you the message below")
mail.body.should include("Just a test!")
- #mail.to_addrs.first.to_s.should == users(:silly_name_user).name_and_email # XXX fix some nastiness with quoting name_and_email
+ #mail.to_addrs.first.to_s.should == users(:silly_name_user).name_and_email # TODO: fix some nastiness with quoting name_and_email
mail.from_addrs.first.to_s.should == users(:bob_smith_user).email
end
@@ -651,7 +651,7 @@ describe UserController, "when using profile photos" do
@user.profile_photo.should_not be_nil
end
- # XXX todo check the two stage javascript cropping (above only tests one stage non-javascript one)
+ # TODO: todo check the two stage javascript cropping (above only tests one stage non-javascript one)
end
describe UserController, "when showing JSON version for API" do
diff --git a/spec/helpers/date_time_helper_spec.rb b/spec/helpers/date_time_helper_spec.rb
new file mode 100644
index 000000000..c4fdee1d1
--- /dev/null
+++ b/spec/helpers/date_time_helper_spec.rb
@@ -0,0 +1,71 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe DateTimeHelper do
+
+ include DateTimeHelper
+
+ describe :simple_date do
+
+ it 'formats a date in html by default' do
+ time = Time.utc(2012, 11, 07, 21, 30, 26)
+ self.should_receive(:simple_date_html).with(time)
+ simple_date(time)
+ end
+
+ it 'formats a date in the specified format' do
+ time = Time.utc(2012, 11, 07, 21, 30, 26)
+ self.should_receive(:simple_date_text).with(time)
+ simple_date(time, :format => :text)
+ end
+
+ it 'raises an argument error if given an unrecognized format' do
+ time = Time.utc(2012, 11, 07, 21, 30, 26)
+ expect { simple_date(time, :format => :unknown) }.to raise_error(ArgumentError)
+ end
+
+ end
+
+ describe :simple_date_html do
+
+ it 'formats a date in a time tag' do
+ Time.use_zone('London') do
+ time = Time.utc(2012, 11, 07, 21, 30, 26)
+ expected = %Q(<time datetime="2012-11-07T21:30:26+00:00" title="2012-11-07 21:30:26 +0000">November 07, 2012</time>)
+ simple_date_html(time).should == expected
+ end
+ end
+
+ end
+
+ describe :simple_date_text do
+
+ it 'should respect time zones' do
+ Time.use_zone('Australia/Sydney') do
+ simple_date_text(Time.utc(2012, 11, 07, 21, 30, 26)).should == 'November 08, 2012'
+ end
+ end
+
+ it 'should handle Date objects' do
+ simple_date_text(Date.new(2012, 11, 21)).should == 'November 21, 2012'
+ end
+
+ end
+
+ describe :simple_time do
+
+ it 'returns 00:00:00 for a date' do
+ simple_time(Date.new(2012, 11, 21)).should == '00:00:00'
+ end
+
+ it 'returns the time component of a datetime' do
+ date = DateTime.new(2012, 11, 21, 10, 34, 56)
+ simple_time(date).should == '10:34:56'
+ end
+
+ it 'returns the time component of a time' do
+ time = Time.utc(2000, 'jan', 1, 20, 15, 1)
+ simple_time(time).should == '20:15:01'
+ end
+
+ end
+end
diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb
index 4a01ec683..261e1ef3e 100644
--- a/spec/helpers/link_to_helper_spec.rb
+++ b/spec/helpers/link_to_helper_spec.rb
@@ -20,6 +20,82 @@ describe LinkToHelper do
end
+ describe 'when linking to new incoming messages' do
+
+ before do
+ @info_request = mock_model(InfoRequest, :id => 123, :url_title => 'test_title')
+ @incoming_message = mock_model(IncomingMessage, :id => 32, :info_request => @info_request)
+ end
+
+ context 'for external links' do
+
+ it 'generates the url to the info request of the message' do
+ incoming_message_url(@incoming_message).should include('http://test.host/request/test_title')
+ end
+
+ it 'includes an anchor to the new message' do
+ incoming_message_url(@incoming_message).should include('#incoming-32')
+ end
+
+ it 'does not cache by default' do
+ incoming_message_url(@incoming_message).should_not include('nocache=incoming-32')
+ end
+
+ it 'includes a cache busting parameter if set' do
+ incoming_message_url(@incoming_message, :cachebust => true).should include('nocache=incoming-32')
+ end
+
+ end
+
+ context 'for internal links' do
+
+ it 'generates the incoming_message_url with the path only' do
+ expected = '/request/test_title#incoming-32'
+ incoming_message_path(@incoming_message).should == expected
+ end
+
+ end
+
+ end
+
+ describe 'when linking to new outgoing messages' do
+
+ before do
+ @info_request = mock_model(InfoRequest, :id => 123, :url_title => 'test_title')
+ @outgoing_message = mock_model(OutgoingMessage, :id => 32, :info_request => @info_request)
+ end
+
+ context 'for external links' do
+
+ it 'generates the url to the info request of the message' do
+ outgoing_message_url(@outgoing_message).should include('http://test.host/request/test_title')
+ end
+
+ it 'includes an anchor to the new message' do
+ outgoing_message_url(@outgoing_message).should include('#outgoing-32')
+ end
+
+ it 'does not cache by default' do
+ outgoing_message_url(@outgoing_message).should_not include('nocache=outgoing-32')
+ end
+
+ it 'includes a cache busting parameter if set' do
+ outgoing_message_url(@outgoing_message, :cachebust => true).should include('nocache=outgoing-32')
+ end
+
+ end
+
+ context 'for internal links' do
+
+ it 'generates the outgoing_message_url with the path only' do
+ expected = '/request/test_title#outgoing-32'
+ outgoing_message_path(@outgoing_message).should == expected
+ end
+
+ end
+
+ end
+
describe 'when displaying a user link for a request' do
context "for external requests" do
@@ -69,51 +145,4 @@ describe LinkToHelper do
end
- describe 'simple_date' do
-
- it 'formats a date in html by default' do
- time = Time.utc(2012, 11, 07, 21, 30, 26)
- self.should_receive(:simple_date_html).with(time)
- simple_date(time)
- end
-
- it 'formats a date in the specified format' do
- time = Time.utc(2012, 11, 07, 21, 30, 26)
- self.should_receive(:simple_date_text).with(time)
- simple_date(time, :format => :text)
- end
-
- it 'raises an argument error if given an unrecognized format' do
- time = Time.utc(2012, 11, 07, 21, 30, 26)
- expect { simple_date(time, :format => :unknown) }.to raise_error(ArgumentError)
- end
-
- end
-
- describe 'simple_date_html' do
-
- it 'formats a date in a time tag' do
- Time.use_zone('London') do
- time = Time.utc(2012, 11, 07, 21, 30, 26)
- expected = "<time datetime=\"2012-11-07T21:30:26+00:00\" title=\"2012-11-07 21:30:26 +0000\">November 07, 2012</time>"
- simple_date_html(time).should == expected
- end
- end
-
- end
-
- describe 'simple_date_text' do
-
- it 'should respect time zones' do
- Time.use_zone('Australia/Sydney') do
- simple_date_text(Time.utc(2012, 11, 07, 21, 30, 26)).should == 'November 08, 2012'
- end
- end
-
- it 'should handle Date objects' do
- simple_date_text(Date.new(2012, 11, 21)).should == 'November 21, 2012'
- end
-
- end
-
end
diff --git a/spec/models/customstates.rb b/spec/models/customstates.rb
index bffbe86fb..942e1fcde 100644
--- a/spec/models/customstates.rb
+++ b/spec/models/customstates.rb
@@ -24,7 +24,7 @@ module InfoRequestCustomStates
end
def date_deadline_extended
- # XXX shouldn't this be 15 days after the date the status was
+ # TODO: shouldn't this be 15 days after the date the status was
# changed to "deadline extended"? Or perhaps 15 days ater the
# initial request due date?
return Holiday.due_date_from_working_days(self.date_response_required_by, 15)
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index 38e31783d..0e1db6986 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -493,7 +493,7 @@ describe PublicBody, " when loading CSV files" do
PublicBody.count.should == original_count + 3
- # XXX Not sure why trying to do a I18n.with_locale fails here. Seems related to
+ # TODO: Not sure why trying to do a I18n.with_locale fails here. Seems related to
# the way categories are loaded every time from the PublicBody class. For now we just
# test some translation was done.
body = PublicBody.find_by_name('North West Fake Authority')
diff --git a/spec/models/raw_email_spec.rb b/spec/models/raw_email_spec.rb
index f86b35e99..aa82b0bc3 100644
--- a/spec/models/raw_email_spec.rb
+++ b/spec/models/raw_email_spec.rb
@@ -23,7 +23,7 @@ describe User, "manipulating a raw email" do
@raw_email.data.should == "Hello, world!"
end
- # XXX this test fails, hopefully will be fixed in later Rails.
+ # TODO: this test fails, hopefully will be fixed in later Rails.
# Doesn't matter too much for us for storing raw_emails, it would seem,
# but keep an eye out.
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index c54043092..7dcd3ab8a 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -284,7 +284,7 @@ describe User, " when making name and email address" do
end
end
-# XXX not finished
+# TODO: not finished
describe User, "when setting a profile photo" do
before do
@user = User.new
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index e391c97d3..0e3fe35c7 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -123,7 +123,7 @@ Spork.prefork do
end
end
- # XXX No idea what namespace/class/module to put this in
+ # TODO: No idea what namespace/class/module to put this in
# Create a clean xapian index based on the fixture files and the raw_email data.
def create_fixtures_xapian_index
load_raw_emails_data