Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-25 06:10:55 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-25 06:10:55 +0300
commit65de487500295d4093cd53d392ea98980f070d57 (patch)
tree13479f14a93f1a03fd2df70c4004a783e8bbc6f0 /spec/serializers
parentb9955afcfbe07fdcf2b819bbf5612e969c4c6910 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/impersonation_access_token_entity_spec.rb26
-rw-r--r--spec/serializers/impersonation_access_token_serializer_spec.rb20
2 files changed, 46 insertions, 0 deletions
diff --git a/spec/serializers/impersonation_access_token_entity_spec.rb b/spec/serializers/impersonation_access_token_entity_spec.rb
new file mode 100644
index 00000000000..e8517779c0d
--- /dev/null
+++ b/spec/serializers/impersonation_access_token_entity_spec.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+require 'spec_helper'
+
+RSpec.describe ImpersonationAccessTokenEntity do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:token) { create(:personal_access_token, :impersonation, user: user) }
+
+ subject(:json) { described_class.new(token).as_json }
+
+ it 'has the correct attributes' do
+ expected_revoke_path = Gitlab::Routing.url_helpers
+ .revoke_admin_user_impersonation_token_path(
+ { user_id: user, id: token })
+
+ expect(json).to(
+ include(
+ id: token.id,
+ name: token.name,
+ scopes: token.scopes,
+ user_id: token.user_id,
+ revoke_path: expected_revoke_path
+ ))
+
+ expect(json).not_to include(:token)
+ end
+end
diff --git a/spec/serializers/impersonation_access_token_serializer_spec.rb b/spec/serializers/impersonation_access_token_serializer_spec.rb
new file mode 100644
index 00000000000..0c8cebb94b1
--- /dev/null
+++ b/spec/serializers/impersonation_access_token_serializer_spec.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+require 'spec_helper'
+
+RSpec.describe ImpersonationAccessTokenSerializer do
+ subject(:serializer) { described_class.new }
+
+ describe '#represent' do
+ it 'can render a single token' do
+ token = create(:personal_access_token)
+
+ expect(serializer.represent(token)).to be_kind_of(Hash)
+ end
+
+ it 'can render a collection of tokens' do
+ tokens = create_list(:personal_access_token, 2)
+
+ expect(serializer.represent(tokens)).to be_kind_of(Array)
+ end
+ end
+end