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:
Diffstat (limited to 'spec/lib/gitlab/audit')
-rw-r--r--spec/lib/gitlab/audit/deploy_token_author_spec.rb17
-rw-r--r--spec/lib/gitlab/audit/null_author_spec.rb9
2 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/gitlab/audit/deploy_token_author_spec.rb b/spec/lib/gitlab/audit/deploy_token_author_spec.rb
new file mode 100644
index 00000000000..449b7456a80
--- /dev/null
+++ b/spec/lib/gitlab/audit/deploy_token_author_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Audit::DeployTokenAuthor do
+ describe '#initialize' do
+ it 'sets correct attributes' do
+ expect(described_class.new(name: 'Lorem deploy token'))
+ .to have_attributes(id: -2, name: 'Lorem deploy token')
+ end
+
+ it 'sets default name when it is not provided' do
+ expect(described_class.new)
+ .to have_attributes(id: -2, name: 'Deploy Token')
+ end
+ end
+end
diff --git a/spec/lib/gitlab/audit/null_author_spec.rb b/spec/lib/gitlab/audit/null_author_spec.rb
index 7203a0cd816..2045139a5f7 100644
--- a/spec/lib/gitlab/audit/null_author_spec.rb
+++ b/spec/lib/gitlab/audit/null_author_spec.rb
@@ -48,6 +48,15 @@ RSpec.describe Gitlab::Audit::NullAuthor do
expect(subject.for(-1, audit_event)).to be_a(Gitlab::Audit::CiRunnerTokenAuthor)
expect(subject.for(-1, audit_event)).to have_attributes(id: -1, name: 'Authentication token: cde456')
end
+
+ it 'returns DeployTokenAuthor when id equals -2', :aggregate_failures do
+ allow(audit_event).to receive(:[]).with(:author_name).and_return('Test deploy token')
+ allow(audit_event).to receive(:details).and_return({})
+ allow(audit_event).to receive(:target_type)
+
+ expect(subject.for(-2, audit_event)).to be_a(Gitlab::Audit::DeployTokenAuthor)
+ expect(subject.for(-2, audit_event)).to have_attributes(id: -2, name: 'Test deploy token')
+ end
end
describe '#current_sign_in_ip' do