From 27128cd0d9a4ae69c8f2cfadd52e0ab078acffec Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 10 Mar 2014 17:46:39 +0000 Subject: Add formatting options to LinkToHelper#simple_date --- spec/helpers/link_to_helper_spec.rb | 40 +++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'spec/helpers') diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb index 2259db6c2..4a01ec683 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -70,14 +70,50 @@ 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 = "" + 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(Time.utc(2012, 11, 07, 21, 30, 26)).should == 'November 08, 2012' + 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(Date.new(2012, 11, 21)).should == 'November 21, 2012' + simple_date_text(Date.new(2012, 11, 21)).should == 'November 21, 2012' end + end + end -- cgit v1.2.3 From d166680e1f0bc534fe758cd313456e584f55b26f Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Fri, 28 Feb 2014 17:20:31 +0000 Subject: Refactor event description to make it easier to translate. Closes #1313 and #365. --- spec/helpers/application_helper_spec.rb | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spec/helpers/application_helper_spec.rb (limited to 'spec/helpers') diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb new file mode 100644 index 000000000..6407eaf3a --- /dev/null +++ b/spec/helpers/application_helper_spec.rb @@ -0,0 +1,34 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe ApplicationHelper do + + include ApplicationHelper + include LinkToHelper + + describe 'when creating an event description' do + + it 'should generate a description for a request' do + @info_request = FactoryGirl.create(:info_request) + @sent_event = @info_request.get_last_event + expected = "Request sent to #{public_body_link_absolute(@info_request.public_body)} by #{request_user_link_absolute(@info_request)}" + event_description(@sent_event).should match(expected) + + end + + it 'should generate a description for a response' do + @info_request_with_incoming = FactoryGirl.create(:info_request_with_incoming) + @response_event = @info_request_with_incoming.get_last_event + expected = "Response by #{public_body_link_absolute(@info_request_with_incoming.public_body)} to #{request_user_link_absolute(@info_request_with_incoming)}" + event_description(@response_event).should match(expected) + end + + it 'should generate a description for a request where an internal review has been requested' do + @info_request_with_internal_review_request = FactoryGirl.create(:info_request_with_internal_review_request) + @response_event = @info_request_with_internal_review_request.get_last_event + expected = "Internal review request sent to #{public_body_link_absolute(@info_request_with_internal_review_request.public_body)} by #{request_user_link_absolute(@info_request_with_internal_review_request)}" + event_description(@response_event).should match(expected) + end + + end + +end -- cgit v1.2.3 From aec70771b7029f8c312e779a6e7fa6d5537abbed Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 17 Mar 2014 17:26:49 +0000 Subject: Add notices for subscribing something you're subscribed to. These notices are full sentences, rather than being composed of phrases, which should make them easier to translate. --- spec/helpers/track_helper_spec.rb | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 spec/helpers/track_helper_spec.rb (limited to 'spec/helpers') diff --git a/spec/helpers/track_helper_spec.rb b/spec/helpers/track_helper_spec.rb new file mode 100644 index 000000000..a009f87ac --- /dev/null +++ b/spec/helpers/track_helper_spec.rb @@ -0,0 +1,86 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe TrackHelper do + + include TrackHelper + include LinkToHelper + + describe 'when displaying notices for a search track' do + + before do + @track_thing = FactoryGirl.build(:search_track) + end + + it 'should create an already subscribed_notice' do + expected = %Q(You are already subscribed to this search) + already_subscribed_notice(@track_thing).should == expected + end + + end + + describe 'when displaying notices for a user track' do + + before do + @track_thing = FactoryGirl.build(:user_track) + end + + it 'should create an already subscribed_notice' do + expected = %Q(You are already subscribed to '#{user_link(@track_thing.tracked_user)}', a person) + already_subscribed_notice(@track_thing).should == expected + end + + end + + describe 'when displaying notices for a public body track' do + + before do + @track_thing = FactoryGirl.build(:public_body_track) + end + + it 'should create an already subscribed_notice' do + expected = %Q(You are already subscribed to '#{public_body_link(@track_thing.public_body)}', a public authority) + already_subscribed_notice(@track_thing).should == expected + end + + end + + describe 'when displaying notices for a successful request track' do + + before do + @track_thing = FactoryGirl.build(:successful_request_track) + end + + it 'should create an already subscribed_notice' do + expected = %Q(You are already subscribed to any successful requests) + already_subscribed_notice(@track_thing).should == expected + end + + end + + describe 'when displaying notices for a new request track' do + + before do + @track_thing = FactoryGirl.build(:new_request_track) + end + + it 'should create an already subscribed_notice' do + expected = %Q(You are already subscribed to any new requests) + already_subscribed_notice(@track_thing).should == expected + end + + end + + describe 'when displaying notices for a request update track' do + + before do + @track_thing = FactoryGirl.build(:request_update_track) + end + + it 'should create an already subscribed_notice' do + expected = %Q(You are already subscribed to '#{request_link(@track_thing.info_request)}', a request) + already_subscribed_notice(@track_thing).should == expected + end + + end + +end -- cgit v1.2.3 From a00067262fd7171a39e74a4ebcd75a5758e12ee6 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 17 Mar 2014 17:30:34 +0000 Subject: Add notices for subscribing to something. These notices are complete sentences, not composed on the fly, so should be easier to translate. --- spec/helpers/track_helper_spec.rb | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'spec/helpers') diff --git a/spec/helpers/track_helper_spec.rb b/spec/helpers/track_helper_spec.rb index a009f87ac..d2c277993 100644 --- a/spec/helpers/track_helper_spec.rb +++ b/spec/helpers/track_helper_spec.rb @@ -16,6 +16,16 @@ describe TrackHelper do already_subscribed_notice(@track_thing).should == expected end + it 'should create an email subscription notice' do + expected = %Q(You will now be emailed updates about this search) + subscribe_email_notice(@track_thing).should == expected + end + + it 'should create a following subscription notice' do + expected = %Q(You are now following updates about this search) + subscribe_follow_notice(@track_thing).should == expected + end + end describe 'when displaying notices for a user track' do @@ -29,6 +39,16 @@ describe TrackHelper do already_subscribed_notice(@track_thing).should == expected end + it 'should create an email subscription notice' do + expected = %Q(You will now be emailed updates about '#{user_link(@track_thing.tracked_user)}', a person) + subscribe_email_notice(@track_thing).should == expected + end + + it 'should create a following subscription notice' do + expected = %Q(You are now following updates about '#{user_link(@track_thing.tracked_user)}', a person) + subscribe_follow_notice(@track_thing).should == expected + end + end describe 'when displaying notices for a public body track' do @@ -42,6 +62,16 @@ describe TrackHelper do already_subscribed_notice(@track_thing).should == expected end + it 'should create an email subscription notice' do + expected = %Q(You will now be emailed updates about '#{public_body_link(@track_thing.public_body)}', a public authority) + subscribe_email_notice(@track_thing).should == expected + end + + it 'should create a following subscription notice' do + expected = %Q(You are now following updates about '#{public_body_link(@track_thing.public_body)}', a public authority) + subscribe_follow_notice(@track_thing).should == expected + end + end describe 'when displaying notices for a successful request track' do @@ -55,6 +85,16 @@ describe TrackHelper do already_subscribed_notice(@track_thing).should == expected end + it 'should create an email subscription notice' do + expected = %Q(You will now be emailed updates about successful requests) + subscribe_email_notice(@track_thing).should == expected + end + + it 'should create a following subscription notice' do + expected = %Q(You are now following updates about successful requests) + subscribe_follow_notice(@track_thing).should == expected + end + end describe 'when displaying notices for a new request track' do @@ -68,6 +108,16 @@ describe TrackHelper do already_subscribed_notice(@track_thing).should == expected end + it 'should create an email subscription notice' do + expected = %Q(You will now be emailed updates about any new requests) + subscribe_email_notice(@track_thing).should == expected + end + + it 'should create a following subscription notice' do + expected = %Q(You are now following updates about new requests) + subscribe_follow_notice(@track_thing).should == expected + end + end describe 'when displaying notices for a request update track' do @@ -81,6 +131,16 @@ describe TrackHelper do already_subscribed_notice(@track_thing).should == expected end + it 'should create an email subscription notice' do + expected = %Q(You will now be emailed updates about '#{request_link(@track_thing.info_request)}', a request) + subscribe_email_notice(@track_thing).should == expected + end + + it 'should create a following subscription notice' do + expected = %Q(You are now following updates about '#{request_link(@track_thing.info_request)}', a request) + subscribe_follow_notice(@track_thing).should == expected + end + end end -- cgit v1.2.3 From 5cb467c469d9a34336da483e47b931c9dd5b9078 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 17 Mar 2014 17:32:02 +0000 Subject: Add notices for unsubscribing from things. These are full sentences, not composed on the fly, so should be easier to translate. --- spec/helpers/track_helper_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'spec/helpers') diff --git a/spec/helpers/track_helper_spec.rb b/spec/helpers/track_helper_spec.rb index d2c277993..bd4be5c3e 100644 --- a/spec/helpers/track_helper_spec.rb +++ b/spec/helpers/track_helper_spec.rb @@ -26,6 +26,11 @@ describe TrackHelper do subscribe_follow_notice(@track_thing).should == expected end + it 'should create an unsubscribe notice' do + expected = %Q(You are no longer following this search) + unsubscribe_notice(@track_thing).should == expected + end + end describe 'when displaying notices for a user track' do @@ -49,6 +54,11 @@ describe TrackHelper do subscribe_follow_notice(@track_thing).should == expected end + it 'should create an unsubscribe notice' do + expected = %Q(You are no longer following '#{user_link(@track_thing.tracked_user)}', a person) + unsubscribe_notice(@track_thing).should == expected + end + end describe 'when displaying notices for a public body track' do @@ -72,6 +82,10 @@ describe TrackHelper do subscribe_follow_notice(@track_thing).should == expected end + it 'should create an unsubscribe notice' do + expected = %Q(You are no longer following '#{public_body_link(@track_thing.public_body)}', a public authority) + unsubscribe_notice(@track_thing).should == expected + end end describe 'when displaying notices for a successful request track' do @@ -95,6 +109,11 @@ describe TrackHelper do subscribe_follow_notice(@track_thing).should == expected end + it 'should create an unsubscribe notice' do + expected = %Q(You are no longer following successful requests) + unsubscribe_notice(@track_thing).should == expected + end + end describe 'when displaying notices for a new request track' do @@ -118,6 +137,11 @@ describe TrackHelper do subscribe_follow_notice(@track_thing).should == expected end + it 'should create an unsubscribe notice' do + expected = %Q(You are no longer following new requests) + unsubscribe_notice(@track_thing).should == expected + end + end describe 'when displaying notices for a request update track' do @@ -141,6 +165,11 @@ describe TrackHelper do subscribe_follow_notice(@track_thing).should == expected end + it 'should create an unsubscribe notice' do + expected = %Q(You are no longer following '#{request_link(@track_thing.info_request)}', a request) + unsubscribe_notice(@track_thing).should == expected + end + end end -- cgit v1.2.3 From 5ac63b9c812fc914fd52de7dae813e1bb5f0f36e Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 17 Mar 2014 17:35:21 +0000 Subject: Move track descriptions to a helper. We can access url generation methods more easily here. --- spec/helpers/track_helper_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'spec/helpers') diff --git a/spec/helpers/track_helper_spec.rb b/spec/helpers/track_helper_spec.rb index bd4be5c3e..80857067b 100644 --- a/spec/helpers/track_helper_spec.rb +++ b/spec/helpers/track_helper_spec.rb @@ -31,6 +31,11 @@ describe TrackHelper do unsubscribe_notice(@track_thing).should == expected end + it 'should create a description of the track' do + expected = %Q(anything matching text 'Example Query') + track_description(@track_thing).should == expected + end + end describe 'when displaying notices for a user track' do @@ -59,6 +64,11 @@ describe TrackHelper do unsubscribe_notice(@track_thing).should == expected end + it 'should create a description of the track' do + expected = %Q('#{user_link(@track_thing.tracked_user)}', a person) + track_description(@track_thing).should == expected + end + end describe 'when displaying notices for a public body track' do @@ -86,6 +96,11 @@ describe TrackHelper do expected = %Q(You are no longer following '#{public_body_link(@track_thing.public_body)}', a public authority) unsubscribe_notice(@track_thing).should == expected end + + it 'should create a description of the track' do + expected = %Q('#{public_body_link(@track_thing.public_body)}', a public authority) + track_description(@track_thing).should == expected + end end describe 'when displaying notices for a successful request track' do @@ -114,6 +129,10 @@ describe TrackHelper do unsubscribe_notice(@track_thing).should == expected end + it 'should create a description of the track' do + expected = %Q(successful requests) + track_description(@track_thing).should == expected + end end describe 'when displaying notices for a new request track' do @@ -142,6 +161,11 @@ describe TrackHelper do unsubscribe_notice(@track_thing).should == expected end + it 'should create a description of the track' do + expected = %Q(new requests) + track_description(@track_thing).should == expected + end + end describe 'when displaying notices for a request update track' do @@ -170,6 +194,11 @@ describe TrackHelper do unsubscribe_notice(@track_thing).should == expected end + it 'should create a description of the track' do + expected = %Q('#{request_link(@track_thing.info_request)}', a request) + track_description(@track_thing).should == expected + end + end end -- cgit v1.2.3 From eff755504d45bfeff415786dcd0dbbb4c47e8dd0 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 14 Mar 2014 11:47:52 +0000 Subject: Add AdminHelper#comment_visibility Get the canonical human-readable status of a comment --- spec/helpers/admin_helper_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/helpers/admin_helper_spec.rb (limited to 'spec/helpers') diff --git a/spec/helpers/admin_helper_spec.rb b/spec/helpers/admin_helper_spec.rb new file mode 100644 index 000000000..804fcc7fd --- /dev/null +++ b/spec/helpers/admin_helper_spec.rb @@ -0,0 +1,21 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe AdminHelper do + + include AdminHelper + + describe :comment_visibility do + + it 'shows the status of a visible comment' do + comment = Factory.build(:visible_comment) + comment_visibility(comment).should == 'Visible' + end + + it 'shows the status of a hidden comment' do + comment = Factory.build(:hidden_comment) + comment_visibility(comment).should == 'Hidden' + end + + end + +end -- cgit v1.2.3 From b3fa23047bf96bd6a08273c9491ac1ee3b4a3f80 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 15 May 2014 16:02:56 +0100 Subject: Update specs for changes to translations in 962e1d2b0edb6c0933ba42dd7690c38ba7d08f91 --- spec/helpers/track_helper_spec.rb | 48 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'spec/helpers') diff --git a/spec/helpers/track_helper_spec.rb b/spec/helpers/track_helper_spec.rb index 80857067b..b6252ab39 100644 --- a/spec/helpers/track_helper_spec.rb +++ b/spec/helpers/track_helper_spec.rb @@ -12,22 +12,22 @@ describe TrackHelper do end it 'should create an already subscribed_notice' do - expected = %Q(You are already subscribed to this search) + expected = %Q(You are already subscribed to this search.) already_subscribed_notice(@track_thing).should == expected end it 'should create an email subscription notice' do - expected = %Q(You will now be emailed updates about this search) + expected = %Q(You will now be emailed updates about this search.) subscribe_email_notice(@track_thing).should == expected end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about this search) + expected = %Q(You are now following updates about this search.) subscribe_follow_notice(@track_thing).should == expected end it 'should create an unsubscribe notice' do - expected = %Q(You are no longer following this search) + expected = %Q(You are no longer following this search.) unsubscribe_notice(@track_thing).should == expected end @@ -45,22 +45,22 @@ describe TrackHelper do end it 'should create an already subscribed_notice' do - expected = %Q(You are already subscribed to '#{user_link(@track_thing.tracked_user)}', a person) + expected = %Q(You are already subscribed to '#{user_link(@track_thing.tracked_user)}', a person.) already_subscribed_notice(@track_thing).should == expected end it 'should create an email subscription notice' do - expected = %Q(You will now be emailed updates about '#{user_link(@track_thing.tracked_user)}', a person) + expected = %Q(You will now be emailed updates about '#{user_link(@track_thing.tracked_user)}', a person.) subscribe_email_notice(@track_thing).should == expected end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about '#{user_link(@track_thing.tracked_user)}', a person) + expected = %Q(You are now following updates about '#{user_link(@track_thing.tracked_user)}', a person.) subscribe_follow_notice(@track_thing).should == expected end it 'should create an unsubscribe notice' do - expected = %Q(You are no longer following '#{user_link(@track_thing.tracked_user)}', a person) + expected = %Q(You are no longer following '#{user_link(@track_thing.tracked_user)}', a person.) unsubscribe_notice(@track_thing).should == expected end @@ -78,22 +78,22 @@ describe TrackHelper do end it 'should create an already subscribed_notice' do - expected = %Q(You are already subscribed to '#{public_body_link(@track_thing.public_body)}', a public authority) + expected = %Q(You are already subscribed to '#{public_body_link(@track_thing.public_body)}', a public authority.) already_subscribed_notice(@track_thing).should == expected end it 'should create an email subscription notice' do - expected = %Q(You will now be emailed updates about '#{public_body_link(@track_thing.public_body)}', a public authority) + expected = %Q(You will now be emailed updates about '#{public_body_link(@track_thing.public_body)}', a public authority.) subscribe_email_notice(@track_thing).should == expected end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about '#{public_body_link(@track_thing.public_body)}', a public authority) + expected = %Q(You are now following updates about '#{public_body_link(@track_thing.public_body)}', a public authority.) subscribe_follow_notice(@track_thing).should == expected end it 'should create an unsubscribe notice' do - expected = %Q(You are no longer following '#{public_body_link(@track_thing.public_body)}', a public authority) + expected = %Q(You are no longer following '#{public_body_link(@track_thing.public_body)}', a public authority.) unsubscribe_notice(@track_thing).should == expected end @@ -110,22 +110,22 @@ describe TrackHelper do end it 'should create an already subscribed_notice' do - expected = %Q(You are already subscribed to any successful requests) + expected = %Q(You are already subscribed to any successful requests.) already_subscribed_notice(@track_thing).should == expected end it 'should create an email subscription notice' do - expected = %Q(You will now be emailed updates about successful requests) + expected = %Q(You will now be emailed updates about successful requests.) subscribe_email_notice(@track_thing).should == expected end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about successful requests) + expected = %Q(You are now following updates about successful requests.) subscribe_follow_notice(@track_thing).should == expected end it 'should create an unsubscribe notice' do - expected = %Q(You are no longer following successful requests) + expected = %Q(You are no longer following successful requests.) unsubscribe_notice(@track_thing).should == expected end @@ -142,22 +142,22 @@ describe TrackHelper do end it 'should create an already subscribed_notice' do - expected = %Q(You are already subscribed to any new requests) + expected = %Q(You are already subscribed to any new requests.) already_subscribed_notice(@track_thing).should == expected end it 'should create an email subscription notice' do - expected = %Q(You will now be emailed updates about any new requests) + expected = %Q(You will now be emailed updates about any new requests.) subscribe_email_notice(@track_thing).should == expected end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about new requests) + expected = %Q(You are now following updates about new requests.) subscribe_follow_notice(@track_thing).should == expected end it 'should create an unsubscribe notice' do - expected = %Q(You are no longer following new requests) + expected = %Q(You are no longer following new requests.) unsubscribe_notice(@track_thing).should == expected end @@ -175,22 +175,22 @@ describe TrackHelper do end it 'should create an already subscribed_notice' do - expected = %Q(You are already subscribed to '#{request_link(@track_thing.info_request)}', a request) + expected = %Q(You are already subscribed to '#{request_link(@track_thing.info_request)}', a request.) already_subscribed_notice(@track_thing).should == expected end it 'should create an email subscription notice' do - expected = %Q(You will now be emailed updates about '#{request_link(@track_thing.info_request)}', a request) + expected = %Q(You will now be emailed updates about '#{request_link(@track_thing.info_request)}', a request.) subscribe_email_notice(@track_thing).should == expected end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about '#{request_link(@track_thing.info_request)}', a request) + expected = %Q(You are now following updates about '#{request_link(@track_thing.info_request)}', a request.) subscribe_follow_notice(@track_thing).should == expected end it 'should create an unsubscribe notice' do - expected = %Q(You are no longer following '#{request_link(@track_thing.info_request)}', a request) + expected = %Q(You are no longer following '#{request_link(@track_thing.info_request)}', a request.) unsubscribe_notice(@track_thing).should == expected end -- cgit v1.2.3