gitlab-org--gitlab-foss/spec/services/wiki_pages/base_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

27 lines
727 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe WikiPages::BaseService do
let(:project) { double('project') }
let(:user) { double('user') }
subject(:service) { described_class.new(project, user, {}) }
describe '#increment_usage' do
counter = Gitlab::UsageDataCounters::WikiPageCounter
error = counter::UnknownEvent
it 'raises an error on unknown events' do
expect { subject.send(:increment_usage, :bad_event) }.to raise_error error
end
context 'the event is valid' do
counter::KNOWN_EVENTS.each do |e|
it "updates the #{e} counter" do
expect { subject.send(:increment_usage, e) }.to change { counter.read(e) }
end
end
end
end
end