debian-mirror-gitlab/spec/services/resource_events/change_milestone_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.5 KiB
Ruby
Raw Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ResourceEvents::ChangeMilestoneService do
2020-10-24 23:57:45 +05:30
let_it_be(:timebox) { create(:milestone) }
let(:created_at_time) { Time.utc(2019, 12, 30) }
2021-03-11 19:13:27 +05:30
let(:add_timebox_args) { { old_milestone: nil } }
let(:remove_timebox_args) { { old_milestone: timebox } }
2020-10-24 23:57:45 +05:30
2020-05-24 23:13:21 +05:30
[:issue, :merge_request].each do |issuable|
2020-10-24 23:57:45 +05:30
it_behaves_like 'timebox(milestone or iteration) resource events creator', ResourceMilestoneEvent do
2021-01-29 00:20:46 +05:30
let_it_be(:resource) { create(issuable) } # rubocop:disable Rails/SaveBang
2020-05-24 23:13:21 +05:30
end
2020-04-08 14:13:33 +05:30
end
2023-01-13 00:05:48 +05:30
describe 'events tracking' do
let_it_be(:user) { create(:user) }
let(:resource) { create(resource_type, milestone: timebox, project: timebox.project) }
subject(:service_instance) { described_class.new(resource, user, old_milestone: nil) }
context 'when the resource is a work item' do
let(:resource_type) { :work_item }
it 'tracks work item usage data counters' do
expect(Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter)
.to receive(:track_work_item_milestone_changed_action)
.with(author: user)
service_instance.execute
end
end
context 'when the resource is not a work item' do
let(:resource_type) { :issue }
it 'does not track work item usage data counters' do
expect(Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter)
.not_to receive(:track_work_item_milestone_changed_action)
service_instance.execute
end
end
end
2020-04-08 14:13:33 +05:30
end