2019-07-20 21:26:19 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe WikiPages::BaseService do
|
2019-07-20 21:26:19 -04:00
|
|
|
let(:project) { double('project') }
|
|
|
|
let(:user) { double('user') }
|
|
|
|
|
|
|
|
describe '#increment_usage' do
|
|
|
|
counter = Gitlab::UsageDataCounters::WikiPageCounter
|
|
|
|
error = counter::UnknownEvent
|
|
|
|
|
2020-05-13 08:07:54 -04:00
|
|
|
let(:subject) { bad_service_class.new(container: project, current_user: user) }
|
2019-07-20 21:26:19 -04:00
|
|
|
|
2020-03-24 08:09:42 -04:00
|
|
|
context 'the class implements usage_counter_action incorrectly' do
|
|
|
|
let(:bad_service_class) do
|
|
|
|
Class.new(described_class) do
|
|
|
|
def usage_counter_action
|
|
|
|
:bad_event
|
|
|
|
end
|
2019-07-20 21:26:19 -04:00
|
|
|
end
|
|
|
|
end
|
2020-03-24 08:09:42 -04:00
|
|
|
|
|
|
|
it 'raises an error on unknown events' do
|
|
|
|
expect { subject.send(:increment_usage) }.to raise_error(error)
|
|
|
|
end
|
2019-07-20 21:26:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|