summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-16 12:23:39 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-16 12:23:39 +0100
commit72f538731a233ab0f75e4ac139452806e2ee8cf0 (patch)
tree799afb125c731262291fcd5d7169674c9d43d7b9
parentd9d69d7ba7dd660c9b3e0ab30b58891a8b760328 (diff)
downloadgitlab-ce-72f538731a233ab0f75e4ac139452806e2ee8cf0.tar.gz
Remove redundant call to after branch delete service
-rw-r--r--app/services/delete_branch_service.rb9
-rw-r--r--spec/features/environments_spec.rb17
-rw-r--r--spec/services/delete_branch_service_spec.rb12
3 files changed, 16 insertions, 22 deletions
diff --git a/app/services/delete_branch_service.rb b/app/services/delete_branch_service.rb
index a9fe8198172..3e5dd4ebb86 100644
--- a/app/services/delete_branch_service.rb
+++ b/app/services/delete_branch_service.rb
@@ -22,7 +22,6 @@ class DeleteBranchService < BaseService
end
if repository.rm_branch(current_user, branch_name)
- execute_after_branch_delete_hooks(branch_name)
success('Branch was removed')
else
error('Failed to remove branch')
@@ -48,12 +47,4 @@ class DeleteBranchService < BaseService
"#{Gitlab::Git::BRANCH_REF_PREFIX}#{branch.name}",
[])
end
-
- private
-
- def execute_after_branch_delete_hooks(branch_name)
- AfterBranchDeleteService
- .new(project, current_user)
- .execute(branch_name)
- end
end
diff --git a/spec/features/environments_spec.rb b/spec/features/environments_spec.rb
index 8b34cb13b9d..e57c355916d 100644
--- a/spec/features/environments_spec.rb
+++ b/spec/features/environments_spec.rb
@@ -291,11 +291,26 @@ feature 'Environments', feature: true do
scenario 'user deletes the branch with running environment' do
visit namespace_project_branches_path(project.namespace, project)
- page.within('.js-branch-feature') { find('a.btn-remove').click }
+ remove_branch_with_hooks(project, user, 'feature') do
+ page.within('.js-branch-feature') { find('a.btn-remove').click }
+ end
+
visit_environment(environment)
expect(page).to have_no_link('Stop')
end
+
+ def remove_branch_with_hooks(project, user, branch)
+ params = {
+ oldrev: project.commit(branch).id,
+ newrev: Gitlab::Git::BLANK_SHA,
+ ref: "refs/heads/#{branch}"
+ }
+
+ yield
+
+ GitPushService.new(project, user, params).execute
+ end
end
def visit_environments(project)
diff --git a/spec/services/delete_branch_service_spec.rb b/spec/services/delete_branch_service_spec.rb
index 3ca4eb14518..336f5dafb5b 100644
--- a/spec/services/delete_branch_service_spec.rb
+++ b/spec/services/delete_branch_service_spec.rb
@@ -20,12 +20,6 @@ describe DeleteBranchService, services: true do
expect(result[:status]).to eq :success
expect(branch_exists?('feature')).to be false
end
-
- it 'calls after branch delete hooks' do
- expect(service).to receive(:execute_after_branch_delete_hooks)
-
- service.execute('feature')
- end
end
context 'when user does not have access to push to repository' do
@@ -38,12 +32,6 @@ describe DeleteBranchService, services: true do
expect(result[:message]).to eq 'You dont have push access to repo'
expect(branch_exists?('feature')).to be true
end
-
- it 'does not call after branch delete hooks' do
- expect(service).not_to receive(:execute_after_branch_delete_hooks)
-
- service.execute('feature')
- end
end
end