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:
Diffstat (limited to 'spec/features/issues')
-rw-r--r--spec/features/issues/filtered_search/dropdown_assignee_spec.rb73
-rw-r--r--spec/features/issues/filtered_search/filter_issues_spec.rb10
-rw-r--r--spec/features/issues/form_spec.rb115
-rw-r--r--spec/features/issues/gfm_autocomplete_spec.rb22
-rw-r--r--spec/features/issues/incident_issue_spec.rb2
-rw-r--r--spec/features/issues/issue_detail_spec.rb4
-rw-r--r--spec/features/issues/issue_header_spec.rb8
-rw-r--r--spec/features/issues/issue_sidebar_spec.rb7
-rw-r--r--spec/features/issues/move_spec.rb2
-rw-r--r--spec/features/issues/spam_akismet_issue_creation_spec.rb178
-rw-r--r--spec/features/issues/spam_issues_spec.rb188
-rw-r--r--spec/features/issues/user_creates_branch_and_merge_request_spec.rb4
-rw-r--r--spec/features/issues/user_creates_issue_spec.rb4
-rw-r--r--spec/features/issues/user_sorts_issues_spec.rb8
-rw-r--r--spec/features/issues/user_views_issue_spec.rb2
15 files changed, 415 insertions, 212 deletions
diff --git a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb
index e873ebb21c4..3ba2f7e788d 100644
--- a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb
+++ b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb
@@ -12,14 +12,14 @@ RSpec.describe 'Dropdown assignee', :js do
let(:js_dropdown_assignee) { '#js-dropdown-assignee' }
let(:filter_dropdown) { find("#{js_dropdown_assignee} .filter-dropdown") }
- before do
- project.add_maintainer(user)
- sign_in(user)
+ describe 'behavior' do
+ before do
+ project.add_maintainer(user)
+ sign_in(user)
- visit project_issues_path(project)
- end
+ visit project_issues_path(project)
+ end
- describe 'behavior' do
it 'loads all the assignees when opened' do
input_filtered_search('assignee:=', submit: false, extra_space: false)
@@ -35,6 +35,11 @@ RSpec.describe 'Dropdown assignee', :js do
describe 'selecting from dropdown without Ajax call' do
before do
+ project.add_maintainer(user)
+ sign_in(user)
+
+ visit project_issues_path(project)
+
Gitlab::Testing::RequestBlockerMiddleware.block_requests!
input_filtered_search('assignee:=', submit: false, extra_space: false)
end
@@ -51,4 +56,60 @@ RSpec.describe 'Dropdown assignee', :js do
expect_filtered_search_input_empty
end
end
+
+ context 'assignee suggestions' do
+ let!(:group) { create(:group) }
+ let!(:group_project) { create(:project, namespace: group) }
+ let!(:group_user) { create(:user) }
+
+ let!(:subgroup) { create(:group, parent: group) }
+ let!(:subgroup_project) { create(:project, namespace: subgroup) }
+ let!(:subgroup_project_issue) { create(:issue, project: subgroup_project) }
+ let!(:subgroup_user) { create(:user) }
+
+ let!(:subsubgroup) { create(:group, parent: subgroup) }
+ let!(:subsubgroup_project) { create(:project, namespace: subsubgroup) }
+ let!(:subsubgroup_user) { create(:user) }
+
+ let!(:invited_to_group_group) { create(:group) }
+ let!(:invited_to_group_group_user) { create(:user) }
+
+ let!(:invited_to_project_group) { create(:group) }
+ let!(:invited_to_project_group_user) { create(:user) }
+
+ before do
+ group.add_developer(group_user)
+ subgroup.add_developer(subgroup_user)
+ subsubgroup.add_developer(subsubgroup_user)
+ invited_to_group_group.add_developer(invited_to_group_group_user)
+ invited_to_project_group.add_developer(invited_to_project_group_user)
+
+ create(:group_group_link, shared_group: subgroup, shared_with_group: invited_to_group_group)
+ create(:project_group_link, project: subgroup_project, group: invited_to_project_group)
+
+ sign_in(subgroup_user)
+ end
+
+ it 'shows inherited, direct, and invited group members but not descendent members', :aggregate_failures do
+ visit issues_group_path(subgroup)
+
+ input_filtered_search('assignee:=', submit: false, extra_space: false)
+
+ expect(page).to have_text group_user.name
+ expect(page).to have_text subgroup_user.name
+ expect(page).to have_text invited_to_group_group_user.name
+ expect(page).not_to have_text subsubgroup_user.name
+ expect(page).not_to have_text invited_to_project_group_user.name
+
+ visit project_issues_path(subgroup_project)
+
+ input_filtered_search('assignee:=', submit: false, extra_space: false)
+
+ expect(page).to have_text group_user.name
+ expect(page).to have_text subgroup_user.name
+ expect(page).to have_text invited_to_project_group_user.name
+ expect(page).not_to have_text subsubgroup_user.name
+ expect(page).not_to have_text invited_to_group_group_user.name
+ end
+ end
end
diff --git a/spec/features/issues/filtered_search/filter_issues_spec.rb b/spec/features/issues/filtered_search/filter_issues_spec.rb
index edf3df7c16e..1375384d1aa 100644
--- a/spec/features/issues/filtered_search/filter_issues_spec.rb
+++ b/spec/features/issues/filtered_search/filter_issues_spec.rb
@@ -497,6 +497,8 @@ RSpec.describe 'Filter issues', :js do
end
it 'filters issues by searched text containing special characters' do
+ stub_feature_flags(issues_full_text_search: false)
+
issue = create(:issue, project: project, author: user, title: "issue with !@\#{$%^&*()-+")
search = '!@#{$%^&*()-+'
@@ -514,6 +516,14 @@ RSpec.describe 'Filter issues', :js do
expect_no_issues_list
expect_filtered_search_input(search)
end
+
+ it 'filters issues by issue reference' do
+ search = '#1'
+ input_filtered_search(search)
+
+ expect_issues_list_count(1)
+ expect_filtered_search_input(search)
+ end
end
context 'searched text with other filters' do
diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb
index b26f65316c5..0700423983f 100644
--- a/spec/features/issues/form_spec.rb
+++ b/spec/features/issues/form_spec.rb
@@ -5,19 +5,22 @@ require 'spec_helper'
RSpec.describe 'New/edit issue', :js do
include ActionView::Helpers::JavaScriptHelper
- let_it_be(:project) { create(:project) }
+ let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
let_it_be(:user2) { create(:user) }
+ let_it_be(:guest) { create(:user) }
let_it_be(:milestone) { create(:milestone, project: project) }
let_it_be(:label) { create(:label, project: project) }
let_it_be(:label2) { create(:label, project: project) }
let_it_be(:issue) { create(:issue, project: project, assignees: [user], milestone: milestone) }
+ let_it_be(:confidential_issue) { create(:issue, project: project, assignees: [user], milestone: milestone, confidential: true) }
let(:current_user) { user }
before_all do
project.add_maintainer(user)
project.add_maintainer(user2)
+ project.add_guest(guest)
end
before do
@@ -184,6 +187,14 @@ RSpec.describe 'New/edit issue', :js do
end
end
+ it 'displays an error message when submitting an invalid form' do
+ click_button 'Create issue'
+
+ page.within('[data-testid="issue-title-input-field"]') do
+ expect(page).to have_text(_('This field is required.'))
+ end
+ end
+
it 'correctly updates the dropdown toggle when removing a label' do
click_button 'Labels'
@@ -310,6 +321,108 @@ RSpec.describe 'New/edit issue', :js do
end
end
+ describe 'new issue with query parameters' do
+ before do
+ project.repository.create_file(
+ current_user,
+ '.gitlab/issue_templates/test_template.md',
+ 'description from template',
+ message: 'Add test_template.md',
+ branch_name: project.default_branch_or_main
+ )
+ end
+
+ after do
+ project.repository.delete_file(
+ current_user,
+ '.gitlab/issue_templates/test_template.md',
+ message: 'Remove test_template.md',
+ branch_name: project.default_branch_or_main
+ )
+ end
+
+ it 'leaves the description blank if no query parameters are specified' do
+ visit new_project_issue_path(project)
+
+ expect(find('#issue_description').value).to be_empty
+ end
+
+ it 'fills the description from the issue[description] query parameter' do
+ visit new_project_issue_path(project, issue: { description: 'description from query parameter' })
+
+ expect(find('#issue_description').value).to match('description from query parameter')
+ end
+
+ it 'fills the description from the issuable_template query parameter' do
+ visit new_project_issue_path(project, issuable_template: 'test_template')
+ wait_for_requests
+
+ expect(find('#issue_description').value).to match('description from template')
+ end
+
+ it 'fills the description from the issuable_template and issue[description] query parameters' do
+ visit new_project_issue_path(project, issuable_template: 'test_template', issue: { description: 'description from query parameter' })
+ wait_for_requests
+
+ expect(find('#issue_description').value).to match('description from template\ndescription from query parameter')
+ end
+ end
+
+ describe 'new issue from related issue' do
+ it 'does not offer to link the new issue to any other issues if the URL parameter is absent' do
+ visit new_project_issue_path(project)
+ expect(page).not_to have_selector '#add_related_issue'
+ expect(page).not_to have_text "Relate to"
+ end
+
+ context 'guest' do
+ let(:current_user) { guest }
+
+ it 'does not offer to link the new issue to an issue that the user does not have access to' do
+ visit new_project_issue_path(project, { add_related_issue: confidential_issue.iid })
+ expect(page).not_to have_selector '#add_related_issue'
+ expect(page).not_to have_text "Relate to"
+ end
+ end
+
+ it 'links the new issue and the issue of origin' do
+ visit new_project_issue_path(project, { add_related_issue: issue.iid })
+ expect(page).to have_selector '#add_related_issue'
+ expect(page).to have_text "Relate to issue \##{issue.iid}"
+ expect(page).to have_text 'Adds this issue as related to the issue it was created from'
+ fill_in 'issue_title', with: 'title'
+ click_button 'Create issue'
+ page.within '#related-issues' do
+ expect(page).to have_text "\##{issue.iid}"
+ end
+ end
+
+ it 'links the new incident and the incident of origin' do
+ incident = create(:incident, project: project)
+ visit new_project_issue_path(project, { add_related_issue: incident.iid })
+ expect(page).to have_selector '#add_related_issue'
+ expect(page).to have_text "Relate to incident \##{incident.iid}"
+ expect(page).to have_text 'Adds this incident as related to the incident it was created from'
+ fill_in 'issue_title', with: 'title'
+ click_button 'Create issue'
+ page.within '#related-issues' do
+ expect(page).to have_text "\##{incident.iid}"
+ end
+ end
+
+ it 'does not link the new issue to any other issues if the checkbox is not checked' do
+ visit new_project_issue_path(project, { add_related_issue: issue.iid })
+ expect(page).to have_selector '#add_related_issue'
+ expect(page).to have_text "Relate to issue \##{issue.iid}"
+ uncheck "Relate to issue \##{issue.iid}"
+ fill_in 'issue_title', with: 'title'
+ click_button 'Create issue'
+ page.within '#related-issues' do
+ expect(page).not_to have_text "\##{issue.iid}"
+ end
+ end
+ end
+
describe 'edit issue' do
before do
visit edit_project_issue_path(project, issue)
diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb
index b4d1b0aeab9..6f4a13c5fad 100644
--- a/spec/features/issues/gfm_autocomplete_spec.rb
+++ b/spec/features/issues/gfm_autocomplete_spec.rb
@@ -111,6 +111,20 @@ RSpec.describe 'GFM autocomplete', :js do
fill_in 'Comment', with: "test\n\n@"
expect(find_autocomplete_menu).to be_visible
end
+
+ it 'does not open label autocomplete menu after strikethrough', :aggregate_failures do
+ fill_in 'Comment', with: "~~"
+ expect(page).not_to have_css('.atwho-view')
+
+ fill_in 'Comment', with: "~~gone~~"
+ expect(page).not_to have_css('.atwho-view')
+
+ fill_in 'Comment', with: "~"
+ expect(find_autocomplete_menu).to be_visible
+
+ fill_in 'Comment', with: "test\n\n~"
+ expect(find_autocomplete_menu).to be_visible
+ end
end
context 'xss checks' do
@@ -406,6 +420,14 @@ RSpec.describe 'GFM autocomplete', :js do
end
end
end
+
+ context 'when typing enter for autocomplete in a markdown list' do
+ it 'does not create a new list item' do
+ fill_in 'Comment', with: "- @#{user.username}\n"
+
+ expect(find_field('Comment').value).to eq "- @#{user.username}\n"
+ end
+ end
end
private
diff --git a/spec/features/issues/incident_issue_spec.rb b/spec/features/issues/incident_issue_spec.rb
index 3033a138551..2956ddede2e 100644
--- a/spec/features/issues/incident_issue_spec.rb
+++ b/spec/features/issues/incident_issue_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe 'Incident Detail', :js do
incident_tabs = find('[data-testid="incident-tabs"]')
aggregate_failures 'shows title and Summary tab' do
- expect(find('h2')).to have_content(incident.title)
+ expect(find('h1')).to have_content(incident.title)
expect(incident_tabs).to have_content('Summary')
expect(incident_tabs).to have_content(incident.description)
end
diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb
index b37c8e9d1cf..88709d66887 100644
--- a/spec/features/issues/issue_detail_spec.rb
+++ b/spec/features/issues/issue_detail_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe 'Issue Detail', :js do
it 'shows the issue' do
page.within('.issuable-details') do
- expect(find('h2')).to have_content(issue.title)
+ expect(find('h1')).to have_content(issue.title)
end
end
end
@@ -85,7 +85,7 @@ RSpec.describe 'Issue Detail', :js do
it 'shows the issue' do
page.within('.issuable-details') do
- expect(find('h2')).to have_content(issue.reload.title)
+ expect(find('h1')).to have_content(issue.reload.title)
end
end
end
diff --git a/spec/features/issues/issue_header_spec.rb b/spec/features/issues/issue_header_spec.rb
index 3e27ce81860..165015013dd 100644
--- a/spec/features/issues/issue_header_spec.rb
+++ b/spec/features/issues/issue_header_spec.rb
@@ -25,8 +25,8 @@ RSpec.describe 'issue header', :js do
click_button 'Issue actions'
end
- it 'shows the "New issue", "Report abuse", and "Delete issue" items', :aggregate_failures do
- expect(page).to have_link 'New issue'
+ it 'shows the "New related issue", "Report abuse", and "Delete issue" items', :aggregate_failures do
+ expect(page).to have_link 'New related issue'
expect(page).to have_link 'Report abuse'
expect(page).to have_button 'Delete issue'
expect(page).not_to have_link 'Submit as spam'
@@ -114,8 +114,8 @@ RSpec.describe 'issue header', :js do
click_button 'Issue actions'
end
- it 'only shows the "New issue" and "Report abuse" items', :aggregate_failures do
- expect(page).to have_link 'New issue'
+ it 'only shows the "New related issue" and "Report abuse" items', :aggregate_failures do
+ expect(page).to have_link 'New related issue'
expect(page).to have_link 'Report abuse'
expect(page).not_to have_link 'Submit as spam'
expect(page).not_to have_button 'Delete issue'
diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb
index 868946814c3..aaa478378a9 100644
--- a/spec/features/issues/issue_sidebar_spec.rb
+++ b/spec/features/issues/issue_sidebar_spec.rb
@@ -106,6 +106,7 @@ RSpec.describe 'Issue Sidebar' do
end
context 'when GraphQL assignees widget feature flag is enabled' do
+ # TODO: Move to shared examples when feature flag is removed: https://gitlab.com/gitlab-org/gitlab/-/issues/328185
context 'when a privileged user can invite' do
it 'shows a link for inviting members and launches invite modal' do
project.add_maintainer(user)
@@ -236,6 +237,12 @@ RSpec.describe 'Issue Sidebar' do
it_behaves_like 'labels sidebar widget'
end
+ context 'escalation status', :js do
+ it 'is not available for default issue type' do
+ expect(page).not_to have_selector('.block.escalation-status')
+ end
+ end
+
context 'interacting with collapsed sidebar', :js do
collapsed_sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed'
expanded_sidebar_selector = 'aside.right-sidebar.right-sidebar-expanded'
diff --git a/spec/features/issues/move_spec.rb b/spec/features/issues/move_spec.rb
index ee2fbf0865e..054b7b3855b 100644
--- a/spec/features/issues/move_spec.rb
+++ b/spec/features/issues/move_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe 'issue move to another project' do
expect(page).to have_content("Text with #{cross_reference}#{mr.to_reference}")
expect(page).to have_content("moved from #{cross_reference}#{issue.to_reference}")
expect(page).to have_content(issue.title)
- expect(page.current_path).to include project_path(new_project)
+ expect(page).to have_current_path(%r(#{project_path(new_project)}))
end
it 'searching project dropdown', :js do
diff --git a/spec/features/issues/spam_akismet_issue_creation_spec.rb b/spec/features/issues/spam_akismet_issue_creation_spec.rb
new file mode 100644
index 00000000000..4cc4c4cf607
--- /dev/null
+++ b/spec/features/issues/spam_akismet_issue_creation_spec.rb
@@ -0,0 +1,178 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Spam detection on issue creation', :js do
+ include StubENV
+
+ let(:project) { create(:project, :public) }
+ let(:user) { create(:user) }
+
+ include_context 'includes Spam constants'
+
+ before do
+ stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+
+ Gitlab::CurrentSettings.update!(
+ akismet_enabled: true,
+ akismet_api_key: 'testkey',
+ spam_check_api_key: 'testkey',
+ recaptcha_enabled: true,
+ recaptcha_site_key: 'test site key',
+ recaptcha_private_key: 'test private key'
+ )
+
+ project.add_maintainer(user)
+ sign_in(user)
+ visit new_project_issue_path(project)
+
+ fill_in 'issue_title', with: 'issue title'
+ fill_in 'issue_description', with: 'issue description'
+ end
+
+ shared_examples 'disallows issue creation' do
+ it 'disallows issue creation' do
+ click_button 'Create issue'
+
+ expect(page).to have_content('discarded')
+ expect(page).not_to have_css('.recaptcha')
+ expect(page).not_to have_content('issue title')
+ end
+ end
+
+ shared_examples 'allows issue creation with CAPTCHA' do
+ it 'allows issue creation' do
+ click_button 'Create issue'
+
+ # it is impossible to test reCAPTCHA automatically and there is no possibility to fill in recaptcha
+ # reCAPTCHA verification is skipped in test environment and it always returns true
+ expect(page).not_to have_content('issue title')
+ expect(page).to have_css('.recaptcha')
+
+ click_button 'Create issue'
+
+ expect(page.find('.issue-details h1.title')).to have_content('issue title')
+ expect(page.find('.issue-details .description')).to have_content('issue description')
+ end
+ end
+
+ shared_examples 'allows issue creation without CAPTCHA' do
+ it 'allows issue creation without need to solve CAPTCHA' do
+ click_button 'Create issue'
+
+ expect(page).not_to have_css('.recaptcha')
+ expect(page.find('.issue-details h1.title')).to have_content('issue title')
+ expect(page.find('.issue-details .description')).to have_content('issue description')
+ end
+ end
+
+ shared_examples 'creates a spam_log record' do
+ it 'creates a spam_log record' do
+ expect { click_button 'Create issue' }
+ .to log_spam(title: 'issue title', description: 'issue description', user_id: user.id, noteable_type: 'Issue')
+ end
+ end
+
+ shared_examples 'does not create a spam_log record' do
+ it 'does not creates a spam_log record' do
+ expect { click_button 'Create issue' }
+ .not_to log_spam(title: 'issue title', description: 'issue description', user_id: user.id, noteable_type: 'Issue')
+ end
+ end
+
+ shared_context 'when spammable is identified as possible spam' do
+ before do
+ allow_next_instance_of(Spam::AkismetService) do |akismet_service|
+ allow(akismet_service).to receive(:spam?).and_return(true)
+ end
+ end
+ end
+
+ shared_context 'when spammable is not identified as possible spam' do
+ before do
+ allow_next_instance_of(Spam::AkismetService) do |akismet_service|
+ allow(akismet_service).to receive(:spam?).and_return(false)
+ end
+ end
+ end
+
+ shared_context 'when CAPTCHA is enabled' do
+ before do
+ stub_application_setting(recaptcha_enabled: true)
+ end
+ end
+
+ shared_context 'when CAPTCHA is not enabled' do
+ before do
+ stub_application_setting(recaptcha_enabled: false)
+ end
+ end
+
+ shared_context 'when allow_possible_spam feature flag is true' do
+ before do
+ stub_feature_flags(allow_possible_spam: true)
+ end
+ end
+
+ shared_context 'when allow_possible_spam feature flag is false' do
+ before do
+ stub_feature_flags(allow_possible_spam: false)
+ end
+ end
+
+ describe 'spam handling' do
+ # verdict, spam_flagged, captcha_enabled, allow_possible_spam_flag, creates_spam_log
+ # TODO: Add example for BLOCK_USER verdict when we add support for testing SpamCheck - see https://gitlab.com/groups/gitlab-org/-/epics/5527#lacking-coverage-for-spamcheck-vs-akismet
+ # DISALLOW, true, false, false, true
+ # CONDITIONAL_ALLOW, true, true, false, true
+ # OVERRIDE_VIA_ALLOW_POSSIBLE_SPAM, true, true, true, true
+ # OVERRIDE_VIA_ALLOW_POSSIBLE_SPAM, true, false, true, true
+ # ALLOW, false, true, false, false
+ # TODO: Add example for NOOP verdict when we add support for testing SpamCheck - see https://gitlab.com/groups/gitlab-org/-/epics/5527#lacking-coverage-for-spamcheck-vs-akismet
+
+ context 'DISALLOW: spam_flagged=true, captcha_enabled=true, allow_possible_spam=true' do
+ include_context 'when spammable is identified as possible spam'
+ include_context 'when CAPTCHA is enabled'
+ include_context 'when allow_possible_spam feature flag is true'
+
+ it_behaves_like 'allows issue creation without CAPTCHA'
+ it_behaves_like 'creates a spam_log record'
+ end
+
+ context 'CONDITIONAL_ALLOW: spam_flagged=true, captcha_enabled=true, allow_possible_spam=false' do
+ include_context 'when spammable is identified as possible spam'
+ include_context 'when CAPTCHA is enabled'
+ include_context 'when allow_possible_spam feature flag is false'
+
+ it_behaves_like 'allows issue creation with CAPTCHA'
+ it_behaves_like 'creates a spam_log record'
+ end
+
+ context 'OVERRIDE_VIA_ALLOW_POSSIBLE_SPAM: spam_flagged=true, captcha_enabled=true, allow_possible_spam=true' do
+ include_context 'when spammable is identified as possible spam'
+ include_context 'when CAPTCHA is enabled'
+ include_context 'when allow_possible_spam feature flag is true'
+
+ it_behaves_like 'allows issue creation without CAPTCHA'
+ it_behaves_like 'creates a spam_log record'
+ end
+
+ context 'OVERRIDE_VIA_ALLOW_POSSIBLE_SPAM: spam_flagged=true, captcha_enabled=false, allow_possible_spam=true' do
+ include_context 'when spammable is identified as possible spam'
+ include_context 'when CAPTCHA is not enabled'
+ include_context 'when allow_possible_spam feature flag is true'
+
+ it_behaves_like 'allows issue creation without CAPTCHA'
+ it_behaves_like 'creates a spam_log record'
+ end
+
+ context 'ALLOW: spam_flagged=false, captcha_enabled=true, allow_possible_spam=false' do
+ include_context 'when spammable is not identified as possible spam'
+ include_context 'when CAPTCHA is not enabled'
+ include_context 'when allow_possible_spam feature flag is false'
+
+ it_behaves_like 'allows issue creation without CAPTCHA'
+ it_behaves_like 'does not create a spam_log record'
+ end
+ end
+end
diff --git a/spec/features/issues/spam_issues_spec.rb b/spec/features/issues/spam_issues_spec.rb
deleted file mode 100644
index 70d7deadec3..00000000000
--- a/spec/features/issues/spam_issues_spec.rb
+++ /dev/null
@@ -1,188 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe 'New issue', :js do
- include StubENV
-
- let(:project) { create(:project, :public) }
- let(:user) { create(:user)}
-
- before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
-
- Gitlab::CurrentSettings.update!(
- akismet_enabled: true,
- akismet_api_key: 'testkey',
- spam_check_api_key: 'testkey',
- recaptcha_enabled: true,
- recaptcha_site_key: 'test site key',
- recaptcha_private_key: 'test private key'
- )
-
- project.add_maintainer(user)
- sign_in(user)
- end
-
- context 'when SpamVerdictService disallows' do
- include_context 'includes Spam constants'
-
- before do
- allow_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
- allow(verdict_service).to receive(:execute).and_return(DISALLOW)
- end
-
- visit new_project_issue_path(project)
- end
-
- context 'when allow_possible_spam feature flag is false' do
- before do
- stub_feature_flags(allow_possible_spam: false)
-
- fill_in 'issue_title', with: 'issue title'
- fill_in 'issue_description', with: 'issue description'
- end
-
- it 'rejects issue creation' do
- click_button 'Create issue'
-
- expect(page).to have_content('discarded')
- expect(page).not_to have_content('potential spam')
- expect(page).not_to have_content('issue title')
- end
-
- it 'creates a spam log record' do
- expect { click_button 'Create issue' }
- .to log_spam(title: 'issue title', description: 'issue description', user_id: user.id, noteable_type: 'Issue')
- end
- end
-
- context 'when allow_possible_spam feature flag is true' do
- before do
- fill_in 'issue_title', with: 'issue title'
- fill_in 'issue_description', with: 'issue description'
- end
-
- it 'allows issue creation' do
- click_button 'Create issue'
-
- expect(page.find('.issue-details h2.title')).to have_content('issue title')
- expect(page.find('.issue-details .description')).to have_content('issue description')
- end
-
- it 'creates a spam log record' do
- expect { click_button 'Create issue' }
- .to log_spam(title: 'issue title', description: 'issue description', user_id: user.id, noteable_type: 'Issue')
- end
- end
- end
-
- context 'when SpamVerdictService requires recaptcha' do
- include_context 'includes Spam constants'
-
- before do
- allow_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
- allow(verdict_service).to receive(:execute).and_return(CONDITIONAL_ALLOW)
- end
-
- visit new_project_issue_path(project)
- end
-
- context 'when recaptcha is enabled' do
- before do
- stub_application_setting(recaptcha_enabled: true)
- end
-
- context 'when allow_possible_spam feature flag is false' do
- before do
- stub_feature_flags(allow_possible_spam: false)
- end
-
- it 'creates an issue after solving reCaptcha' do
- fill_in 'issue_title', with: 'issue title'
- fill_in 'issue_description', with: 'issue description'
-
- click_button 'Create issue'
-
- # it is impossible to test reCAPTCHA automatically and there is no possibility to fill in recaptcha
- # reCAPTCHA verification is skipped in test environment and it always returns true
- expect(page).not_to have_content('issue title')
- expect(page).to have_css('.recaptcha')
-
- click_button 'Create issue'
-
- expect(page.find('.issue-details h2.title')).to have_content('issue title')
- expect(page.find('.issue-details .description')).to have_content('issue description')
- end
- end
-
- context 'when allow_possible_spam feature flag is true' do
- before do
- fill_in 'issue_title', with: 'issue title'
- fill_in 'issue_description', with: 'issue description'
- end
-
- it 'creates an issue without a need to solve reCAPTCHA' do
- click_button 'Create issue'
-
- expect(page).not_to have_css('.recaptcha')
- expect(page.find('.issue-details h2.title')).to have_content('issue title')
- expect(page.find('.issue-details .description')).to have_content('issue description')
- end
-
- it 'creates a spam log record' do
- expect { click_button 'Create issue' }
- .to log_spam(title: 'issue title', description: 'issue description', user_id: user.id, noteable_type: 'Issue')
- end
- end
- end
-
- context 'when reCAPTCHA is not enabled' do
- before do
- stub_application_setting(recaptcha_enabled: false)
- end
-
- context 'when allow_possible_spam feature flag is true' do
- before do
- fill_in 'issue_title', with: 'issue title'
- fill_in 'issue_description', with: 'issue description'
- end
-
- it 'creates an issue without a need to solve reCaptcha' do
- click_button 'Create issue'
-
- expect(page).not_to have_css('.recaptcha')
- expect(page.find('.issue-details h2.title')).to have_content('issue title')
- expect(page.find('.issue-details .description')).to have_content('issue description')
- end
-
- it 'creates a spam log record' do
- expect { click_button 'Create issue' }
- .to log_spam(title: 'issue title', description: 'issue description', user_id: user.id, noteable_type: 'Issue')
- end
- end
- end
- end
-
- context 'when the SpamVerdictService allows' do
- include_context 'includes Spam constants'
-
- before do
- allow_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
- allow(verdict_service).to receive(:execute).and_return(ALLOW)
- end
-
- visit new_project_issue_path(project)
- end
-
- it 'creates an issue' do
- fill_in 'issue_title', with: 'issue title'
- fill_in 'issue_description', with: 'issue description'
-
- click_button 'Create issue'
-
- expect(page.find('.issue-details h2.title')).to have_content('issue title')
- expect(page.find('.issue-details .description')).to have_content('issue description')
- end
- end
-end
diff --git a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
index 8c80e19810e..ae1bce7ea4c 100644
--- a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
+++ b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
@@ -85,7 +85,7 @@ RSpec.describe 'User creates branch and merge request on issue page', :js do
wait_for_requests
expect(page).to have_selector('.dropdown-toggle-text ', text: '1-cherry-coloured-funk')
- expect(current_path).to eq project_tree_path(project, '1-cherry-coloured-funk')
+ expect(page).to have_current_path project_tree_path(project, '1-cherry-coloured-funk'), ignore_query: true
end
end
@@ -110,7 +110,7 @@ RSpec.describe 'User creates branch and merge request on issue page', :js do
wait_for_requests
expect(page).to have_selector('.dropdown-toggle-text ', text: branch_name)
- expect(current_path).to eq project_tree_path(project, branch_name)
+ expect(page).to have_current_path project_tree_path(project, branch_name), ignore_query: true
end
end
end
diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb
index 37e324e6ded..446f13dc4d0 100644
--- a/spec/features/issues/user_creates_issue_spec.rb
+++ b/spec/features/issues/user_creates_issue_spec.rb
@@ -22,11 +22,11 @@ RSpec.describe "User creates issue" do
click_link "New issue"
end
- expect(current_path).to eq new_user_session_path
+ expect(page).to have_current_path new_user_session_path, ignore_query: true
gitlab_sign_in(create(:user))
- expect(current_path).to eq new_project_issue_path(project)
+ expect(page).to have_current_path new_project_issue_path(project), ignore_query: true
end
end
diff --git a/spec/features/issues/user_sorts_issues_spec.rb b/spec/features/issues/user_sorts_issues_spec.rb
index f3eaff379a1..86bdaf5d706 100644
--- a/spec/features/issues/user_sorts_issues_spec.rb
+++ b/spec/features/issues/user_sorts_issues_spec.rb
@@ -9,9 +9,9 @@ RSpec.describe "User sorts issues" do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project_empty_repo, :public, group: group) }
- let_it_be(:issue1, reload: true) { create(:issue, title: 'foo', created_at: Time.now, project: project) }
- let_it_be(:issue2, reload: true) { create(:issue, title: 'bar', created_at: Time.now - 60, project: project) }
- let_it_be(:issue3, reload: true) { create(:issue, title: 'baz', created_at: Time.now - 120, project: project) }
+ let_it_be(:issue1, reload: true) { create(:issue, title: 'foo', created_at: Time.zone.now, project: project) }
+ let_it_be(:issue2, reload: true) { create(:issue, title: 'bar', created_at: Time.zone.now - 60, project: project) }
+ let_it_be(:issue3, reload: true) { create(:issue, title: 'baz', created_at: Time.zone.now - 120, project: project) }
let_it_be(:newer_due_milestone) { create(:milestone, project: project, due_date: '2013-12-11') }
let_it_be(:later_due_milestone) { create(:milestone, project: project, due_date: '2013-12-12') }
@@ -75,7 +75,7 @@ RSpec.describe "User sorts issues" do
end
it 'sorts by most recently updated', :js do
- issue3.updated_at = Time.now + 100
+ issue3.updated_at = Time.zone.now + 100
issue3.save!
visit project_issues_path(project, sort: sort_value_recently_updated)
diff --git a/spec/features/issues/user_views_issue_spec.rb b/spec/features/issues/user_views_issue_spec.rb
index 31bf7649470..eca698bb2f4 100644
--- a/spec/features/issues/user_views_issue_spec.rb
+++ b/spec/features/issues/user_views_issue_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe "User views issue" do
it 'shows the merge request and issue actions', :js, :aggregate_failures do
click_button 'Issue actions'
- expect(page).to have_link('New issue', href: new_project_issue_path(project, { issue: { description: "Related to \##{issue.iid}.\n\n" } }))
+ expect(page).to have_link('New related issue', href: new_project_issue_path(project, { add_related_issue: issue.iid }))
expect(page).to have_button('Create merge request')
expect(page).to have_button('Close issue')
end