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/models/ci/job_token/allowlist_spec.rb')
-rw-r--r--spec/models/ci/job_token/allowlist_spec.rb39
1 files changed, 30 insertions, 9 deletions
diff --git a/spec/models/ci/job_token/allowlist_spec.rb b/spec/models/ci/job_token/allowlist_spec.rb
index 45083d64393..3a2673c7c26 100644
--- a/spec/models/ci/job_token/allowlist_spec.rb
+++ b/spec/models/ci/job_token/allowlist_spec.rb
@@ -3,6 +3,7 @@
require 'spec_helper'
RSpec.describe Ci::JobToken::Allowlist, feature_category: :continuous_integration do
+ include Ci::JobTokenScopeHelpers
using RSpec::Parameterized::TableSyntax
let_it_be(:source_project) { create(:project) }
@@ -24,11 +25,11 @@ RSpec.describe Ci::JobToken::Allowlist, feature_category: :continuous_integratio
end
context 'when projects are added to the scope' do
- include_context 'with scoped projects'
+ include_context 'with a project in each allowlist'
where(:direction, :additional_project) do
- :outbound | ref(:outbound_scoped_project)
- :inbound | ref(:inbound_scoped_project)
+ :outbound | ref(:outbound_allowlist_project)
+ :inbound | ref(:inbound_allowlist_project)
end
with_them do
@@ -39,6 +40,26 @@ RSpec.describe Ci::JobToken::Allowlist, feature_category: :continuous_integratio
end
end
+ describe 'add!' do
+ let_it_be(:added_project) { create(:project) }
+ let_it_be(:user) { create(:user) }
+
+ subject { allowlist.add!(added_project, user: user) }
+
+ [:inbound, :outbound].each do |d|
+ let(:direction) { d }
+
+ it 'adds the project' do
+ subject
+
+ expect(allowlist.projects).to contain_exactly(source_project, added_project)
+ expect(subject.added_by_id).to eq(user.id)
+ expect(subject.source_project_id).to eq(source_project.id)
+ expect(subject.target_project_id).to eq(added_project.id)
+ end
+ end
+ end
+
describe '#includes?' do
subject { allowlist.includes?(includes_project) }
@@ -57,16 +78,16 @@ RSpec.describe Ci::JobToken::Allowlist, feature_category: :continuous_integratio
end
end
- context 'with scoped projects' do
- include_context 'with scoped projects'
+ context 'with a project in each allowlist' do
+ include_context 'with a project in each allowlist'
where(:includes_project, :direction, :result) do
ref(:source_project) | :outbound | false
ref(:source_project) | :inbound | false
- ref(:inbound_scoped_project) | :outbound | false
- ref(:inbound_scoped_project) | :inbound | true
- ref(:outbound_scoped_project) | :outbound | true
- ref(:outbound_scoped_project) | :inbound | false
+ ref(:inbound_allowlist_project) | :outbound | false
+ ref(:inbound_allowlist_project) | :inbound | true
+ ref(:outbound_allowlist_project) | :outbound | true
+ ref(:outbound_allowlist_project) | :inbound | false
ref(:unscoped_project1) | :outbound | false
ref(:unscoped_project1) | :inbound | false
ref(:unscoped_project2) | :outbound | false