Commit 371f4227 authored by Dmitry Gruzd's avatar Dmitry Gruzd Committed by Robert Speicher

Add unfurl support for /search

This change adds meta tags for slack link unfurling using
page_description and page_card_attributes methods.
parent 6b3a3d12
......@@ -2,6 +2,10 @@
- page_title @search_term
- @hide_breadcrumbs = true
- if @search_results
- page_description(_("%{count} %{scope} for term '%{term}'") % { count: @search_results.formatted_count(@scope), scope: @scope, term: @search_term })
- page_card_attributes("Namespace" => @group&.full_path, "Project" => @project&.full_path)
.page-title-holder.d-sm-flex.align-items-sm-center
%h1.page-title<
= _('Search')
......
---
title: Improve unfurling support for /search
merge_request: 38699
author:
type: other
......@@ -333,6 +333,9 @@ msgstr ""
msgid "%{cores} cores"
msgstr ""
msgid "%{count} %{scope} for term '%{term}'"
msgstr ""
msgid "%{count} LOC/commit"
msgstr ""
......
......@@ -33,5 +33,37 @@ RSpec.describe 'search/show' do
expect(rendered).to render_template('search/_category')
expect(rendered).to render_template('search/_results')
end
context 'unfurling support' do
let(:group) { build(:group) }
let(:search_results) do
instance_double(Gitlab::GroupSearchResults).tap do |double|
allow(double).to receive(:formatted_count).and_return(0)
end
end
before do
assign(:search_results, search_results)
assign(:scope, 'issues')
assign(:group, group)
end
it 'renders meta tags for a group' do
render
expect(view.page_description).to match(/\d+ issues for term '#{search_term}'/)
expect(view.page_card_attributes).to eq("Namespace" => group.full_path)
end
it 'renders meta tags for both group and project' do
project = build(:project, group: group)
assign(:project, project)
render
expect(view.page_description).to match(/\d+ issues for term '#{search_term}'/)
expect(view.page_card_attributes).to eq("Namespace" => group.full_path, "Project" => project.full_path)
end
end
end
end
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