Commit d2b41267 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'fix-elasticsearch-snippets' into 'master'

Search snippets via elasticsearch

Closes #10548

See merge request gitlab-org/gitlab-ee!10325
parents b282fe8d 421ba4aa
......@@ -19,3 +19,5 @@ module Search
end
end
end
Search::SnippetService.prepend(::EE::Search::SnippetService)
# frozen_string_literal: true
module EE
module Search
module SnippetService
extend ::Gitlab::Utils::Override
override :execute
def execute
if ::Gitlab::CurrentSettings.elasticsearch_search?
::Gitlab::Elastic::SnippetSearchResults.new(current_user, params[:search])
else
super
end
end
end
end
end
---
title: Search snippets via elasticsearch
merge_request: 10325
author:
type: fixed
require 'spec_helper'
describe Search::GlobalService do
let(:user) { create(:user) }
describe 'elasticsearch' do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
subject(:results) { described_class.new(user, search: '*').execute }
it { is_expected.to be_a(::Gitlab::Elastic::SearchResults) }
end
end
......@@ -54,4 +54,17 @@ describe Search::GroupService do
include_examples 'group search'
end
describe 'elasticsearch result' do
let(:user) { create(:user) }
let(:group) { create(:group) }
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
subject(:results) { described_class.new(user, group, search: '*').execute }
it { is_expected.to be_a(::Gitlab::Elastic::GroupSearchResults) }
end
end
require 'spec_helper'
describe Search::ProjectService do
let(:project) { create(:project) }
let(:user) { project.owner }
describe 'elasticsearch' do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
subject(:results) { described_class.new(project, user, search: '*').execute }
it { is_expected.to be_a(::Gitlab::Elastic::ProjectSearchResults) }
end
end
require 'spec_helper'
describe Search::SnippetService do
let(:user) { create(:user) }
describe 'elasticsearch' do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
subject(:results) { described_class.new(user, search: '*').execute }
it { is_expected.to be_a(::Gitlab::Elastic::SnippetSearchResults) }
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