Commit bbe8990b authored by Michael Kozono's avatar Michael Kozono

Merge branch '287921-epics-scope-group-level-search' into 'master'

Land on epics tab when searching within epics search context

See merge request gitlab-org/gitlab!58201
parents 37d598c2 bb728ba4
---
title: Land on epics tab when searching within epics search context
merge_request: 58201
author:
type: fixed
# frozen_string_literal: true
module EE
module Gitlab
module SearchContext
module Builder
extend ::Gitlab::Utils::Override
override :search_scope
def search_scope
if view_context.current_controller?(:epics)
'epics'
else
super
end
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::SearchContext::Builder, type: :controller do
controller(ApplicationController) { }
subject(:builder) { described_class.new(controller.view_context) }
describe '#with_group' do
let(:group) { create(:group) }
describe '#build!' do
subject(:context) { builder.with_group(group).build! }
context 'with epics scope' do
before do
allow(controller).to receive(:controller_name).and_return('epics')
end
it 'search context returns epics scope' do
expect(subject.scope).to be('epics')
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'layouts/_search' do
let(:group) { create(:group) }
let(:project) { nil }
let(:scope) { 'epics' }
let(:search_context) do
instance_double(Gitlab::SearchContext,
project: project,
group: group,
scope: scope,
ref: nil,
snippets: [],
search_url: '/search',
project_metadata: {},
group_metadata: {})
end
before do
allow(view).to receive(:search_context).and_return(search_context)
allow(search_context).to receive(:code_search?).and_return(false)
allow(search_context).to receive(:for_snippets?).and_return(false)
allow(search_context).to receive(:for_project?).and_return(false)
allow(search_context).to receive(:for_group?).and_return(true)
end
context 'when doing group level search' do
context 'when on epics' do
it 'sets scope to epics' do
render
expect(rendered).to have_css("input[name='scope'][value='epics']", count: 1, visible: false)
end
end
end
end
......@@ -163,3 +163,5 @@ module Gitlab
end
end
end
Gitlab::SearchContext::Builder.prepend_ee_mod
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