Commit ebabf56e authored by Alex Kalderimis's avatar Alex Kalderimis

Add integration test for design tab link filtering

This verifies that the new information from `object_link_text_extras` is
used correctly
parent 94d9e719
......@@ -6,24 +6,38 @@ describe Banzai::Filter::IssueReferenceFilter do
include FilterSpecHelper
include DesignManagementTestHelpers
let_it_be(:issue) { create(:issue) }
let_it_be(:project) { issue.project }
let_it_be(:current_user) { project.owner }
let_it_be(:designs_tab_url) { url_for_designs(issue) }
context 'when processing a link to the designs tab' do
before do
enable_design_management
end
let(:input_text) { "See #{designs_tab_url}" }
subject(:link) { reference_filter(input_text).css('a').first }
it 'includes the word "designs" after the reference in the text content', :aggregate_failures do
expect(link.attr('title')).to eq(issue.title)
expect(link.attr('href')).to eq(designs_tab_url)
expect(link.text).to eq("#{issue.to_reference} (designs)")
end
end
describe '#object_link_text_extras' do
before do
enable_design_management(enabled)
end
let(:enabled) { true }
let_it_be(:issue) { create(:issue) }
let(:project) { issue.project }
let(:matches) { ::Issue.link_reference_pattern.match(input_text) }
let(:current_user) { project.owner }
let(:extras) { subject.object_link_text_extras(issue, matches) }
subject do
render_context = Banzai::RenderContext.new(project, current_user)
context = { project: project, current_user: current_user, render_context: render_context }
described_class.new(input_text, context)
end
subject { filter_instance }
context 'the link does not go to the designs tab' do
let(:input_text) { Gitlab::Routing.url_helpers.project_issue_url(issue.project, issue) }
......@@ -34,7 +48,7 @@ describe Banzai::Filter::IssueReferenceFilter do
end
context 'the link goes to the designs tab' do
let(:input_text) { url_for_designs(issue) }
let(:input_text) { designs_tab_url }
it 'includes designs' do
expect(extras).to include('designs')
......
......@@ -55,6 +55,7 @@ module FilterSpecHelper
def reference_pipeline(context = {})
context.reverse_merge!(project: project) if defined?(project)
context.reverse_merge!(current_user: current_user) if defined?(current_user)
filters = [
Banzai::Filter::AutolinkFilter,
......
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