diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bc9d69f1b..52a157ba8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,7 +30,6 @@ class UsersController < ApplicationController # change email notifications if u[:email_preferences] - pp u[:email_preferences] @user.update_user_preferences(u[:email_preferences]) flash[:notice] = I18n.t 'users.update.email_notifications_changed' # change passowrd diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 587376a35..93d885bc7 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -95,6 +95,24 @@ describe UsersController do @user.language.should_not == old_language end end + + describe 'email settings' do + it 'lets the user turn off mail' do + par = {:id => @user.id, :user => {:email_preferences => {'mentioned' => 'true'}}} + proc{ + put :update, par + }.should change(@user.user_preferences, :count).by(1) + end + + it 'lets the user get mail again' do + @user.user_preferences.create(:email_type => 'mentioned') + par = {:id => @user.id, :user => {:email_preferences => {'mentioned' => 'false'}}} + proc{ + put :update, par + }.should change(@user.user_preferences, :count).by(-1) + + end + end end describe '#edit' do diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb new file mode 100644 index 000000000..66613b87d --- /dev/null +++ b/spec/models/user_preference_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe UserPreference do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 151a165c6..bce2ffc5c 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -467,8 +467,6 @@ describe User do end it 'does not enqueue a mail job if the correct corresponding job has a prefrence entry' do - alice.save - alice.reload alice.user_preferences.create(:email_type => 'request_received') Resque.should_not_receive(:enqueue) alice.mail(Job::MailRequestReceived, alice.id, 'contactrequestid')