summaryrefslogtreecommitdiff
path: root/spec/requests/abuse_reports_controller_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-23 12:08:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-23 12:08:48 +0000
commit8137303e47baaff97a36396cfb05efc0d99879a2 (patch)
tree89dc777fd2d63e259e4b8b2d781baf472d3429a0 /spec/requests/abuse_reports_controller_spec.rb
parent5b1258ee90fb29779d6c9da3f488ebff61e243a3 (diff)
downloadgitlab-ce-8137303e47baaff97a36396cfb05efc0d99879a2.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/abuse_reports_controller_spec.rb')
-rw-r--r--spec/requests/abuse_reports_controller_spec.rb38
1 files changed, 35 insertions, 3 deletions
diff --git a/spec/requests/abuse_reports_controller_spec.rb b/spec/requests/abuse_reports_controller_spec.rb
index 49a80689c65..934f123e45b 100644
--- a/spec/requests/abuse_reports_controller_spec.rb
+++ b/spec/requests/abuse_reports_controller_spec.rb
@@ -5,9 +5,12 @@ require 'spec_helper'
RSpec.describe AbuseReportsController, feature_category: :insider_threat do
let(:reporter) { create(:user) }
let(:user) { create(:user) }
+ let(:abuse_category) { 'spam' }
+
let(:attrs) do
attributes_for(:abuse_report) do |hash|
hash[:user_id] = user.id
+ hash[:category] = abuse_category
end
end
@@ -55,8 +58,6 @@ RSpec.describe AbuseReportsController, feature_category: :insider_threat do
describe 'POST add_category', :aggregate_failures do
subject(:request) { post add_category_abuse_reports_path, params: request_params }
- let(:abuse_category) { 'spam' }
-
context 'when user is reported for abuse' do
let(:ref_url) { 'http://example.com' }
let(:request_params) do
@@ -80,6 +81,17 @@ RSpec.describe AbuseReportsController, feature_category: :insider_threat do
reported_from_url: ref_url
)
end
+
+ it 'tracks the snowplow event' do
+ subject
+
+ expect_snowplow_event(
+ category: 'ReportAbuse',
+ action: 'select_abuse_category',
+ property: abuse_category,
+ user: user
+ )
+ end
end
context 'when abuse_report is missing in params' do
@@ -149,15 +161,35 @@ RSpec.describe AbuseReportsController, feature_category: :insider_threat do
expect(response).to redirect_to root_path
end
+
+ it 'tracks the snowplow event' do
+ post abuse_reports_path(abuse_report: attrs)
+
+ expect_snowplow_event(
+ category: 'ReportAbuse',
+ action: 'submit_form',
+ property: abuse_category,
+ user: user
+ )
+ end
end
context 'with invalid attributes' do
- it 'redirects back to root' do
+ before do
attrs.delete(:user_id)
+ end
+
+ it 'redirects back to root' do
post abuse_reports_path(abuse_report: attrs)
expect(response).to redirect_to root_path
end
+
+ it 'does not track the snowplow event' do
+ post abuse_reports_path(abuse_report: attrs)
+
+ expect_no_snowplow_event
+ end
end
end
end