diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-14 21:09:20 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-14 21:09:20 +0000 |
commit | db2275b561bace34d90b901226d7f46d33e4cbd9 (patch) | |
tree | 7fde15815e18d0818b9be7ce61ddd90a13ea0f8c /spec/views | |
parent | 3c6cad91a1a9d8732e8cb998f83d32dc19373b7b (diff) | |
download | gitlab-ce-db2275b561bace34d90b901226d7f46d33e4cbd9.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/search/_results.html.haml_spec.rb | 9 | ||||
-rw-r--r-- | spec/views/search/show.html.haml_spec.rb | 135 |
2 files changed, 88 insertions, 56 deletions
diff --git a/spec/views/search/_results.html.haml_spec.rb b/spec/views/search/_results.html.haml_spec.rb index 72e2d7131c0..2149c394320 100644 --- a/spec/views/search/_results.html.haml_spec.rb +++ b/spec/views/search/_results.html.haml_spec.rb @@ -12,6 +12,13 @@ RSpec.describe 'search/_results' do controller.params[:action] = 'show' controller.params[:search] = term + allow(self).to receive(:current_user).and_return(user) + allow(@search_results).to receive(:formatted_count).with(scope).and_return(10) + allow(self).to receive(:search_count_path).with(any_args).and_return("test count link") + allow(self).to receive(:search_path).with(any_args).and_return("link test") + + stub_feature_flags(search_page_vertical_nav: false) + create_list(:issue, 3) @search_objects = search_objects @@ -147,7 +154,7 @@ RSpec.describe 'search/_results' do it 'does not render the sidebar' do render - expect(rendered).not_to have_selector('#js-search-sidebar') + expect(rendered).not_to have_selector('form.search-sidebar') end end end diff --git a/spec/views/search/show.html.haml_spec.rb b/spec/views/search/show.html.haml_spec.rb index a336ec91ff2..565dadd64fe 100644 --- a/spec/views/search/show.html.haml_spec.rb +++ b/spec/views/search/show.html.haml_spec.rb @@ -4,93 +4,118 @@ require 'spec_helper' RSpec.describe 'search/show' do let(:search_term) { nil } + let(:user) { build(:user) } before do stub_template "search/_category.html.haml" => 'Category Partial' stub_template "search/_results.html.haml" => 'Results Partial' - - @search_term = search_term - - render end - context 'when the search page is opened' do - it 'displays the title' do - expect(rendered).to have_selector('h1.page-title', text: 'Search') - expect(rendered).not_to have_selector('h1.page-title code') + context 'feature flag enabled' do + before do + allow(self).to receive(:current_user).and_return(user) + @search_term = search_term + + render end - it 'does not render partials' do - expect(rendered).not_to render_template('search/_category') - expect(rendered).not_to render_template('search/_results') + context 'when search term is supplied' do + let(:search_term) { 'Search Foo' } + + it 'will not render category partial' do + expect(rendered).not_to render_template('search/_category') + expect(rendered).to render_template('search/_results') + end end end - context 'when search term is supplied' do - let(:search_term) { 'Search Foo' } + context 'feature flag disabled' do + before do + stub_feature_flags(search_page_vertical_nav: false) - it 'renders partials' do - expect(rendered).to render_template('search/_category') - expect(rendered).to render_template('search/_results') + @search_term = search_term + + render 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 + context 'when the search page is opened' do + it 'displays the title' do + expect(rendered).to have_selector('h1.page-title', text: 'Search') + expect(rendered).not_to have_selector('h1.page-title code') end - before do - assign(:search_results, search_results) - assign(:scope, 'issues') - assign(:group, group) + it 'does not render partials' do + expect(rendered).not_to render_template('search/_category') + expect(rendered).not_to render_template('search/_results') end + end + + context 'when search term is supplied' do + let(:search_term) { 'Search Foo' } + + it 'renders partials' 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 - context 'search with full count' do before do - assign(:without_count, false) + assign(:search_results, search_results) + assign(:scope, 'issues') + assign(:group, group) end - it 'renders meta tags for a group' do - render + context 'search with full count' do + before do + assign(:without_count, false) + end - 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 a group' do + render - it 'renders meta tags for both group and project' do - project = build(:project, group: group) - assign(:project, project) + expect(view.page_description).to match(/\d+ issues for term '#{search_term}'/) + expect(view.page_card_attributes).to eq("Namespace" => group.full_path) + end - render + it 'renders meta tags for both group and project' do + project = build(:project, group: group) + assign(:project, project) - 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 + render - context 'search without full count' do - before do - assign(:without_count, true) + 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 - it 'renders meta tags for a group' do - render + context 'search without full count' do + before do + assign(:without_count, true) + end - expect(view.page_description).to match(/issues results for term '#{search_term}'/) - expect(view.page_card_attributes).to eq("Namespace" => group.full_path) - end + it 'renders meta tags for a group' do + render + + expect(view.page_description).to match(/issues results 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) + it 'renders meta tags for both group and project' do + project = build(:project, group: group) + assign(:project, project) - render + render - expect(view.page_description).to match(/issues results for term '#{search_term}'/) - expect(view.page_card_attributes).to eq("Namespace" => group.full_path, "Project" => project.full_path) + expect(view.page_description).to match(/issues results for term '#{search_term}'/) + expect(view.page_card_attributes).to eq("Namespace" => group.full_path, "Project" => project.full_path) + end end end end |