Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-15 06:11:57 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-15 06:11:57 +0300
commit1b5891ee8ce8adc6877c462ea292eaee3c4ab30b (patch)
tree6773287f5bcf34597f131c64588c285c304f1301 /spec/services
parent25c9c07a16a8100809542eb209df4902f5ef427c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/notes/create_service_spec.rb33
-rw-r--r--spec/services/notes/destroy_service_spec.rb26
-rw-r--r--spec/services/notes/update_service_spec.rb34
-rw-r--r--spec/services/system_notes/issuables_service_spec.rb9
4 files changed, 69 insertions, 33 deletions
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index 53b75a3c991..ed64663260e 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -69,20 +69,31 @@ RSpec.describe Notes::CreateService do
end
end
- it 'tracks issue comment usage data', :clean_gitlab_redis_shared_state do
- event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED
- counter = Gitlab::UsageDataCounters::HLLRedisCounter
+ describe 'event tracking', :snowplow do
+ let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED }
+ let(:execute_create_service) { described_class.new(project, user, opts).execute }
- expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_added_action).with(author: user).and_call_original
- expect do
- described_class.new(project, user, opts).execute
- 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 issue comment usage data', :clean_gitlab_redis_shared_state do
+ counter = Gitlab::UsageDataCounters::HLLRedisCounter
- it 'does not track merge request usage data' do
- expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_create_comment_action)
+ expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_added_action)
+ .with(author: user, project: project)
+ .and_call_original
+ expect do
+ execute_create_service
+ end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
+ end
- described_class.new(project, user, opts).execute
+ it 'does not track merge request usage data' do
+ expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter).not_to receive(:track_create_comment_action)
+
+ execute_create_service
+ end
+
+ it_behaves_like 'issue_edit snowplow tracking' do
+ let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_ADDED }
+ subject(:service_action) { execute_create_service }
+ end
end
context 'in a merge request' do
diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb
index 55acdabef82..be95a4bb181 100644
--- a/spec/services/notes/destroy_service_spec.rb
+++ b/spec/services/notes/destroy_service_spec.rb
@@ -25,15 +25,25 @@ RSpec.describe Notes::DestroyService do
.to change { user.todos_pending_count }.from(1).to(0)
end
- it 'tracks issue comment removal usage data', :clean_gitlab_redis_shared_state do
- note = create(:note, project: project, noteable: issue)
- event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_REMOVED
- counter = Gitlab::UsageDataCounters::HLLRedisCounter
+ describe 'comment removed event tracking', :snowplow do
+ let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_REMOVED }
+ let(:note) { create(:note, project: project, noteable: issue) }
+ let(:service_action) { described_class.new(project, user).execute(note) }
+
+ it 'tracks issue comment removal usage data', :clean_gitlab_redis_shared_state do
+ counter = Gitlab::UsageDataCounters::HLLRedisCounter
+
+ expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_removed_action)
+ .with(author: user, project: project)
+ .and_call_original
+ expect do
+ service_action
+ end.to change { counter.unique_events(event_names: property, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
+ end
- expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_removed_action).with(author: user).and_call_original
- expect do
- described_class.new(project, user).execute(note)
- end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
+ it_behaves_like 'issue_edit snowplow tracking' do
+ subject(:execute_service_action) { service_action }
+ end
end
it 'tracks merge request usage data' do
diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb
index ae7bea30944..989ca7b8df1 100644
--- a/spec/services/notes/update_service_spec.rb
+++ b/spec/services/notes/update_service_spec.rb
@@ -47,21 +47,31 @@ RSpec.describe Notes::UpdateService do
end
end
- 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)
+ describe 'event tracking', :snowplow do
+ let(:event) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED }
- update_note({})
- end
+ 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)
- it 'tracks issue usage data', :clean_gitlab_redis_shared_state do
- event = Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED
- counter = Gitlab::UsageDataCounters::HLLRedisCounter
+ update_note({})
+ end
- expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_edited_action).with(author: user).and_call_original
- expect do
- update_note(note: 'new text')
- end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
+ it 'tracks issue usage data', :clean_gitlab_redis_shared_state do
+ counter = Gitlab::UsageDataCounters::HLLRedisCounter
+
+ expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_comment_edited_action)
+ .with(author: user, project: project)
+ .and_call_original
+ expect do
+ update_note(note: 'new text')
+ end.to change { counter.unique_events(event_names: event, start_date: 1.day.ago, end_date: 1.day.from_now) }.by(1)
+ end
+
+ it_behaves_like 'issue_edit snowplow tracking' do
+ let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_COMMENT_EDITED }
+ subject(:service_action) { update_note(note: 'new text') }
+ end
end
context 'when note text was changed' do
diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb
index 70f6ce8926c..d0e68bf0ddb 100644
--- a/spec/services/system_notes/issuables_service_spec.rb
+++ b/spec/services/system_notes/issuables_service_spec.rb
@@ -712,15 +712,20 @@ RSpec.describe ::SystemNotes::IssuablesService do
end
end
- context 'cloned to' do
+ context 'cloned to', :snowplow do
let(:direction) { :to }
it 'tracks usage' do
expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter)
- .to receive(:track_issue_cloned_action).with(author: author)
+ .to receive(:track_issue_cloned_action).with(author: author, project: project )
subject
end
+
+ it_behaves_like 'issue_edit snowplow tracking' do
+ let(:property) { Gitlab::UsageDataCounters::IssueActivityUniqueCounter::ISSUE_CLONED }
+ let(:user) { author }
+ end
end
end
end