summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorMark Fletcher <mark@gitlab.com>2017-01-02 20:51:57 +0000
committerMark Fletcher <mark@gitlab.com>2017-03-07 20:05:33 +0530
commitb5b448934563b0b3237b6b2e6e168c012b012097 (patch)
tree8d7f7b977b9d53ab60d764bb89e15d5790057316 /spec/views
parentdf55d35ffd33fe97e669a227dd4666044e8cc65b (diff)
downloadgitlab-ce-b5b448934563b0b3237b6b2e6e168c012b012097.tar.gz
Don't show links to tag a commit for non permitted users
* Show tag link for users that can push code * Don't show tag link for guests and non-authenticated users
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/projects/commit/_commit_box.html.haml_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/views/projects/commit/_commit_box.html.haml_spec.rb b/spec/views/projects/commit/_commit_box.html.haml_spec.rb
index e741e3cf9b6..f2919f20e85 100644
--- a/spec/views/projects/commit/_commit_box.html.haml_spec.rb
+++ b/spec/views/projects/commit/_commit_box.html.haml_spec.rb
@@ -3,11 +3,13 @@ require 'spec_helper'
describe 'projects/commit/_commit_box.html.haml' do
include Devise::Test::ControllerHelpers
+ let(:user) { create(:user) }
let(:project) { create(:project) }
before do
assign(:project, project)
assign(:commit, project.commit)
+ allow(view).to receive(:can_collaborate_with_project?).and_return(false)
end
it 'shows the commit SHA' 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")
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