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