X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4609a76d9b84e0f63233cdf6dcbef376b1686b69..1cfe69550c0cf25bc9dd8d2fc1468906f2b7e0e1:/services/api/test/unit/user_test.rb?ds=sidebyside diff --git a/services/api/test/unit/user_test.rb b/services/api/test/unit/user_test.rb index 0d55633724..d4f25245c3 100644 --- a/services/api/test/unit/user_test.rb +++ b/services/api/test/unit/user_test.rb @@ -3,6 +3,12 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase include CurrentApiClient + # The fixture services/api/test/fixtures/users.yml serves as the input for this test case + setup do + # Make sure system_user exists before making "pre-test users" list + system_user + end + test "check non-admin active user properties" do @active_user = users(:active) # get the active user assert !@active_user.is_admin, 'is_admin should not be set for a non-admin user' @@ -54,7 +60,8 @@ 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 == 0, "inactive and uninvited user should not be able read any groups" + 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" end @@ -95,9 +102,7 @@ class UserTest < ActiveSupport::TestCase user.save # verify there is one extra user in the db now - # the API server also auto-creates the root system user after the first user - # is created, hence the test for the delta of 2. - assert_equal @all_users.size+2, User.find(:all).size + assert_equal @all_users.size+1, User.find(:all).size user = User.find(user.id) # get the user back assert_equal(user.first_name, 'first_name_for_newly_created_user')