Commit 685e261f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '26188-tag-creation-404-for-guests' into 'master'

Don't show links to tag a commit for non permitted users

Closes #26188

See merge request !8407
parents e78a3669 b5b44893
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
= revert_commit_link(@commit, namespace_project_commit_path(@project.namespace, @project, @commit.id), has_tooltip: false) = revert_commit_link(@commit, namespace_project_commit_path(@project.namespace, @project, @commit.id), has_tooltip: false)
%li.clearfix %li.clearfix
= cherry_pick_commit_link(@commit, namespace_project_commit_path(@project.namespace, @project, @commit.id), has_tooltip: false) = cherry_pick_commit_link(@commit, namespace_project_commit_path(@project.namespace, @project, @commit.id), has_tooltip: false)
- if can_collaborate_with_project?
%li.clearfix %li.clearfix
= link_to "Tag", new_namespace_project_tag_path(@project.namespace, @project, ref: @commit) = link_to "Tag", new_namespace_project_tag_path(@project.namespace, @project, ref: @commit)
%li.divider %li.divider
......
---
title: Don't show links to tag a commit for users that are not permitted
merge_request: 8407
author:
...@@ -3,11 +3,13 @@ require 'spec_helper' ...@@ -3,11 +3,13 @@ require 'spec_helper'
describe 'projects/commit/_commit_box.html.haml' do describe 'projects/commit/_commit_box.html.haml' do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
before do before do
assign(:project, project) assign(:project, project)
assign(:commit, project.commit) assign(:commit, project.commit)
allow(view).to receive(:can_collaborate_with_project?).and_return(false)
end end
it 'shows the commit SHA' do it 'shows the commit SHA' do
...@@ -25,4 +27,30 @@ describe 'projects/commit/_commit_box.html.haml' do ...@@ -25,4 +27,30 @@ describe 'projects/commit/_commit_box.html.haml' do
expect(rendered).to have_text("Pipeline ##{third_pipeline.id} for #{Commit.truncate_sha(project.commit.sha)} failed") expect(rendered).to have_text("Pipeline ##{third_pipeline.id} for #{Commit.truncate_sha(project.commit.sha)} failed")
end end
context 'viewing a commit' do
context 'as a developer' do
before do
expect(view).to receive(:can_collaborate_with_project?).and_return(true)
end
it 'has a link to create a new tag' do
render
expect(rendered).to have_link('Tag')
end
end
context 'as a non-developer' do
before do
expect(view).to receive(:can_collaborate_with_project?).and_return(false)
end
it 'does not have a link to create a new tag' do
render
expect(rendered).not_to have_link('Tag')
end
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment