diff options
Diffstat (limited to 'spec/services/resource_access_tokens/create_service_spec.rb')
-rw-r--r-- | spec/services/resource_access_tokens/create_service_spec.rb | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/spec/services/resource_access_tokens/create_service_spec.rb b/spec/services/resource_access_tokens/create_service_spec.rb index 517ed086713..11069dc1bb8 100644 --- a/spec/services/resource_access_tokens/create_service_spec.rb +++ b/spec/services/resource_access_tokens/create_service_spec.rb @@ -88,12 +88,28 @@ RSpec.describe ResourceAccessTokens::CreateService do end end - it 'adds the bot user as a maintainer in the resource' do - response = subject - access_token = response.payload[:access_token] - bot_user = access_token.user + context 'access level' do + context 'when user does not specify an access level' do + it 'adds the bot user as a maintainer in the resource' do + response = subject + access_token = response.payload[:access_token] + bot_user = access_token.user + + expect(resource.members.maintainers.map(&:user_id)).to include(bot_user.id) + end + end - expect(resource.members.maintainers.map(&:user_id)).to include(bot_user.id) + context 'when user specifies an access level' do + let_it_be(:params) { { access_level: Gitlab::Access::DEVELOPER } } + + it 'adds the bot user with the specified access level in the resource' do + response = subject + access_token = response.payload[:access_token] + bot_user = access_token.user + + expect(resource.members.developers.map(&:user_id)).to include(bot_user.id) + end + end end context 'personal access token' do @@ -176,6 +192,7 @@ RSpec.describe ResourceAccessTokens::CreateService do context "when access provisioning fails" do let_it_be(:bot_user) { create(:user, :project_bot) } + let(:unpersisted_member) { build(:project_member, source: resource, user: bot_user) } before do |