Rails 3.1 compatibility.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9067 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-03-04 10:44:59 +00:00
parent eb5a9f83c9
commit 70ced2f2af
2 changed files with 29 additions and 4 deletions

View File

@ -93,11 +93,9 @@ class UsersController < ApplicationController
@user.login = params[:user][:login]
@user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation] unless @user.auth_source_id
# TODO: Similar to My#account
@user.pref.attributes = params[:pref]
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
if @user.save
@user.pref.attributes = params[:pref]
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
@user.pref.save
@user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])

View File

@ -194,6 +194,33 @@ class UsersControllerTest < ActionController::TestCase
assert mail.body.include?('secret')
end
def test_create_with_preferences
assert_difference 'User.count' do
post :create,
:user => {
:firstname => 'John',
:lastname => 'Doe',
:login => 'jdoe',
:password => 'secret',
:password_confirmation => 'secret',
:mail => 'jdoe@gmail.com',
:mail_notification => 'none'
},
:pref => {
'hide_mail' => '1',
'time_zone' => 'Paris',
'comments_sorting' => 'desc',
'warn_on_leaving_unsaved' => '0'
}
end
user = User.first(:order => 'id DESC')
assert_equal 'jdoe', user.login
assert_equal true, user.pref.hide_mail
assert_equal 'Paris', user.pref.time_zone
assert_equal 'desc', user.pref[:comments_sorting]
assert_equal '0', user.pref[:warn_on_leaving_unsaved]
end
def test_create_with_failure
assert_no_difference 'User.count' do
post :create, :user => {}