2017-01-27 11:25:39 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
describe 'New issue', :js do
|
2017-01-27 11:25:39 -05:00
|
|
|
include StubENV
|
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2017-01-27 11:25:39 -05:00
|
|
|
let(:user) { create(:user)}
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
|
|
|
|
2018-02-02 13:39:55 -05:00
|
|
|
Gitlab::CurrentSettings.update!(
|
2017-01-27 11:25:39 -05:00
|
|
|
akismet_enabled: true,
|
|
|
|
akismet_api_key: 'testkey',
|
|
|
|
recaptcha_enabled: true,
|
|
|
|
recaptcha_site_key: 'test site key',
|
|
|
|
recaptcha_private_key: 'test private key'
|
|
|
|
)
|
|
|
|
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_master(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-01-27 11:25:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when identified as a spam' do
|
|
|
|
before do
|
|
|
|
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200)
|
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit new_project_issue_path(project)
|
2017-01-27 11:25:39 -05:00
|
|
|
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'
|
|
|
|
|
2018-01-24 08:48:02 -05:00
|
|
|
# reCAPTCHA alerts when it can't contact the server, so just accept it and move on
|
|
|
|
page.driver.browser.switch_to.alert.accept
|
|
|
|
|
2017-01-27 11:25:39 -05:00
|
|
|
# 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)
|
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit new_project_issue_path(project)
|
2017-01-27 11:25:39 -05:00
|
|
|
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
|