diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-27 17:25:39 +0100 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-02-07 12:56:20 +0100 |
commit | 3d2954e4570d236a080b0d46698d96a28fd9acec (patch) | |
tree | 0295eec45b4589fc55a1cf587eb7c1cd98d8c9ce /spec/features/issues/spam_issues_spec.rb | |
parent | 999edc5c1783aa205fdac4ba159e51851acdb446 (diff) | |
download | gitlab-ce-3d2954e4570d236a080b0d46698d96a28fd9acec.tar.gz |
Use reCaptcha when an issue identified as spam
Diffstat (limited to 'spec/features/issues/spam_issues_spec.rb')
-rw-r--r-- | spec/features/issues/spam_issues_spec.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/features/issues/spam_issues_spec.rb b/spec/features/issues/spam_issues_spec.rb new file mode 100644 index 00000000000..4bc9b49f889 --- /dev/null +++ b/spec/features/issues/spam_issues_spec.rb @@ -0,0 +1,66 @@ +require 'rails_helper' + +describe 'New issue', feature: true do + include StubENV + + let(:project) { create(:project, :public) } + let(:user) { create(:user)} + + before do + stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') + + current_application_settings.update!( + akismet_enabled: true, + akismet_api_key: 'testkey', + recaptcha_enabled: true, + recaptcha_site_key: 'test site key', + recaptcha_private_key: 'test private key' + ) + + project.team << [user, :master] + login_as(user) + end + + context 'when identified as a spam' do + before do + WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200) + + visit new_namespace_project_issue_path(project.namespace, project) + 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 'Submit 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 'Submit 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 not identified as a spam' do + before do + WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: 'false', status: 200) + + visit new_namespace_project_issue_path(project.namespace, project) + end + + it 'creates an issue' do + fill_in 'issue_title', with: 'issue title' + fill_in 'issue_description', with: 'issue description' + + click_button 'Submit 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 |