Fixed that locking and unlocking a user resets the email notification checkbox (#14020).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11839 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0dce4761a8
commit
10ed306b19
|
@ -53,7 +53,6 @@ class MyController < ApplicationController
|
||||||
if request.post?
|
if request.post?
|
||||||
@user.safe_attributes = params[:user]
|
@user.safe_attributes = params[:user]
|
||||||
@user.pref.attributes = params[:pref]
|
@user.pref.attributes = params[:pref]
|
||||||
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
|
||||||
if @user.save
|
if @user.save
|
||||||
@user.pref.save
|
@user.pref.save
|
||||||
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
|
|
|
@ -93,7 +93,6 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
if @user.save
|
if @user.save
|
||||||
@user.pref.attributes = params[:pref]
|
@user.pref.attributes = params[:pref]
|
||||||
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
|
||||||
@user.pref.save
|
@user.pref.save
|
||||||
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
|
||||||
|
|
||||||
|
@ -139,7 +138,6 @@ class UsersController < ApplicationController
|
||||||
was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE])
|
was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE])
|
||||||
# TODO: Similar to My#account
|
# TODO: Similar to My#account
|
||||||
@user.pref.attributes = params[:pref]
|
@user.pref.attributes = params[:pref]
|
||||||
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
|
||||||
|
|
||||||
if @user.save
|
if @user.save
|
||||||
@user.pref.save
|
@user.pref.save
|
||||||
|
|
|
@ -390,7 +390,7 @@ class Mailer < ActionMailer::Base
|
||||||
|
|
||||||
# Removes the author from the recipients and cc
|
# Removes the author from the recipients and cc
|
||||||
# if he doesn't want to receive notifications about what he does
|
# if he doesn't want to receive notifications about what he does
|
||||||
if @author && @author.logged? && @author.pref[:no_self_notified]
|
if @author && @author.logged? && @author.pref.no_self_notified
|
||||||
headers[:to].delete(@author.mail) if headers[:to].is_a?(Array)
|
headers[:to].delete(@author.mail) if headers[:to].is_a?(Array)
|
||||||
headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array)
|
headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array)
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,4 +56,7 @@ class UserPreference < ActiveRecord::Base
|
||||||
|
|
||||||
def warn_on_leaving_unsaved; self[:warn_on_leaving_unsaved] || '1'; end
|
def warn_on_leaving_unsaved; self[:warn_on_leaving_unsaved] || '1'; end
|
||||||
def warn_on_leaving_unsaved=(value); self[:warn_on_leaving_unsaved]=value; end
|
def warn_on_leaving_unsaved=(value); self[:warn_on_leaving_unsaved]=value; end
|
||||||
|
|
||||||
|
def no_self_notified; (self[:no_self_notified] == true || self[:no_self_notified] == '1'); end
|
||||||
|
def no_self_notified=(value); self[:no_self_notified]=value; end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,9 +19,10 @@
|
||||||
end %>
|
end %>
|
||||||
<p><em class="info"><%= l(:text_user_mail_option) %></em></p>
|
<p><em class="info"><%= l(:text_user_mail_option) %></em></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= fields_for :pref, @user.pref do |pref_fields| %>
|
||||||
<p>
|
<p>
|
||||||
<label>
|
<%= pref_fields.check_box :no_self_notified %>
|
||||||
<%= l(:label_user_mail_no_self_notified) %>
|
<label for="pref_no_self_notified"><%= l(:label_user_mail_no_self_notified) %></label>
|
||||||
<%= check_box_tag 'no_self_notified', 1, @user.pref[:no_self_notified] %>
|
|
||||||
</label>
|
|
||||||
</p>
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -83,7 +83,7 @@ class AdminControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_test_email
|
def test_test_email
|
||||||
user = User.find(1)
|
user = User.find(1)
|
||||||
user.pref[:no_self_notified] = '1'
|
user.pref.no_self_notified = '1'
|
||||||
user.pref.save!
|
user.pref.save!
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,18 @@ class UsersControllerTest < ActionController::TestCase
|
||||||
assert_equal [1, 2], u.notified_projects_ids.sort
|
assert_equal [1, 2], u.notified_projects_ids.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_update_status_should_not_update_attributes
|
||||||
|
user = User.find(2)
|
||||||
|
user.pref[:no_self_notified] = '1'
|
||||||
|
user.pref.save
|
||||||
|
|
||||||
|
put :update, :id => 2, :user => {:status => 3}
|
||||||
|
assert_response 302
|
||||||
|
user = User.find(2)
|
||||||
|
assert_equal 3, user.status
|
||||||
|
assert_equal '1', user.pref[:no_self_notified]
|
||||||
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
assert_difference 'User.count', -1 do
|
assert_difference 'User.count', -1 do
|
||||||
delete :destroy, :id => 2
|
delete :destroy, :id => 2
|
||||||
|
|
|
@ -215,14 +215,14 @@ class MailerTest < ActiveSupport::TestCase
|
||||||
# Remove members except news author
|
# Remove members except news author
|
||||||
news.project.memberships.each {|m| m.destroy unless m.user == user}
|
news.project.memberships.each {|m| m.destroy unless m.user == user}
|
||||||
|
|
||||||
user.pref[:no_self_notified] = false
|
user.pref.no_self_notified = false
|
||||||
user.pref.save
|
user.pref.save
|
||||||
User.current = user
|
User.current = user
|
||||||
Mailer.news_added(news.reload).deliver
|
Mailer.news_added(news.reload).deliver
|
||||||
assert_equal 1, last_email.bcc.size
|
assert_equal 1, last_email.bcc.size
|
||||||
|
|
||||||
# nobody to notify
|
# nobody to notify
|
||||||
user.pref[:no_self_notified] = true
|
user.pref.no_self_notified = true
|
||||||
user.pref.save
|
user.pref.save
|
||||||
User.current = user
|
User.current = user
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
|
@ -296,7 +296,7 @@ class MailerTest < ActiveSupport::TestCase
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
user = User.find(9)
|
user = User.find(9)
|
||||||
# minimal email notification options
|
# minimal email notification options
|
||||||
user.pref[:no_self_notified] = '1'
|
user.pref.no_self_notified = '1'
|
||||||
user.pref.save
|
user.pref.save
|
||||||
user.mail_notification = false
|
user.mail_notification = false
|
||||||
user.save
|
user.save
|
||||||
|
|
Loading…
Reference in New Issue