X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7f5e5b88c9161cbec69725108e438aa1532acaf5..5a625a53394fa99ef7fb44ab63104b8195d963df:/services/api/test/unit/user_test.rb diff --git a/services/api/test/unit/user_test.rb b/services/api/test/unit/user_test.rb index 4df6cc0b36..742deda0c6 100644 --- a/services/api/test/unit/user_test.rb +++ b/services/api/test/unit/user_test.rb @@ -136,7 +136,6 @@ class UserTest < ActiveSupport::TestCase test "admin can't clear username when user owns repositories" do set_user_from_auth :admin user = users(:active) - start_username = user.username user.username = nil assert_not_allowed { user.save } refute_empty(user.errors[:username]) @@ -163,8 +162,8 @@ class UserTest < ActiveSupport::TestCase if auto_admin_first_user_config # This test requires no admin users exist (except for the system user) users(:admin).delete - @all_users = User.where("uuid not like '%-000000000000000'").where(:is_admin => true).find(:all) - assert_equal 0, @all_users.size, "No admin users should exist (except for the system user)" + @all_users = User.where("uuid not like '%-000000000000000'").where(:is_admin => true) + assert_equal 0, @all_users.count, "No admin users should exist (except for the system user)" end Rails.configuration.auto_admin_first_user = auto_admin_first_user_config @@ -277,14 +276,16 @@ class UserTest < ActiveSupport::TestCase assert @uninvited_user.can? :write=>"#{@uninvited_user.uuid}" assert @uninvited_user.can? :manage=>"#{@uninvited_user.uuid}" - assert @uninvited_user.groups_i_can(:read).size == 1, "inactive and uninvited user can only read anonymous user group" - assert @uninvited_user.groups_i_can(:read).first.ends_with? 'anonymouspublic' , "inactive and uninvited user can only read anonymous user group" - assert @uninvited_user.groups_i_can(:write).size == 0, "inactive and uninvited user should not be able write to any groups" - assert @uninvited_user.groups_i_can(:manage).size == 0, "inactive and uninvited user should not be able manage any groups" + assert_equal(@uninvited_user.groups_i_can(:read).sort, + [@uninvited_user.uuid, groups(:anonymous_group).uuid].sort) + assert_equal(@uninvited_user.groups_i_can(:write), + [@uninvited_user.uuid]) + assert_equal(@uninvited_user.groups_i_can(:manage), + [@uninvited_user.uuid]) end test "find user method checks" do - User.find(:all).each do |user| + User.all.each do |user| assert_not_nil user.uuid, "non-null uuid expected for " + user.full_name end @@ -312,14 +313,14 @@ class UserTest < ActiveSupport::TestCase test "create new user" do set_user_from_auth :admin - @all_users = User.find(:all) + @all_users = User.all.to_a user = User.new user.first_name = "first_name_for_newly_created_user" user.save # verify there is one extra user in the db now - assert_equal @all_users.size+1, User.find(:all).size + assert_equal @all_users.size+1, User.all.count user = User.find(user.id) # get the user back assert_equal(user.first_name, 'first_name_for_newly_created_user') @@ -421,7 +422,7 @@ class UserTest < ActiveSupport::TestCase @active_user.delete found_deleted_user = false - User.find(:all).each do |user| + User.all.each do |user| if user.uuid == active_user_uuid found_deleted_user = true break