summaryrefslogtreecommitdiffstats
path: root/test/functional/users_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-11 10:25:44 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-03-11 10:25:44 +0000
commit81185a8d93c049eb77d3c3638dc01ab4e3a65f07 (patch)
tree567c70ae244bed5231f6b3a8d8ca061522cc884d /test/functional/users_controller_test.rb
parent16fbb3664c7a1ec87ad00fca6edaa599688d4b5c (diff)
downloadredmine-81185a8d93c049eb77d3c3638dc01ab4e3a65f07.tar.gz
redmine-81185a8d93c049eb77d3c3638dc01ab4e3a65f07.zip
Additional tests for UsersController.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9231 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/users_controller_test.rb')
-rw-r--r--test/functional/users_controller_test.rb41
1 files changed, 39 insertions, 2 deletions
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 11e5acc3c..aba9ea9c6 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -296,13 +296,13 @@ class UsersControllerTest < ActionController::TestCase
assert_mail_body_match 'newpass', mail
end
- test "put :update with a password change to an AuthSource user switching to Internal authentication" do
+ def test_update_user_switchin_from_auth_source_to_password_authentication
# Configure as auth source
u = User.find(2)
u.auth_source = AuthSource.find(1)
u.save!
- put :update, :id => u.id, :user => {:auth_source_id => '', :password => 'newpass'}, :password_confirmation => 'newpass'
+ put :update, :id => u.id, :user => {:auth_source_id => '', :password => 'newpass', :password_confirmation => 'newpass'}
assert_equal nil, u.reload.auth_source
assert u.check_password?('newpass')
@@ -336,6 +336,27 @@ class UsersControllerTest < ActionController::TestCase
assert_equal 3, member.project_id
end
+ def test_create_membership_js_format
+ assert_difference 'Member.count' do
+ post :edit_membership, :id => 7, :membership => {:project_id => 3, :role_ids => [2]}, :format => 'js'
+ end
+ assert_response :success
+ assert_select_rjs :replace_html, 'tab-content-memberships'
+ member = Member.first(:order => 'id DESC')
+ assert_equal User.find(7), member.principal
+ assert_equal [2], member.role_ids
+ assert_equal 3, member.project_id
+ end
+
+ def test_create_membership_js_format_with_failure
+ assert_no_difference 'Member.count' do
+ post :edit_membership, :id => 7, :membership => {:project_id => 3}, :format => 'js'
+ end
+ assert_response :success
+ assert @response.body.match(/alert/i), "Alert message not sent"
+ assert @response.body.match(/role can't be empty/i), "Error message not sent"
+ end
+
def test_update_membership
assert_no_difference 'Member.count' do
put :edit_membership, :id => 2, :membership_id => 1, :membership => { :role_ids => [2]}
@@ -344,6 +365,14 @@ class UsersControllerTest < ActionController::TestCase
assert_equal [2], Member.find(1).role_ids
end
+ def test_update_membership_js_format
+ assert_no_difference 'Member.count' do
+ put :edit_membership, :id => 2, :membership_id => 1, :membership => {:role_ids => [2]}, :format => 'js'
+ end
+ assert_response :success
+ assert_select_rjs :replace_html, 'tab-content-memberships'
+ end
+
def test_destroy_membership
assert_difference 'Member.count', -1 do
delete :destroy_membership, :id => 2, :membership_id => 1
@@ -351,4 +380,12 @@ class UsersControllerTest < ActionController::TestCase
assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships'
assert_nil Member.find_by_id(1)
end
+
+ def test_destroy_membership_js_format
+ assert_difference 'Member.count', -1 do
+ delete :destroy_membership, :id => 2, :membership_id => 1, :format => 'js'
+ end
+ assert_response :success
+ assert_select_rjs :replace_html, 'tab-content-memberships'
+ end
end