Extract EE specific files/lines for Create spec/services
We have the following files containing EE specific code. We should move them to ee/
spec/services/delete_branch_service_spec.rb
diff --git a/spec/services/delete_branch_service_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/delete_branch_service_spec.rb
index 9c9fba030e7..ceca12a57b8 100644
--- a/spec/services/delete_branch_service_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/delete_branch_service_spec.rb
@@ -6,20 +6,24 @@ describe DeleteBranchService do
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
+ shared_examples 'a deleted branch' do |branch_name|
+ it 'removes the branch' do
+ expect(branch_exists?(branch_name)).to be true
+
+ result = service.execute(branch_name)
+
+ expect(result[:status]).to eq :success
+ expect(branch_exists?(branch_name)).to be false
+ end
+ end
+
describe '#execute' do
context 'when user has access to push to repository' do
before do
project.add_developer(user)
end
- it 'removes the branch' do
- expect(branch_exists?('feature')).to be true
-
- result = service.execute('feature')
-
- expect(result[:status]).to eq :success
- expect(branch_exists?('feature')).to be false
- end
+ it_behaves_like 'a deleted branch', 'feature'
end
context 'when user does not have access to push to repository' do
@@ -33,6 +37,15 @@ describe DeleteBranchService do
expect(branch_exists?('feature')).to be true
end
end
+
+ context 'when there is a push rule matching the branch name' do
+ before do
+ project.add_developer(user)
+ create(:push_rule, branch_name_regex: '^(w*)$')
+ end
+
+ it_behaves_like 'a deleted branch', 'add-pdf-file'
+ end
end
def branch_exists?(branch_name)
spec/services/git_push_service_spec.rb
diff --git a/spec/services/git_push_service_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/git_push_service_spec.rb
index e8fce951155..dcdff077da8 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/services/git_push_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe GitPushService, services: true do
+describe GitPushService do
include RepoHelpers
set(:user) { create(:user) }
@@ -203,6 +203,28 @@ describe GitPushService, services: true do
end
end
+ describe "ES indexing" do
+ before 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
+
+ it "does not trigger indexer when push to non-default branch" do
+ expect_any_instance_of(Gitlab::Elastic::Indexer).not_to receive(:run)
+
+ execute_service(project, user, oldrev, newrev, 'refs/heads/other')
+ end
+
+ it "triggers indexer when push to default branch" do
+ expect_any_instance_of(Gitlab::Elastic::Indexer).to receive(:run)
+
+ execute_service(project, user, oldrev, newrev, ref)
+ end
+ end
+
describe "Push Event" do
context "with an existing branch" do
let!(:push_data) { push_data_from_service(project, user, oldrev, newrev, ref) }
@@ -324,7 +346,8 @@ describe GitPushService, services: true do
it "when pushing a branch for the first time with an existing branch permission configured" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
- create(:protected_branch, :no_one_can_push, :developers_can_merge, project: project, name: 'master')
+ create(:protected_branch, :no_one_can_push, :developers_can_merge,
+ project: project, name: 'master')
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
expect_any_instance_of(ProtectedBranches::CreateService).not_to receive(:execute)
Edited by Douwe Maan