diff options
-rw-r--r-- | app/controllers/track_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/track_helper.rb | 23 | ||||
-rw-r--r-- | spec/helpers/track_helper_spec.rb | 29 |
3 files changed, 53 insertions, 1 deletions
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index c861971bd..dccc52efc 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -179,7 +179,7 @@ class TrackController < ApplicationController new_medium = params[:track_medium] if new_medium == 'delete' track_thing.destroy - flash[:notice] = _("You are no longer following {{track_description}}.", :track_description => track_thing.params[:list_description]) + flash[:notice] = view_context.unsubscribe_notice(track_thing) redirect_to URI.parse(params[:r]).path else raise "new medium not handled " + new_medium diff --git a/app/helpers/track_helper.rb b/app/helpers/track_helper.rb index 49209d6bc..5038cf5e8 100644 --- a/app/helpers/track_helper.rb +++ b/app/helpers/track_helper.rb @@ -76,4 +76,27 @@ module TrackHelper end end + def unsubscribe_notice(track_thing) + case track_thing.track_type + when 'request_updates' + _("You are no longer following '{{link_to_request}}', a request", + :link_to_request => request_link(track_thing.info_request)) + when 'all_new_requests' + _('You are no longer following <a href="{{new_requests_url}}">new requests</a>', + :new_requests_url => request_list_path) + when 'all_successful_requests' + _('You are no longer following <a href="{{successful_requests_url}}">successful requests</a>', + :successful_requests_url => request_list_successful_path ) + when 'public_body_updates' + _("You are no longer following '{{link_to_authority}}', a public authority", + :link_to_authority => public_body_link(track_thing.public_body)) + when 'user_updates' + _("You are no longer following '{{link_to_user}}', a person", + :link_to_user => user_link(track_thing.tracked_user)) + when 'search_query' + _('You are no longer following <a href="{{search_url}}">this search</a>', + :search_url => search_path([track_thing.track_query, 'newest', 'advanced'])) + end + end + end 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 <a href="/search/Example%20Query/newest/advanced">this search</a>) + 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 <a href="/list/successful">successful requests</a>) + 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 <a href="/list">new requests</a>) + 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 |