Move issuable reference display to a helper method
This commit is contained in:
parent
0e14a2f21d
commit
78b0106878
4 changed files with 46 additions and 4 deletions
|
@ -162,6 +162,10 @@ module IssuablesHelper
|
|||
]
|
||||
end
|
||||
|
||||
def issuable_reference(issuable)
|
||||
@show_full_reference ? issuable.to_reference(full: true) : issuable.to_reference(@group || @project)
|
||||
end
|
||||
|
||||
def issuable_filter_present?
|
||||
issuable_filter_params.any? { |k| params.key?(k) }
|
||||
end
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
= note_count
|
||||
|
||||
.issue-info
|
||||
= @show_full_reference ? issue.to_reference(full: true) : issue.to_reference(@group || @project)
|
||||
·
|
||||
#{issuable_reference(issue)} ·
|
||||
opened #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')}
|
||||
by #{link_to_member(@project, issue.author, avatar: false)}
|
||||
- if issue.milestone
|
||||
|
|
|
@ -46,8 +46,7 @@
|
|||
= note_count
|
||||
|
||||
.merge-request-info
|
||||
= @show_full_reference ? merge_request.to_reference(full: true) : merge_request.to_reference(@group || @project)
|
||||
·
|
||||
#{issuable_reference(merge_request)} ·
|
||||
opened #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')}
|
||||
by #{link_to_member(@project, merge_request.author, avatar: false)}
|
||||
- if merge_request.target_project.default_branch != merge_request.target_branch
|
||||
|
|
|
@ -115,6 +115,46 @@ describe IssuablesHelper do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#issuable_reference' do
|
||||
context 'when show_full_reference truthy' do
|
||||
it 'display issuable full reference' do
|
||||
assign(:show_full_reference, true)
|
||||
issue = build_stubbed(:issue)
|
||||
|
||||
expect(helper.issuable_reference(issue)).to eql(issue.to_reference(full: true))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when show_full_reference falsey' do
|
||||
context 'when @group present' do
|
||||
it 'display issuable reference to @group' do
|
||||
project = build_stubbed(:project)
|
||||
|
||||
assign(:show_full_reference, nil)
|
||||
assign(:group, project.namespace)
|
||||
|
||||
issue = build_stubbed(:issue)
|
||||
|
||||
expect(helper.issuable_reference(issue)).to eql(issue.to_reference(project.namespace))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when @project present' do
|
||||
it 'display issuable reference to @project' do
|
||||
project = build_stubbed(:project)
|
||||
|
||||
assign(:show_full_reference, nil)
|
||||
assign(:group, nil)
|
||||
assign(:project, project)
|
||||
|
||||
issue = build_stubbed(:issue)
|
||||
|
||||
expect(helper.issuable_reference(issue)).to eql(issue.to_reference(project))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#issuable_filter_present?' do
|
||||
it 'returns true when any key is present' do
|
||||
allow(helper).to receive(:params).and_return(
|
||||
|
|
Loading…
Reference in a new issue