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
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
......@@ -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)
......
......@@ -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
......
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