Commit 78b01068 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Move issuable reference display to a helper method

parent 0e14a2f2
...@@ -162,6 +162,10 @@ module IssuablesHelper ...@@ -162,6 +162,10 @@ module IssuablesHelper
] ]
end end
def issuable_reference(issuable)
@show_full_reference ? issuable.to_reference(full: true) : issuable.to_reference(@group || @project)
end
def issuable_filter_present? def issuable_filter_present?
issuable_filter_params.any? { |k| params.key?(k) } issuable_filter_params.any? { |k| params.key?(k) }
end end
......
...@@ -34,8 +34,7 @@ ...@@ -34,8 +34,7 @@
= note_count = note_count
.issue-info .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')} opened #{time_ago_with_tooltip(issue.created_at, placement: 'bottom')}
by #{link_to_member(@project, issue.author, avatar: false)} by #{link_to_member(@project, issue.author, avatar: false)}
- if issue.milestone - if issue.milestone
......
...@@ -46,8 +46,7 @@ ...@@ -46,8 +46,7 @@
= note_count = note_count
.merge-request-info .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')} opened #{time_ago_with_tooltip(merge_request.created_at, placement: 'bottom')}
by #{link_to_member(@project, merge_request.author, avatar: false)} by #{link_to_member(@project, merge_request.author, avatar: false)}
- if merge_request.target_project.default_branch != merge_request.target_branch - if merge_request.target_project.default_branch != merge_request.target_branch
......
...@@ -115,6 +115,46 @@ describe IssuablesHelper do ...@@ -115,6 +115,46 @@ describe IssuablesHelper do
end end
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 describe '#issuable_filter_present?' do
it 'returns true when any key is present' do it 'returns true when any key is present' do
allow(helper).to receive(:params).and_return( allow(helper).to receive(:params).and_return(
......
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