summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorMark Fletcher <mark@gitlab.com>2018-01-09 18:00:11 +0000
committerMark Fletcher <mark@gitlab.com>2018-01-09 18:04:41 +0000
commit7034ef29edd853b3d18d3666a19826217990bfb1 (patch)
treefffca7348f71b7657045a8a38c046a7bde2f7789 /spec/views
parent396e7647f836c0cb87d19252fb6d31e91e0dbd6c (diff)
downloadgitlab-ce-7034ef29edd853b3d18d3666a19826217990bfb1.tar.gz
Hide new branch and tag links for projects with an empty repo
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/projects/buttons/_dropdown.html.haml_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/views/projects/buttons/_dropdown.html.haml_spec.rb b/spec/views/projects/buttons/_dropdown.html.haml_spec.rb
new file mode 100644
index 00000000000..d0e692635b9
--- /dev/null
+++ b/spec/views/projects/buttons/_dropdown.html.haml_spec.rb
@@ -0,0 +1,39 @@
+require 'spec_helper'
+
+describe 'projects/buttons/_dropdown' do
+ let(:user) { create(:user) }
+
+ context 'user with all abilities' do
+ before do
+ assign(:project, project)
+
+ allow(view).to receive(:current_user).and_return(user)
+ allow(view).to receive(:can?).and_return(true)
+ end
+
+ context 'empty repository' do
+ let(:project) { create(:project, :empty_repo) }
+
+ it 'has a link to create a new file' do
+ render
+
+ expect(view).to render_template('projects/buttons/_dropdown')
+ expect(rendered).to have_link('New file')
+ end
+
+ it 'does not have a link to create a new branch' do
+ render
+
+ expect(view).to render_template('projects/buttons/_dropdown')
+ expect(rendered).not_to have_link('New branch')
+ end
+
+ it 'does not have a link to create a new tag' do
+ render
+
+ expect(view).to render_template('projects/buttons/_dropdown')
+ expect(rendered).not_to have_link('New tag')
+ end
+ end
+ end
+end