diff options
Diffstat (limited to 'spec/services/notes/create_service_spec.rb')
-rw-r--r-- | spec/services/notes/create_service_spec.rb | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index 3118956951e..20f06619e02 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -78,6 +78,12 @@ RSpec.describe Notes::CreateService do end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1) end + it 'does not track merge request usage data' do + expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_create_comment_action) + + described_class.new(project, user, opts).execute + end + context 'in a merge request' do let_it_be(:project_with_repo) { create(:project, :repository) } let_it_be(:merge_request) do @@ -85,18 +91,6 @@ RSpec.describe Notes::CreateService do target_project: project_with_repo) end - context 'issue comment usage data' do - let(:opts) do - { note: 'Awesome comment', noteable_type: 'MergeRequest', noteable_id: merge_request.id } - end - - it 'does not track' do - expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_comment_added_action) - - described_class.new(project, user, opts).execute - end - end - context 'noteable highlight cache clearing' do let(:position) do Gitlab::Diff::Position.new(old_path: "files/ruby/popen.rb", @@ -119,6 +113,18 @@ RSpec.describe Notes::CreateService do .to receive(:unfolded_diff?) { true } end + it 'does not track issue comment usage data' do + expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_comment_added_action) + + described_class.new(project_with_repo, user, new_opts).execute + end + + it 'tracks merge request usage data' do + expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).to receive(:track_create_comment_action).with(note: kind_of(Note)) + + described_class.new(project_with_repo, user, new_opts).execute + end + it 'clears noteable diff cache when it was unfolded for the note position' do expect_any_instance_of(Gitlab::Diff::HighlightCache).to receive(:clear) |