diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-04-03 06:49:06 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-04-03 06:49:06 +0000 |
commit | 1ab58b6aa580326f6841cd897fc1675bd2c5cb82 (patch) | |
tree | 67145e5a7a3b0f3361706ebfcfd25105b09a6c10 /test/unit/user_test.rb | |
parent | df347c5c017d50a503c4c0b630fd45bb77452b44 (diff) | |
download | redmine-1ab58b6aa580326f6841cd897fc1675bd2c5cb82.tar.gz redmine-1ab58b6aa580326f6841cd897fc1675bd2c5cb82.zip |
Adds a User.admin scope (#25416).
git-svn-id: http://svn.redmine.org/redmine/trunk@16449 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/user_test.rb')
-rw-r--r-- | test/unit/user_test.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 655a8affc..48c4cb3d4 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -36,6 +36,24 @@ class UserTest < ActiveSupport::TestCase @dlopper = User.find(3) end + def test_admin_scope_without_args_should_return_admin_users + users = User.admin.to_a + assert users.any? + assert users.all? {|u| u.admin == true} + end + + def test_admin_scope_with_true_should_return_admin_users + users = User.admin(true).to_a + assert users.any? + assert users.all? {|u| u.admin == true} + end + + def test_admin_scope_with_false_should_return_non_admin_users + users = User.admin(false).to_a + assert users.any? + assert users.all? {|u| u.admin == false} + end + def test_sorted_scope_should_sort_user_by_display_name # Use .active to ignore anonymous with localized display name assert_equal User.active.map(&:name).map(&:downcase).sort, @@ -1049,7 +1067,7 @@ class UserTest < ActiveSupport::TestCase end def test_own_account_deletable_should_be_false_for_a_single_admin - User.where(["admin = ? AND id <> ?", true, 1]).delete_all + User.admin.where("id <> ?", 1).delete_all with_settings :unsubscribe => '1' do assert_equal false, User.find(1).own_account_deletable? |