add specs for updating email settings in the controller, and user#mail

This commit is contained in:
maxwell 2011-03-11 14:46:23 -08:00
parent e9a843b095
commit 52b970098b
4 changed files with 23 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,5 @@
require 'spec_helper'
describe UserPreference do
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -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')