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>2023-12-04 18:12:07 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-04 18:12:07 +0300
commita155ff5671d06afd4c219a49b6c9fd673af69876 (patch)
treeea9f3422fcfe751f954561ff579569ba9a742eb3 /spec/models/ci/catalog/listing_spec.rb
parent157061839634d24bdb937316373f35bf1fb1f71e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/ci/catalog/listing_spec.rb')
-rw-r--r--spec/models/ci/catalog/listing_spec.rb33
1 files changed, 23 insertions, 10 deletions
diff --git a/spec/models/ci/catalog/listing_spec.rb b/spec/models/ci/catalog/listing_spec.rb
index 2d20acd4091..9d20d944e5a 100644
--- a/spec/models/ci/catalog/listing_spec.rb
+++ b/spec/models/ci/catalog/listing_spec.rb
@@ -185,11 +185,11 @@ RSpec.describe Ci::Catalog::Listing, feature_category: :pipeline_composition do
end
describe '#find_resource' do
+ let_it_be(:accessible_resource) { create(:ci_catalog_resource, :published, project: public_project) }
+
subject { list.find_resource(id: id) }
context 'when the resource is published and visible to the user' do
- let_it_be(:accessible_resource) { create(:ci_catalog_resource, :published, project: public_project) }
-
let(:id) { accessible_resource.id }
it 'fetches the resource' do
@@ -200,9 +200,7 @@ RSpec.describe Ci::Catalog::Listing, feature_category: :pipeline_composition do
context 'when the resource is not found' do
let(:id) { 'not-an-id' }
- it 'returns nil' do
- is_expected.to be_nil
- end
+ it { is_expected.to be_nil }
end
context 'when the resource is not published' do
@@ -210,9 +208,7 @@ RSpec.describe Ci::Catalog::Listing, feature_category: :pipeline_composition do
let(:id) { draft_resource.id }
- it 'returns nil' do
- is_expected.to be_nil
- end
+ it { is_expected.to be_nil }
end
context "when the current user cannot read code on the resource's project" do
@@ -220,8 +216,25 @@ RSpec.describe Ci::Catalog::Listing, feature_category: :pipeline_composition do
let(:id) { inaccessible_resource.id }
- it 'returns nil' do
- is_expected.to be_nil
+ it { is_expected.to be_nil }
+ end
+
+ context 'when the current user is anonymous' do
+ let(:user) { nil }
+
+ context 'when the resource is public' do
+ let(:id) { accessible_resource.id }
+
+ it 'fetches the public resource' do
+ is_expected.to eq(accessible_resource)
+ end
+ end
+
+ context 'when the resource is internal' do
+ let(:internal_resource) { create(:ci_catalog_resource, :published, project: internal_project) }
+ let(:id) { internal_resource.id }
+
+ it { is_expected.to be_nil }
end
end
end