Commit 72f53873 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove redundant call to after branch delete service

parent d9d69d7b
...@@ -22,7 +22,6 @@ class DeleteBranchService < BaseService ...@@ -22,7 +22,6 @@ class DeleteBranchService < BaseService
end end
if repository.rm_branch(current_user, branch_name) if repository.rm_branch(current_user, branch_name)
execute_after_branch_delete_hooks(branch_name)
success('Branch was removed') success('Branch was removed')
else else
error('Failed to remove branch') error('Failed to remove branch')
...@@ -48,12 +47,4 @@ class DeleteBranchService < BaseService ...@@ -48,12 +47,4 @@ class DeleteBranchService < BaseService
"#{Gitlab::Git::BRANCH_REF_PREFIX}#{branch.name}", "#{Gitlab::Git::BRANCH_REF_PREFIX}#{branch.name}",
[]) [])
end end
private
def execute_after_branch_delete_hooks(branch_name)
AfterBranchDeleteService
.new(project, current_user)
.execute(branch_name)
end
end end
...@@ -291,11 +291,26 @@ feature 'Environments', feature: true do ...@@ -291,11 +291,26 @@ feature 'Environments', feature: true do
scenario 'user deletes the branch with running environment' do scenario 'user deletes the branch with running environment' do
visit namespace_project_branches_path(project.namespace, project) 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) visit_environment(environment)
expect(page).to have_no_link('Stop') expect(page).to have_no_link('Stop')
end 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 end
def visit_environments(project) def visit_environments(project)
......
...@@ -20,12 +20,6 @@ describe DeleteBranchService, services: true do ...@@ -20,12 +20,6 @@ describe DeleteBranchService, services: true do
expect(result[:status]).to eq :success expect(result[:status]).to eq :success
expect(branch_exists?('feature')).to be false expect(branch_exists?('feature')).to be false
end end
it 'calls after branch delete hooks' do
expect(service).to receive(:execute_after_branch_delete_hooks)
service.execute('feature')
end
end end
context 'when user does not have access to push to repository' do context 'when user does not have access to push to repository' do
...@@ -38,12 +32,6 @@ describe DeleteBranchService, services: true do ...@@ -38,12 +32,6 @@ describe DeleteBranchService, services: true do
expect(result[:message]).to eq 'You dont have push access to repo' expect(result[:message]).to eq 'You dont have push access to repo'
expect(branch_exists?('feature')).to be true expect(branch_exists?('feature')).to be true
end 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
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