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-10 21:07:39 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-10 21:07:39 +0300
commit8cc4a6f23d41a1c57dc309130d2ce9ebc04d8334 (patch)
tree8391f5ee4f3391534131ae834b4b0a413845239e /spec/features/abuse_report_spec.rb
parent87f8fdb93cb1e63f8e9cedf7d3d00c8ade70b18c (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.rb141
1 files changed, 65 insertions, 76 deletions
diff --git a/spec/features/abuse_report_spec.rb b/spec/features/abuse_report_spec.rb
index 591b397119c..f9fa3e6e109 100644
--- a/spec/features/abuse_report_spec.rb
+++ b/spec/features/abuse_report_spec.rb
@@ -2,130 +2,119 @@
require 'spec_helper'
-RSpec.describe 'Abuse reports', feature_category: :insider_threat do
- 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) }
+RSpec.describe 'Abuse reports', :js, feature_category: :insider_threat do
+ let_it_be(:abusive_user) { create(:user) }
+
+ let_it_be(:reporter1) { create(:user) }
+
let_it_be(:project) { create(:project, :public) }
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(reporter1)
end
- it 'allows a user to be reported for abuse from an issue', :js do
- visit project_issue_path(project, issue)
+ context 'when reporting an issue for abuse' 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'
- click_link 'Report abuse to administrator'
+ click_button 'Issue actions'
+ click_link 'Report abuse to administrator'
- wait_for_requests
+ wait_for_requests
- fill_and_submit_form
+ fill_and_submit_form
- expect(page).to have_content 'Thank you for your report'
- end
+ 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)
+ it 'redirects backs to the issue when cancel button is clicked' do
+ visit project_issue_path(project, issue)
- click_button 'Report abuse to administrator'
+ click_button 'Issue actions'
+ click_link 'Report abuse to administrator'
- choose "They're posting spam."
- click_button 'Next'
+ wait_for_requests
- wait_for_requests
+ click_link 'Cancel'
- fill_and_submit_form
+ expect(page).to have_current_path(project_issue_path(project, issue))
+ end
+ end
- expect(page).to have_content 'Thank you for your report'
+ context 'when reporting a user profile for abuse' do
+ let_it_be(:reporter2) { create(:user) }
- visit user_path(abusive_user)
+ it 'allows a user to be reported for abuse from their profile' do
+ visit user_path(abusive_user)
- click_button 'Report abuse to administrator'
+ click_button 'Report abuse to administrator'
- choose "They're posting spam."
- click_button 'Next'
+ choose "They're posting spam."
+ click_button 'Next'
- fill_and_submit_form
+ wait_for_requests
- expect(page).to have_content 'You have already reported this user'
- end
+ fill_and_submit_form
- it 'allows multiple users to report a user', :js do
- visit user_path(abusive_user)
+ expect(page).to have_content 'Thank you for your report'
- click_button 'Report abuse to administrator'
+ visit user_path(abusive_user)
- choose "They're posting spam."
- click_button 'Next'
+ click_button 'Report abuse to administrator'
- wait_for_requests
+ choose "They're posting spam."
+ click_button 'Next'
- fill_and_submit_form
+ fill_and_submit_form
- expect(page).to have_content 'Thank you for your report'
+ expect(page).to have_content 'User has already been reported for abuse'
+ end
- sign_out(reporter1)
- sign_in(reporter2)
+ it 'allows multiple users to report a user' do
+ visit user_path(abusive_user)
- visit user_path(abusive_user)
+ click_button 'Report abuse to administrator'
- click_button 'Report abuse to administrator'
+ choose "They're posting spam."
+ click_button 'Next'
- choose "They're posting spam."
- click_button 'Next'
+ wait_for_requests
- wait_for_requests
+ fill_and_submit_form
- fill_and_submit_form
+ expect(page).to have_content 'Thank you for your report'
- expect(page).to have_content 'Thank you for your report'
- end
+ gitlab_sign_out
+ gitlab_sign_in(reporter2)
- 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 user_path(abusive_user)
- visit origin_url
+ click_button 'Report abuse to administrator'
- click_button 'Report abuse to administrator'
- choose "They're posting spam."
- click_button 'Next'
+ choose "They're posting spam."
+ click_button 'Next'
- wait_for_requests
+ wait_for_requests
- click_link 'Cancel'
+ fill_and_submit_form
- expect(page).to have_current_path(origin_url)
- end
+ expect(page).to have_content 'Thank you for your report'
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)
+ it 'redirects backs to user profile when cancel button is clicked' do
+ visit user_path(abusive_user)
- visit ref_url
+ click_button 'Report abuse to administrator'
- # visit abusive user's profile page
- page.first('.js-user-link').click
+ choose "They're posting spam."
+ click_button 'Next'
- click_button 'Report abuse to administrator'
- choose "They're posting spam."
- click_button 'Next'
+ wait_for_requests
- click_link 'Cancel'
+ click_link 'Cancel'
- expect(page).to have_current_path(ref_url)
- end
+ expect(page).to have_current_path(user_path(abusive_user))
end
end