summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-30 04:46:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-30 04:47:03 +0000
commit8171aefb3235e3f112fadbd1f1dc698a04f1d84b (patch)
tree6a4148560270a26cda2464c7016d73c561aa56f5 /spec
parent7229dcfc0a757cc94a80cf925d6ff4bfd4c9217a (diff)
downloadgitlab-ce-8171aefb3235e3f112fadbd1f1dc698a04f1d84b.tar.gz
Add latest changes from gitlab-org/security/gitlab@15-4-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/features/tags/developer_views_tags_spec.rb2
-rw-r--r--spec/models/project_spec.rb4
-rw-r--r--spec/support/shared_examples/features/user_views_tag_shared_examples.rb47
3 files changed, 38 insertions, 15 deletions
diff --git a/spec/features/tags/developer_views_tags_spec.rb b/spec/features/tags/developer_views_tags_spec.rb
index 57e1f7da04e..e2399dd9978 100644
--- a/spec/features/tags/developer_views_tags_spec.rb
+++ b/spec/features/tags/developer_views_tags_spec.rb
@@ -53,6 +53,8 @@ RSpec.describe 'Developer views tags' do
end
it 'views a specific tag page' do
+ create(:release, project: project, tag: 'v1.0.0', name: 'v1.0.0', description: nil)
+
click_on 'v1.0.0'
expect(page).to have_current_path(
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 99b984ff547..825a914c810 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -5509,8 +5509,8 @@ RSpec.describe Project, factory_default: :keep do
let(:import_state) { create(:import_state, project: project) }
it 'runs the correct hooks' do
- expect(project.repository).to receive(:remove_prohibited_branches)
- expect(project.repository).to receive(:expire_content_cache)
+ expect(project.repository).to receive(:expire_content_cache).ordered
+ expect(project.repository).to receive(:remove_prohibited_branches).ordered
expect(project.wiki.repository).to receive(:expire_content_cache)
expect(import_state).to receive(:finish)
expect(project).to receive(:update_project_counter_caches)
diff --git a/spec/support/shared_examples/features/user_views_tag_shared_examples.rb b/spec/support/shared_examples/features/user_views_tag_shared_examples.rb
index 989de1dbfbb..702964a2610 100644
--- a/spec/support/shared_examples/features/user_views_tag_shared_examples.rb
+++ b/spec/support/shared_examples/features/user_views_tag_shared_examples.rb
@@ -2,33 +2,54 @@
RSpec.shared_examples 'user views tag' do
context 'when user views with the tag' do
- let(:project) { create(:project, :repository) }
+ let(:project) { create(:project, :repository, :public) }
let(:user) { create(:user) }
let(:tag_name) { "stable" }
- let!(:release) { create(:release, project: project, tag: tag_name, name: "ReleaseName") }
+ let(:release_name) { 'ReleaseName' }
+ let(:release_notes) { 'Release notes' }
+ let!(:release) do
+ create(:release, project: project, tag: tag_name, name: release_name, description: release_notes)
+ end
before do
- project.add_developer(user)
project.repository.add_tag(user, tag_name, project.default_branch_or_main)
-
sign_in(user)
end
- shared_examples 'shows tag' do
- it do
- visit tag_page
+ context 'and user is authorized to read release' do
+ before do
+ project.add_developer(user)
+ end
+
+ shared_examples 'shows tag' do
+ it do
+ visit tag_page
+
+ expect(page).to have_content tag_name
+ expect(page).to have_link(release_name, href: project_release_path(project, release))
+ end
+ end
- expect(page).to have_content tag_name
- expect(page).to have_link("ReleaseName", href: project_release_path(project, release))
+ it_behaves_like 'shows tag'
+
+ context 'when tag name contains a slash' do
+ let(:tag_name) { "stable/v0.1" }
+
+ it_behaves_like 'shows tag'
end
end
- it_behaves_like 'shows tag'
+ context 'and user is not authorized to read release' do
+ before do
+ project.project_feature.update!(releases_access_level: Featurable::PRIVATE)
+ end
- context 'when tag name contains a slash' do
- let(:tag_name) { "stable/v0.1" }
+ it 'hides release link and notes', :aggregate_failures do
+ visit tag_page
- it_behaves_like 'shows tag'
+ expect(page).not_to have_link(release_name, href: project_release_path(project, release))
+ expect(page).not_to have_text(release_notes)
+ end
end
end
end