Commit 70b8f421 authored by Mayra Cabrera's avatar Mayra Cabrera

Modifies commit branches section

- Display the default branch (if the limit is not exceeded)
- Requires '...' to be clicked before showing the rest of the branches and/or tags
- Fixes haml lints
parent 4585f358
......@@ -61,7 +61,7 @@
%span.cgray= n_('parent', 'parents', @commit.parents.count)
- @commit.parents.each do |parent|
= link_to parent.short_id, project_commit_path(@project, parent), class: "commit-sha"
%div.commit-info.branches
.commit-info.branches
%i.fa.fa-spinner.fa-spin
- if @commit.last_pipeline
......
.has-tooltip{class: "limit-box limit-box-#{objects.singularize}", data: { title: "Project has too many #{objects} to search"} }
.has-tooltip{ class: "limit-box limit-box-#{objects.singularize}", data: { title: "Project has too many #{objects} to search"} }
.limit-icon
- if objects == "branches"
= icon('code-fork')
- else
= icon('tag')
.limit-message
%span= "#{objects.capitalize} unavailable"
%span #{objects.capitalize} unavailable
- if @branches_limit_exceeded
= render 'limit_exceeded_message', objects: 'branches'
- elsif @branches.any?
= commit_branches_links(@project, @branches)
- else
- branch = commit_default_branch(@project, @branches)
= commit_branch_link(project_ref_path(@project, branch), branch)
- if @tags_limit_exceeded
- if @branches.any? || @tags.any? || @tags_limit_exceeded
%span
= link_to "…", "#", class: "js-details-expand label label-gray"
%span.js-details-content.hide
= commit_branches_links(@project, @branches)
- if @tags_limit_exceeded
= render 'limit_exceeded_message', objects: 'tags'
- elsif @tags.any?
- else
= commit_tags_links(@project, @tags)
......@@ -7,7 +7,7 @@ describe 'projects/commit/branches.html.haml' do
assign(:project, project)
end
context 'branches and tags' do
context 'when branches and tags are available' do
before do
assign(:branches, ['master', 'test-branch'])
assign(:branches_limit_exceeded, false)
......@@ -17,16 +17,75 @@ describe 'projects/commit/branches.html.haml' do
render
end
it 'shows default branch' do
expect(rendered).to have_link('master')
end
it 'shows js expand link' do
expect(rendered).to have_selector('.js-details-expand')
end
it 'shows branch and tag links' do
expect(rendered).to have_link('test-branch')
expect(rendered).to have_link('tag1')
end
end
context 'when branches are available but no tags' do
before do
assign(:branches, ['master', 'test-branch'])
assign(:branches_limit_exceeded, false)
assign(:tags, [])
assign(:tags_limit_exceeded, true)
render
end
it 'shows branches' do
expect(rendered).to have_link('master')
expect(rendered).to have_link('test-branch')
end
it 'shows js expand link' do
expect(rendered).to have_selector('.js-details-expand')
end
it 'shows limit exceeded message for tags' do
expect(rendered).to have_text('Tags unavailable')
end
end
context 'when tags are available but no branches (just default)' do
before do
assign(:branches, ['master'])
assign(:branches_limit_exceeded, true)
assign(:tags, ['tag1', 'tag2'])
assign(:tags_limit_exceeded, false)
render
end
it 'shows default branch' do
expect(rendered).to have_text('master')
end
it 'shows js expand link' do
expect(rendered).to have_selector('.js-details-expand')
end
it 'shows tags' do
expect(rendered).to have_link('tag1')
expect(rendered).to have_link('tag2')
end
it 'shows limit exceeded for branches' do
expect(rendered).to have_text('Branches unavailable')
end
end
context 'throttled branches and tags' do
context 'when branches and tags are not available' do
before do
assign(:branches, [])
assign(:branches, ['master'])
assign(:branches_limit_exceeded, true)
assign(:tags, [])
assign(:tags_limit_exceeded, true)
......@@ -34,6 +93,14 @@ describe 'projects/commit/branches.html.haml' do
render
end
it 'shows default branch' do
expect(rendered).to have_text('master')
end
it 'shows js expand link' do
expect(rendered).to have_selector('.js-details-expand')
end
it 'shows too many to search' do
expect(rendered).to have_text('Branches unavailable')
expect(rendered).to have_text('Tags unavailable')
......
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