summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-12 15:13:34 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-12 15:13:34 +0000
commit0a2ec6ef0472fc0a14fe5793408c0546ebf39e4d (patch)
treeb634c4b758b9f958e23ae968bdd481e78306f803 /test
parent87ae744dce313076211ff472eb95edb65a048c82 (diff)
downloadredmine-0a2ec6ef0472fc0a14fe5793408c0546ebf39e4d.tar.gz
redmine-0a2ec6ef0472fc0a14fe5793408c0546ebf39e4d.zip
Extracts user groups assignment from controller.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4499 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/my_controller_test.rb15
-rw-r--r--test/functional/users_controller_test.rb7
2 files changed, 18 insertions, 4 deletions
diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb
index 3fefa0675..69a5b3e13 100644
--- a/test/functional/my_controller_test.rb
+++ b/test/functional/my_controller_test.rb
@@ -64,17 +64,24 @@ class MyControllerTest < ActionController::TestCase
end
def test_update_account
- post :account, :user => {:firstname => "Joe",
- :login => "root",
- :admin => 1,
- :custom_field_values => {"4" => "0100562500"}}
+ post :account,
+ :user => {
+ :firstname => "Joe",
+ :login => "root",
+ :admin => 1,
+ :group_ids => ['10'],
+ :custom_field_values => {"4" => "0100562500"}
+ }
+
assert_redirected_to '/my/account'
user = User.find(2)
assert_equal user, assigns(:user)
assert_equal "Joe", user.firstname
assert_equal "jsmith", user.login
assert_equal "0100562500", user.custom_value_for(4).value
+ # ignored
assert !user.admin?
+ assert user.groups.empty?
end
def test_change_password
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 0b3231f93..c9c2c0ee3 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -183,6 +183,13 @@ class UsersControllerTest < ActionController::TestCase
assert ActionMailer::Base.deliveries.empty?
end
+ def test_update_with_group_ids_should_assign_groups
+ put :update, :id => 2, :user => {:group_ids => ['10']}
+
+ user = User.find(2)
+ assert_equal [10], user.group_ids
+ end
+
def test_update_with_activation_should_send_a_notification
u = User.new(:firstname => 'Foo', :lastname => 'Bar', :mail => 'foo.bar@somenet.foo', :language => 'fr')
u.login = 'foo'