gitlab-org--gitlab-foss/spec/services/wiki_pages/destroy_service_spec.rb
Alex Kalderimis 7320758611 Count wiki page creation
This adds a counter to count page creation, which is reflected in the
usage-data we collect.

The number created is stored in Redis, avoiding DB access.
2019-07-21 01:26:19 +00:00

36 lines
918 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe WikiPages::DestroyService do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:page) { create(:wiki_page) }
subject(:service) { described_class.new(project, user) }
before do
project.add_developer(user)
end
describe '#execute' do
it 'executes webhooks' do
expect(service).to receive(:execute_hooks).once
.with(instance_of(WikiPage), 'delete')
service.execute(page)
end
it 'increments the delete count' do
counter = Gitlab::UsageDataCounters::WikiPageCounter
expect { service.execute(page) }.to change { counter.read(:delete) }.by 1
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
end