Commit 1fc6f6cc authored by Mark Fletcher's avatar Mark Fletcher

Execute web hooks for WikiPage delete operation

* Add a new DestroyService for Wiki Pages
* Alter WikiPagesController to use the new service
parent a616b475
......@@ -84,7 +84,7 @@ class Projects::WikisController < Projects::ApplicationController
def destroy
@page = @project_wiki.find_page(params[:id])
@page&.delete
WikiPages::DestroyService.new(@project, current_user).execute(@page)
redirect_to(
namespace_project_wiki_path(@project.namespace, @project, :home),
......
module WikiPages
class DestroyService < WikiPages::BaseService
def execute(page)
if page&.delete
execute_hooks(page, 'delete')
end
page
end
end
end
---
title: Execute web hooks for WikiPage delete operation
merge_request: 8198
author:
......@@ -714,7 +714,7 @@ X-Gitlab-Event: Merge Request Hook
### Wiki Page events
Triggered when a wiki page is created or edited.
Triggered when a wiki page is created, edited or deleted.
**Request Header**:
......
require 'spec_helper'
describe WikiPages::DestroyService, services: true do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
let(:wiki_page) { create(:wiki_page) }
let(:service) { described_class.new(project, user) }
describe '#execute' do
before do
allow(service).to receive(:execute_hooks)
project.add_master(user)
end
it 'executes webhooks' do
service.execute(wiki_page)
expect(service).to have_received(:execute_hooks).once.with(wiki_page, 'delete')
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