aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/track_mailer.rb4
-rw-r--r--app/views/user/show.rhtml2
-rw-r--r--spec/controllers/track_controller_spec.rb9
3 files changed, 11 insertions, 4 deletions
diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb
index 9863cbe68..792191bd9 100644
--- a/app/models/track_mailer.rb
+++ b/app/models/track_mailer.rb
@@ -4,12 +4,12 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: track_mailer.rb,v 1.15 2009-03-06 19:50:25 francis Exp $
+# $Id: track_mailer.rb,v 1.16 2009-03-17 23:22:01 francis Exp $
class TrackMailer < ApplicationMailer
def event_digest(user, email_about_things)
post_redirect = PostRedirect.new(
- :uri => main_url(user_url(user)),
+ :uri => main_url(user_url(user)) + "#email_subscriptions",
:user_id => user.id)
post_redirect.save!
unsubscribe_url = confirm_url(:email_token => post_redirect.email_token)
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index f78fcffe0..4e895f2e2 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -102,7 +102,7 @@
<% end %>
<% if @is_you and not @track_things.empty? %>
- <h2>
+ <h2 id="email_subscriptions">
Your <%=pluralize(@track_things.size, "email subscription") %>
<% if @track_things_grouped.size == 1 %>
<% form_tag :controller => 'track', :action => 'delete_all_type' do %>
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 1e273b3fe..a2092acc0 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -23,6 +23,7 @@ end
describe TrackController, "when sending alerts for a track" do
integrate_views
fixtures :info_requests, :outgoing_messages, :incoming_messages, :raw_emails, :info_request_events, :users, :track_things, :track_things_sent_emails
+ include LinkToHelper # for main_url
it "should send alerts" do
TrackMailer.alert_tracks
@@ -39,7 +40,8 @@ describe TrackController, "when sending alerts for a track" do
mail.body.should_not =~ /&amp;/
# Check subscription managing link
-# XXX reenable this if we ever have a page manager in the track controller
+# XXX We can't do this, as it is redirecting to another control, so this is a
+# functional test. 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
# session[:user_id].should == users(:silly_name_user).id
@@ -47,6 +49,11 @@ describe TrackController, "when sending alerts for a track" do
# response.should render_template('users/show')
# assigns[:display_user].should == users(:silly_name_user)
+ # Given we can't click the link, check the token is right instead
+ post_redirect = PostRedirect.find_by_email_token(mail_token)
+ expected_url = main_url("/user/" + users(:silly_name_user).url_name + "#email_subscriptions") # XXX can't call URL making functions here, what is correct way to do this?
+ post_redirect.uri.should == expected_url
+
# Check nothing more is delivered if we try again
deliveries.clear
TrackMailer.alert_tracks