Commit 2f409a9a authored by Markus Koller's avatar Markus Koller

Clean up ES specs

- Always use :elastic tag instead of manually handling the index
- Remove unnecessary stub calls in after blocks
parent 5e576a85
require 'spec_helper'
describe 'GlobalSearch' do
describe 'GlobalSearch', :elastic do
let(:features) { %i(issues merge_requests repository builds wiki snippets) }
let(:admin) { create :user, admin: true }
let(:auditor) {create :user, auditor: true }
......@@ -12,18 +12,12 @@ describe 'GlobalSearch' do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
Gitlab::Elastic::Helper.create_empty_index
project.add_developer(member)
project.add_developer(external_member)
project.add_guest(guest)
end
after do
Gitlab::Elastic::Helper.delete_index
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
context "Respect feature visibility levels" do
context "Private projects" do
let(:project) { create(:project, :private, :repository, :wiki_repo) }
......
......@@ -11,10 +11,6 @@ describe 'Global elastic search', :elastic do
sign_in(user)
end
after do
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
shared_examples 'an efficient database result' do
it 'avoids N+1 database queries' do
create(object, creation_args)
......
require 'spec_helper'
describe 'Group elastic search', :js do
describe 'Group elastic search', :js, :elastic do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, :repository, :wiki_repo, namespace: group) }
......@@ -16,7 +16,6 @@ describe 'Group elastic search', :js do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
Gitlab::Elastic::Helper.create_empty_index
project.add_maintainer(user)
group.add_owner(user)
......@@ -24,11 +23,6 @@ describe 'Group elastic search', :js do
sign_in(user)
end
after do
Gitlab::Elastic::Helper.delete_index
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
describe 'issue search' do
before do
create(:issue, project: project, title: 'chosen issue title')
......
require 'spec_helper'
describe Gitlab::Elastic::ProjectSearchResults do
describe Gitlab::Elastic::ProjectSearchResults, :elastic do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:query) { 'hello world' }
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
Gitlab::Elastic::Helper.create_empty_index
end
after do
Gitlab::Elastic::Helper.delete_index
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
describe 'initialize with empty ref' do
......
......@@ -6,10 +6,6 @@ describe Gitlab::Elastic::SearchResults, :elastic do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
end
after do
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
let(:user) { create(:user) }
let(:project_1) { create(:project, :repository, :wiki_repo) }
let(:project_2) { create(:project, :repository, :wiki_repo) }
......
......@@ -36,12 +36,6 @@ describe API::Search do
shared_examples 'elasticsearch enabled' do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
Gitlab::Elastic::Helper.create_empty_index
end
after do
Gitlab::Elastic::Helper.delete_index
stub_ee_application_setting(elasticsearch_search: false, elasticsearch_indexing: false)
end
context 'for wiki_blobs scope' do
......@@ -119,7 +113,7 @@ describe API::Search do
end
end
context 'when elasticsearch is enabled' do
context 'when elasticsearch is enabled', :elastic do
it_behaves_like 'elasticsearch enabled' do
let(:endpoint) { '/search' }
end
......@@ -135,7 +129,7 @@ describe API::Search do
end
end
context 'when elasticsearch is enabled' do
context 'when elasticsearch is enabled', :elastic do
it_behaves_like 'elasticsearch enabled' do
let(:endpoint) { "/groups/#{group.id}/-/search" }
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