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>2023-01-09 15:07:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-09 15:07:31 +0300
commit1935f3e81b99c00697bf0b4d6a44d64068b34745 (patch)
treee2c42218945d0ae19c4566e844d4707513cc2fd6 /spec/features/abuse_report_spec.rb
parenta352bc8e72b948a834b0569d0d4288e95a9c529e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/abuse_report_spec.rb')
-rw-r--r--spec/features/abuse_report_spec.rb116
1 files changed, 101 insertions, 15 deletions
diff --git a/spec/features/abuse_report_spec.rb b/spec/features/abuse_report_spec.rb
index 87236530046..591b397119c 100644
--- a/spec/features/abuse_report_spec.rb
+++ b/spec/features/abuse_report_spec.rb
@@ -3,16 +3,24 @@
require 'spec_helper'
RSpec.describe 'Abuse reports', feature_category: :insider_threat do
- let_it_be(:another_user) { create(:user) }
-
+ let_it_be(:abusive_user) { create(:user, username: 'abuser_mcabusive') }
+ let_it_be(:reporter1) { create(:user, username: 'reporter_mcreporty') }
+ let_it_be(:reporter2) { create(:user) }
let_it_be(:project) { create(:project, :public) }
- let_it_be(:issue) { create(:issue, project: project, author: another_user) }
+ let_it_be(:issue) { create(:issue, project: project, author: abusive_user) }
+
+ let!(:group) do
+ create(:group).tap do |g|
+ g.add_owner(reporter1)
+ g.add_developer(abusive_user)
+ end
+ end
before do
- sign_in(create(:user))
+ sign_in(reporter1)
end
- it 'report abuse from an issue', :js do
+ it 'allows a user to be reported for abuse from an issue', :js do
visit project_issue_path(project, issue)
click_button 'Issue actions'
@@ -20,18 +28,39 @@ RSpec.describe 'Abuse reports', feature_category: :insider_threat do
wait_for_requests
- fill_in 'abuse_report_message', with: 'This user sends spam'
- click_button 'Send report'
+ fill_and_submit_form
expect(page).to have_content 'Thank you for your report'
+ end
+
+ it 'allows a user to be reported for abuse from their profile', :js do
+ visit user_path(abusive_user)
+
+ click_button 'Report abuse to administrator'
+
+ choose "They're posting spam."
+ click_button 'Next'
+
+ wait_for_requests
- visit user_path(another_user)
+ fill_and_submit_form
- expect(page).to have_button('Already reported for abuse')
+ expect(page).to have_content 'Thank you for your report'
+
+ visit user_path(abusive_user)
+
+ click_button 'Report abuse to administrator'
+
+ choose "They're posting spam."
+ click_button 'Next'
+
+ fill_and_submit_form
+
+ expect(page).to have_content 'You have already reported this user'
end
- it 'report abuse from profile', :js do
- visit user_path(another_user)
+ it 'allows multiple users to report a user', :js do
+ visit user_path(abusive_user)
click_button 'Report abuse to administrator'
@@ -40,13 +69,70 @@ RSpec.describe 'Abuse reports', feature_category: :insider_threat do
wait_for_requests
- fill_in 'abuse_report_message', with: 'This user sends spam'
- click_button 'Send report'
+ fill_and_submit_form
expect(page).to have_content 'Thank you for your report'
- visit user_path(another_user)
+ sign_out(reporter1)
+ sign_in(reporter2)
+
+ visit user_path(abusive_user)
- expect(page).to have_button('Already reported for abuse')
+ click_button 'Report abuse to administrator'
+
+ choose "They're posting spam."
+ click_button 'Next'
+
+ wait_for_requests
+
+ fill_and_submit_form
+
+ expect(page).to have_content 'Thank you for your report'
+ end
+
+ describe 'Cancel', :js do
+ context 'when ref_url is not present (e.g. visit user page then click on report abuse)' do
+ it 'links the user back to where abuse report was triggered' do
+ origin_url = user_path(abusive_user)
+
+ visit origin_url
+
+ click_button 'Report abuse to administrator'
+ choose "They're posting spam."
+ click_button 'Next'
+
+ wait_for_requests
+
+ click_link 'Cancel'
+
+ expect(page).to have_current_path(origin_url)
+ end
+ end
+
+ context 'when ref_url is present (e.g. user is reported from one of their MRs)' do
+ it 'links the user back to ref_url' do
+ ref_url = group_group_members_path(group)
+
+ visit ref_url
+
+ # visit abusive user's profile page
+ page.first('.js-user-link').click
+
+ click_button 'Report abuse to administrator'
+ choose "They're posting spam."
+ click_button 'Next'
+
+ click_link 'Cancel'
+
+ expect(page).to have_current_path(ref_url)
+ end
+ end
+ end
+
+ private
+
+ def fill_and_submit_form
+ fill_in 'abuse_report_message', with: 'This user sends spam'
+ click_button 'Send report'
end
end