diff options
-rw-r--r-- | app/controllers/user_controller.rb | 2 | ||||
-rw-r--r-- | app/views/user/_change_receive_email.rhtml | 2 | ||||
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 9 | ||||
-rw-r--r-- | spec/fixtures/users.yml | 5 |
4 files changed, 17 insertions, 1 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index ef013ad1e..e56c4dd33 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -588,7 +588,7 @@ class UserController < ApplicationController end @user.receive_email_alerts = params[:receive_email_alerts] @user.save! - redirect_to request.headers['HTTP_REFERER'] + redirect_to params[:came_from] end private diff --git a/app/views/user/_change_receive_email.rhtml b/app/views/user/_change_receive_email.rhtml index 78d847038..83e5d8601 100644 --- a/app/views/user/_change_receive_email.rhtml +++ b/app/views/user/_change_receive_email.rhtml @@ -3,10 +3,12 @@ <% if @user.receive_email_alerts %> <%= _('You are currently receiving notification of new activity on your wall by email.', :wall_url => show_user_wall_path) %><br><br> <%= hidden_field_tag 'receive_email_alerts', 'false' %> + <%= hidden_field_tag 'came_from', request.url %> <%= submit_tag _("Turn off email alerts") %> <% else %> <%= _('Items matching the following conditions are currently displayed on your wall.') %><br><br> <%= hidden_field_tag 'receive_email_alerts', 'true' %> + <%= hidden_field_tag 'came_from', request.url %> <%= submit_tag _("Also send me alerts by email") %> <% end %> </div> diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 37b8b33dc..7a6c9ac0d 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -658,4 +658,13 @@ describe UserController, "when viewing the wall" do assigns[:feed_results][0].should_not == ire end + it "should allow users to turn their own email alerts on and off" do + user = users(:silly_name_user) + session[:user_id] = user.id + user.receive_email_alerts.should == true + get :set_receive_email_alerts, :receive_email_alerts => 'false', :came_from => "/" + user.reload + user.receive_email_alerts.should_not == true + end + end diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml index 8620fb3de..d6391c5e8 100644 --- a/spec/fixtures/users.yml +++ b/spec/fixtures/users.yml @@ -12,6 +12,7 @@ bob_smith_user: ban_text: '' locale: 'en' about_me: 'I like making requests about fancy dogs and naughty chickens and stuff.' + receive_email_alerts: true silly_name_user: id: "2" name: "Silly <em>Name</em>" @@ -26,6 +27,7 @@ silly_name_user: ban_text: '' locale: 'en' about_me: '' + receive_email_alerts: true admin_user: id: "3" name: Joe Admin @@ -40,6 +42,7 @@ admin_user: ban_text: '' locale: '' about_me: '' + receive_email_alerts: true unconfirmed_user: id: "4" name: "Unconfirmed" @@ -53,6 +56,7 @@ unconfirmed_user: admin_level: 'none' ban_text: '' about_me: '' + receive_email_alerts: true robin_user: id: 5 name: Robin Houston @@ -66,3 +70,4 @@ robin_user: admin_level: 'none' ban_text: '' about_me: 'I am the best' + receive_email_alerts: true |