summaryrefslogtreecommitdiff
path: root/spec/services/wiki_pages/destroy_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/wiki_pages/destroy_service_spec.rb')
-rw-r--r--spec/services/wiki_pages/destroy_service_spec.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/spec/services/wiki_pages/destroy_service_spec.rb b/spec/services/wiki_pages/destroy_service_spec.rb
index 350a7eb123b..e205bedfdb9 100644
--- a/spec/services/wiki_pages/destroy_service_spec.rb
+++ b/spec/services/wiki_pages/destroy_service_spec.rb
@@ -15,8 +15,7 @@ describe WikiPages::DestroyService do
describe '#execute' do
it 'executes webhooks' do
- expect(service).to receive(:execute_hooks).once
- .with(instance_of(WikiPage), 'delete')
+ expect(service).to receive(:execute_hooks).once.with(page)
service.execute(page)
end
@@ -27,10 +26,29 @@ describe WikiPages::DestroyService do
expect { service.execute(page) }.to change { counter.read(:delete) }.by 1
end
+ it 'creates a new wiki page deletion event' do
+ expect { service.execute(page) }.to change { Event.count }.by 1
+
+ expect(Event.recent.first).to have_attributes(
+ action: Event::DESTROYED,
+ target: have_attributes(canonical_slug: page.slug)
+ )
+ end
+
it 'does not increment the delete count if the deletion failed' do
counter = Gitlab::UsageDataCounters::WikiPageCounter
expect { service.execute(nil) }.not_to change { counter.read(:delete) }
end
end
+
+ context 'the feature is disabled' do
+ before do
+ stub_feature_flags(wiki_events: false)
+ end
+
+ it 'does not record the activity' do
+ expect { service.execute(page) }.not_to change(Event, :count)
+ end
+ end
end