diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/services/personal_access_tokens/create_service_spec.rb | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/services/personal_access_tokens/create_service_spec.rb')
-rw-r--r-- | spec/services/personal_access_tokens/create_service_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/services/personal_access_tokens/create_service_spec.rb b/spec/services/personal_access_tokens/create_service_spec.rb new file mode 100644 index 00000000000..9190434b96a --- /dev/null +++ b/spec/services/personal_access_tokens/create_service_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe PersonalAccessTokens::CreateService do + describe '#execute' do + context 'with valid params' do + it 'creates personal access token record' do + user = create(:user) + params = { name: 'Test token', impersonation: true, scopes: [:api], expires_at: Date.today + 1.month } + + response = described_class.new(user, params).execute + personal_access_token = response.payload[:personal_access_token] + + expect(response.success?).to be true + expect(personal_access_token.name).to eq(params[:name]) + expect(personal_access_token.impersonation).to eq(params[:impersonation]) + expect(personal_access_token.scopes).to eq(params[:scopes]) + expect(personal_access_token.expires_at).to eq(params[:expires_at]) + expect(personal_access_token.user).to eq(user) + end + end + end +end |