Fixed that preferences are not preserved when adding a user fails (#15552).
git-svn-id: http://svn.redmine.org/redmine/trunk@12350 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e494983e1f
commit
6032263d9b
@ -90,11 +90,9 @@ class UsersController < ApplicationController
|
|||||||
@user.admin = params[:user][:admin] || false
|
@user.admin = params[:user][:admin] || false
|
||||||
@user.login = params[:user][:login]
|
@user.login = params[:user][:login]
|
||||||
@user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation] unless @user.auth_source_id
|
@user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation] unless @user.auth_source_id
|
||||||
|
@user.pref.attributes = params[:pref]
|
||||||
|
|
||||||
if @user.save
|
if @user.save
|
||||||
@user.pref.attributes = params[:pref]
|
|
||||||
@user.pref.save
|
|
||||||
|
|
||||||
Mailer.account_information(@user, @user.password).deliver if params[:send_information]
|
Mailer.account_information(@user, @user.password).deliver if params[:send_information]
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -250,6 +250,25 @@ class UsersControllerTest < ActionController::TestCase
|
|||||||
assert_template 'new'
|
assert_template 'new'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_create_with_failure_sould_preserve_preference
|
||||||
|
assert_no_difference 'User.count' do
|
||||||
|
post :create,
|
||||||
|
:user => {},
|
||||||
|
:pref => {
|
||||||
|
'no_self_notified' => '1',
|
||||||
|
'hide_mail' => '1',
|
||||||
|
'time_zone' => 'Paris',
|
||||||
|
'comments_sorting' => 'desc',
|
||||||
|
'warn_on_leaving_unsaved' => '0'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'new'
|
||||||
|
|
||||||
|
assert_select 'select#pref_time_zone option[selected=selected]', :text => /Paris/
|
||||||
|
assert_select 'input#pref_no_self_notified[value=1][checked=checked]'
|
||||||
|
end
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
get :edit, :id => 2
|
get :edit, :id => 2
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
Loading…
x
Reference in New Issue
Block a user