Merge branch '39988-hide-new-branch-tag-empty-repo' into 'master'
Resolve ""New branch" and "New tag" actions are pointless on an empty repository" Closes #39988 See merge request gitlab-org/gitlab-ce!16332
This commit is contained in:
commit
442fc4edeb
3 changed files with 51 additions and 6 deletions
|
@ -30,12 +30,13 @@
|
|||
%li
|
||||
= link_to project_new_blob_path(@project, @project.default_branch || 'master') do
|
||||
#{ _('New file') }
|
||||
%li
|
||||
= link_to new_project_branch_path(@project) do
|
||||
#{ _('New branch') }
|
||||
%li
|
||||
= link_to new_project_tag_path(@project) do
|
||||
#{ _('New tag') }
|
||||
- unless @project.empty_repo?
|
||||
%li
|
||||
= link_to new_project_branch_path(@project) do
|
||||
#{ _('New branch') }
|
||||
%li
|
||||
= link_to new_project_tag_path(@project) do
|
||||
#{ _('New tag') }
|
||||
- elsif current_user && current_user.already_forked?(@project)
|
||||
%li
|
||||
= link_to project_new_blob_path(@project, @project.default_branch || 'master') do
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Hide new branch and tag links for projects with an empty repo
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
39
spec/views/projects/buttons/_dropdown.html.haml_spec.rb
Normal file
39
spec/views/projects/buttons/_dropdown.html.haml_spec.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue