]> source.dussan.org Git - redmine.git/commitdiff
Fixes password sending when creating user.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 12 Dec 2010 15:26:55 +0000 (15:26 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 12 Dec 2010 15:26:55 +0000 (15:26 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4500 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/users_controller.rb
test/functional/users_controller_test.rb

index c3c63d73651fb6f3c7bd09835fcc3463f1c2ad48..8bdc106142e43ce6a4783e3e628a1e5c751b941e 100644 (file)
@@ -105,7 +105,7 @@ class UsersController < ApplicationController
       @user.pref.save
       @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
 
-      Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
+      Mailer.deliver_account_information(@user, params[:user][:password]) if params[:send_information]
       
       respond_to do |format|
         format.html {
index c9c2c0ee399b8533bc311f76f8098baa83b660d6..d8493740d76d53d046fa5f3212368298c25db0d7 100644 (file)
@@ -168,7 +168,41 @@ class UsersControllerTest < ActionController::TestCase
       should_respond_with :success
       should_render_template :new
     end
-
+  end
+  
+  def test_create
+    Setting.bcc_recipients = '1'
+    
+    assert_difference 'User.count' do
+      assert_difference 'ActionMailer::Base.deliveries.size' do
+        post :create,
+          :user => {
+            :firstname => 'John',
+            :lastname => 'Doe',
+            :login => 'jdoe',
+            :password => 'secret',
+            :password_confirmation => 'secret',
+            :mail => 'jdoe@gmail.com',
+            :mail_notification => 'none'
+          },
+          :send_information => '1'
+      end
+    end
+    
+    user = User.first(:order => 'id DESC')
+    assert_redirected_to :controller => 'users', :action => 'edit', :id => user.id
+    
+    assert_equal 'John', user.firstname
+    assert_equal 'Doe', user.lastname
+    assert_equal 'jdoe', user.login
+    assert_equal 'jdoe@gmail.com', user.mail
+    assert_equal 'none', user.mail_notification
+    assert user.check_password?('secret')
+    
+    mail = ActionMailer::Base.deliveries.last
+    assert_not_nil mail
+    assert_equal [user.mail], mail.bcc
+    assert mail.body.include?('secret')
   end
 
   def test_update