add specs for updating email settings in the controller, and user#mail
This commit is contained in:
parent
e9a843b095
commit
52b970098b
4 changed files with 23 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
5
spec/models/user_preference_spec.rb
Normal file
5
spec/models/user_preference_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe UserPreference do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue