diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/services/notes | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/services/notes')
-rw-r--r-- | spec/services/notes/create_service_spec.rb | 30 | ||||
-rw-r--r-- | spec/services/notes/destroy_service_spec.rb | 8 | ||||
-rw-r--r-- | spec/services/notes/quick_actions_service_spec.rb | 8 | ||||
-rw-r--r-- | spec/services/notes/update_service_spec.rb | 14 |
4 files changed, 43 insertions, 17 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) diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb index 0859c28cbe7..eebbdcc33b8 100644 --- a/spec/services/notes/destroy_service_spec.rb +++ b/spec/services/notes/destroy_service_spec.rb @@ -35,6 +35,14 @@ RSpec.describe Notes::DestroyService 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 'tracks merge request usage data' do + mr = create(:merge_request, source_project: project) + note = create(:note, project: project, noteable: mr) + expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).to receive(:track_remove_comment_action).with(note: note) + + described_class.new(project, user).execute(note) + end + context 'in a merge request' do let_it_be(:repo_project) { create(:project, :repository) } let_it_be(:merge_request) do diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb index 64aa845841b..c098500b78a 100644 --- a/spec/services/notes/quick_actions_service_spec.rb +++ b/spec/services/notes/quick_actions_service_spec.rb @@ -153,8 +153,8 @@ RSpec.describe Notes::QuickActionsService do expect(execute(note)).to be_empty end - it 'does not assign the milestone' do - expect { execute(note) }.not_to change { issue.reload.milestone } + it 'assigns the milestone' do + expect { execute(note) }.to change { issue.reload.milestone }.from(nil).to(milestone) end end @@ -195,8 +195,8 @@ RSpec.describe Notes::QuickActionsService do expect(execute(note)).to be_empty end - it 'does not remove the milestone' do - expect { execute(note) }.not_to change { issue.reload.milestone } + it 'removes the milestone' do + expect { execute(note) }.to change { issue.reload.milestone }.from(milestone).to(nil) end end diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb index e2f51c9af67..902fd9958f8 100644 --- a/spec/services/notes/update_service_spec.rb +++ b/spec/services/notes/update_service_spec.rb @@ -49,11 +49,12 @@ RSpec.describe Notes::UpdateService do it 'does not track usage data when params is blank' do expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).not_to receive(:track_issue_comment_edited_action) + expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_edit_comment_action) update_note({}) end - it 'tracks usage data', :clean_gitlab_redis_shared_state do + it 'tracks issue usage data', :clean_gitlab_redis_shared_state do event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED counter = Gitlab::UsageDataCounters::HLLRedisCounter @@ -63,6 +64,17 @@ RSpec.describe Notes::UpdateService do end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1) end + context 'when the notable is a merge request' do + let(:merge_request) { create(:merge_request, source_project: project) } + let(:note) { create(:note, project: project, noteable: merge_request, author: user, note: "Old note #{user2.to_reference}") } + + it 'tracks merge request usage data' do + expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).to receive(:track_edit_comment_action).with(note: note) + + update_note(note: 'new text') + end + end + context 'with system note' do before do note.update_column(:system, true) |