Commit f5917674 authored by charlieablett's avatar charlieablett

Make reCAPTCHA consistent

There was no consistency in reCAPTCHA capitalisation,
so these are now consistent in tests and comments.
parent 84ccec12
...@@ -24,7 +24,7 @@ module Spam ...@@ -24,7 +24,7 @@ module Spam
def execute(api: false, recaptcha_verified:, spam_log_id:, user_id:) def execute(api: false, recaptcha_verified:, spam_log_id:, user_id:)
if recaptcha_verified if recaptcha_verified
# If it's a request which is already verified through recaptcha, # If it's a request which is already verified through reCAPTCHA,
# update the spam log accordingly. # update the spam log accordingly.
SpamLog.verify_recaptcha!(user_id: user_id, id: spam_log_id) SpamLog.verify_recaptcha!(user_id: user_id, id: spam_log_id)
else else
......
...@@ -30,7 +30,7 @@ describe RegistrationsController do ...@@ -30,7 +30,7 @@ describe RegistrationsController do
end end
end end
context 'when recaptcha experiment enabled' do context 'when reCAPTCHA experiment enabled' do
it "logs a 'User Created' message including the experiment state" do it "logs a 'User Created' message including the experiment state" do
user_params = { user: attributes_for(:user) } user_params = { user: attributes_for(:user) }
allow_any_instance_of(EE::RecaptchaExperimentHelper).to receive(:show_recaptcha_sign_up?).and_return(true) allow_any_instance_of(EE::RecaptchaExperimentHelper).to receive(:show_recaptcha_sign_up?).and_return(true)
......
...@@ -752,7 +752,7 @@ describe Projects::IssuesController do ...@@ -752,7 +752,7 @@ describe Projects::IssuesController do
expect { update_issue }.not_to change { issue.reload.title } expect { update_issue }.not_to change { issue.reload.title }
end end
it 'rejects an issue recognized as a spam when recaptcha disabled' do it 'rejects an issue recognized as a spam when reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false) stub_application_setting(recaptcha_enabled: false)
expect { update_issue }.not_to change { issue.reload.title } expect { update_issue }.not_to change { issue.reload.title }
...@@ -811,7 +811,7 @@ describe Projects::IssuesController do ...@@ -811,7 +811,7 @@ describe Projects::IssuesController do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
it 'accepts an issue after recaptcha is verified' do it 'accepts an issue after reCAPTCHA is verified' do
expect { update_verified_issue }.to change { issue.reload.title }.to(spammy_title) expect { update_verified_issue }.to change { issue.reload.title }.to(spammy_title)
end end
...@@ -1017,7 +1017,7 @@ describe Projects::IssuesController do ...@@ -1017,7 +1017,7 @@ describe Projects::IssuesController do
expect { post_new_issue(title: '') }.not_to change(Issue, :count) expect { post_new_issue(title: '') }.not_to change(Issue, :count)
end end
it 'does not create an issue when recaptcha is not enabled' do it 'does not create an issue when reCAPTCHA is not enabled' do
stub_application_setting(recaptcha_enabled: false) stub_application_setting(recaptcha_enabled: false)
expect { post_spam_issue }.not_to change(Issue, :count) expect { post_spam_issue }.not_to change(Issue, :count)
...@@ -1052,7 +1052,7 @@ describe Projects::IssuesController do ...@@ -1052,7 +1052,7 @@ describe Projects::IssuesController do
expect(controller).to receive_messages(verify_recaptcha: true) expect(controller).to receive_messages(verify_recaptcha: true)
end end
it 'accepts an issue after recaptcha is verified' do it 'accepts an issue after reCAPTCHA is verified' do
expect { post_verified_issue }.to change(Issue, :count) expect { post_verified_issue }.to change(Issue, :count)
end end
......
...@@ -127,7 +127,7 @@ describe Projects::SnippetsController do ...@@ -127,7 +127,7 @@ describe Projects::SnippetsController do
.to log_spam(title: 'Title', user_id: user.id, noteable_type: 'ProjectSnippet') .to log_spam(title: 'Title', user_id: user.id, noteable_type: 'ProjectSnippet')
end end
it 'renders :new with recaptcha disabled' do it 'renders :new with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false) stub_application_setting(recaptcha_enabled: false)
create_snippet(project, visibility_level: Snippet::PUBLIC) create_snippet(project, visibility_level: Snippet::PUBLIC)
...@@ -135,18 +135,18 @@ describe Projects::SnippetsController do ...@@ -135,18 +135,18 @@ describe Projects::SnippetsController do
expect(response).to render_template(:new) expect(response).to render_template(:new)
end end
context 'recaptcha enabled' do context 'reCAPTCHA enabled' do
before do before do
stub_application_setting(recaptcha_enabled: true) stub_application_setting(recaptcha_enabled: true)
end end
it 'renders :verify with recaptcha enabled' do it 'renders :verify with reCAPTCHA enabled' do
create_snippet(project, visibility_level: Snippet::PUBLIC) create_snippet(project, visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify) expect(response).to render_template(:verify)
end end
it 'renders snippet page when recaptcha verified' do it 'renders snippet page when reCAPTCHA verified' do
spammy_title = 'Whatever' spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title) spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
...@@ -223,7 +223,7 @@ describe Projects::SnippetsController do ...@@ -223,7 +223,7 @@ describe Projects::SnippetsController do
.to log_spam(title: 'Foo', user_id: user.id, noteable_type: 'ProjectSnippet') .to log_spam(title: 'Foo', user_id: user.id, noteable_type: 'ProjectSnippet')
end end
it 'renders :edit with recaptcha disabled' do it 'renders :edit with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false) stub_application_setting(recaptcha_enabled: false)
update_snippet(title: 'Foo') update_snippet(title: 'Foo')
...@@ -231,18 +231,18 @@ describe Projects::SnippetsController do ...@@ -231,18 +231,18 @@ describe Projects::SnippetsController do
expect(response).to render_template(:edit) expect(response).to render_template(:edit)
end end
context 'recaptcha enabled' do context 'reCAPTCHA enabled' do
before do before do
stub_application_setting(recaptcha_enabled: true) stub_application_setting(recaptcha_enabled: true)
end end
it 'renders :verify with recaptcha enabled' do it 'renders :verify with reCAPTCHA enabled' do
update_snippet(title: 'Foo') update_snippet(title: 'Foo')
expect(response).to render_template(:verify) expect(response).to render_template(:verify)
end end
it 'renders snippet page when recaptcha verified' do it 'renders snippet page when reCAPTCHA verified' do
spammy_title = 'Whatever' spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title) spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
...@@ -268,7 +268,7 @@ describe Projects::SnippetsController do ...@@ -268,7 +268,7 @@ describe Projects::SnippetsController do
.to log_spam(title: 'Foo', user_id: user.id, noteable_type: 'ProjectSnippet') .to log_spam(title: 'Foo', user_id: user.id, noteable_type: 'ProjectSnippet')
end end
it 'renders :edit with recaptcha disabled' do it 'renders :edit with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false) stub_application_setting(recaptcha_enabled: false)
update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
...@@ -276,18 +276,18 @@ describe Projects::SnippetsController do ...@@ -276,18 +276,18 @@ describe Projects::SnippetsController do
expect(response).to render_template(:edit) expect(response).to render_template(:edit)
end end
context 'recaptcha enabled' do context 'reCAPTCHA enabled' do
before do before do
stub_application_setting(recaptcha_enabled: true) stub_application_setting(recaptcha_enabled: true)
end end
it 'renders :verify with recaptcha enabled' do it 'renders :verify' do
update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify) expect(response).to render_template(:verify)
end end
it 'renders snippet page when recaptcha verified' do it 'renders snippet page' do
spammy_title = 'Whatever' spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title) spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
......
...@@ -139,7 +139,7 @@ describe RegistrationsController do ...@@ -139,7 +139,7 @@ describe RegistrationsController do
expect(flash[:alert]).to eq(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')) expect(flash[:alert]).to eq(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'))
end end
it 'redirects to the dashboard when the recaptcha is solved' do it 'redirects to the dashboard when the reCAPTCHA is solved' do
post(:create, params: user_params) post(:create, params: user_params)
expect(flash[:notice]).to eq(I18n.t('devise.registrations.signed_up')) expect(flash[:notice]).to eq(I18n.t('devise.registrations.signed_up'))
......
...@@ -318,7 +318,7 @@ describe SnippetsController do ...@@ -318,7 +318,7 @@ describe SnippetsController do
.to log_spam(title: 'Title', user: user, noteable_type: 'PersonalSnippet') .to log_spam(title: 'Title', user: user, noteable_type: 'PersonalSnippet')
end end
it 'renders :new with recaptcha disabled' do it 'renders :new with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false) stub_application_setting(recaptcha_enabled: false)
create_snippet(visibility_level: Snippet::PUBLIC) create_snippet(visibility_level: Snippet::PUBLIC)
...@@ -326,18 +326,18 @@ describe SnippetsController do ...@@ -326,18 +326,18 @@ describe SnippetsController do
expect(response).to render_template(:new) expect(response).to render_template(:new)
end end
context 'recaptcha enabled' do context 'reCAPTCHA enabled' do
before do before do
stub_application_setting(recaptcha_enabled: true) stub_application_setting(recaptcha_enabled: true)
end end
it 'renders :verify with recaptcha enabled' do it 'renders :verify' do
create_snippet(visibility_level: Snippet::PUBLIC) create_snippet(visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify) expect(response).to render_template(:verify)
end end
it 'renders snippet page when recaptcha verified' do it 'renders snippet page' do
spammy_title = 'Whatever' spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title) spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
...@@ -403,7 +403,7 @@ describe SnippetsController do ...@@ -403,7 +403,7 @@ describe SnippetsController do
.to log_spam(title: 'Foo', user: user, noteable_type: 'PersonalSnippet') .to log_spam(title: 'Foo', user: user, noteable_type: 'PersonalSnippet')
end end
it 'renders :edit with recaptcha disabled' do it 'renders :edit with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false) stub_application_setting(recaptcha_enabled: false)
update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
...@@ -411,18 +411,18 @@ describe SnippetsController do ...@@ -411,18 +411,18 @@ describe SnippetsController do
expect(response).to render_template(:edit) expect(response).to render_template(:edit)
end end
context 'recaptcha enabled' do context 'reCAPTCHA enabled' do
before do before do
stub_application_setting(recaptcha_enabled: true) stub_application_setting(recaptcha_enabled: true)
end end
it 'renders :verify with recaptcha enabled' do it 'renders :verify' do
update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify) expect(response).to render_template(:verify)
end end
it 'renders snippet page when recaptcha verified' do it 'renders snippet page when reCAPTCHA verified' do
spammy_title = 'Whatever' spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title) spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
...@@ -446,7 +446,7 @@ describe SnippetsController do ...@@ -446,7 +446,7 @@ describe SnippetsController do
.to log_spam(title: 'Foo', user: user, noteable_type: 'PersonalSnippet') .to log_spam(title: 'Foo', user: user, noteable_type: 'PersonalSnippet')
end end
it 'renders :edit with recaptcha disabled' do it 'renders :edit with reCAPTCHA disabled' do
stub_application_setting(recaptcha_enabled: false) stub_application_setting(recaptcha_enabled: false)
update_snippet(title: 'Foo') update_snippet(title: 'Foo')
...@@ -459,13 +459,13 @@ describe SnippetsController do ...@@ -459,13 +459,13 @@ describe SnippetsController do
stub_application_setting(recaptcha_enabled: true) stub_application_setting(recaptcha_enabled: true)
end end
it 'renders :verify with recaptcha enabled' do it 'renders :verify' do
update_snippet(title: 'Foo') update_snippet(title: 'Foo')
expect(response).to render_template(:verify) expect(response).to render_template(:verify)
end end
it 'renders snippet page when recaptcha verified' do it 'renders snippet page when reCAPTCHA verified' do
spammy_title = 'Whatever' spammy_title = 'Whatever'
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title) spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
......
...@@ -103,8 +103,8 @@ describe 'New issue', :js do ...@@ -103,8 +103,8 @@ describe 'New issue', :js do
click_button 'Submit issue' click_button 'Submit issue'
# it is impossible to test recaptcha automatically and there is no possibility to fill in recaptcha # 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 # reCAPTCHA verification is skipped in test environment and it always returns true
expect(page).not_to have_content('issue title') expect(page).not_to have_content('issue title')
expect(page).to have_css('.recaptcha') expect(page).to have_css('.recaptcha')
......
...@@ -40,13 +40,13 @@ shared_examples_for 'snippet editor' do ...@@ -40,13 +40,13 @@ shared_examples_for 'snippet editor' do
end end
end end
shared_examples 'solve recaptcha' do shared_examples 'solve reCAPTCHA' do
it 'creates a snippet after solving reCaptcha' do it 'creates a snippet after solving reCAPTCHA' do
click_button('Create snippet') click_button('Create snippet')
wait_for_requests wait_for_requests
# it is impossible to test recaptcha automatically and there is no possibility to fill in recaptcha # 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 # reCAPTCHA verification is skipped in test environment and it always returns true
expect(page).not_to have_content('My Snippet Title') expect(page).not_to have_content('My Snippet Title')
expect(page).to have_css('.recaptcha') expect(page).to have_css('.recaptcha')
click_button('Submit personal snippet') click_button('Submit personal snippet')
...@@ -82,7 +82,7 @@ shared_examples_for 'snippet editor' do ...@@ -82,7 +82,7 @@ shared_examples_for 'snippet editor' do
end end
context 'when allow_possible_spam feature flag is true' do context 'when allow_possible_spam feature flag is true' do
it_behaves_like 'solve recaptcha' it_behaves_like 'solve reCAPTCHA'
end end
end end
......
...@@ -316,7 +316,7 @@ describe('Issuable output', () => { ...@@ -316,7 +316,7 @@ describe('Issuable output', () => {
}); });
}); });
it('opens recaptcha modal if update rejected as spam', done => { it('opens reCAPTCHA modal if update rejected as spam', done => {
function mockScriptSrc() { function mockScriptSrc() {
const recaptchaChild = vm.$children.find( const recaptchaChild = vm.$children.find(
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
......
...@@ -57,7 +57,7 @@ describe('Description component', () => { ...@@ -57,7 +57,7 @@ describe('Description component', () => {
}); });
}); });
it('opens recaptcha dialog if update rejected as spam', done => { it('opens reCAPTCHA dialog if update rejected as spam', done => {
let modal; let modal;
const recaptchaChild = vm.$children.find( const recaptchaChild = vm.$children.find(
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
......
...@@ -386,7 +386,7 @@ describe Issues::CreateService do ...@@ -386,7 +386,7 @@ describe Issues::CreateService do
stub_feature_flags(allow_possible_spam: false) stub_feature_flags(allow_possible_spam: false)
end end
context 'when recaptcha was verified' do context 'when reCAPTCHA was verified' do
let(:log_user) { user } let(:log_user) { user }
let(:spam_logs) { create_list(:spam_log, 2, user: log_user, title: title) } let(:spam_logs) { create_list(:spam_log, 2, user: log_user, title: title) }
let(:target_spam_log) { spam_logs.last } let(:target_spam_log) { spam_logs.last }
...@@ -423,7 +423,7 @@ describe Issues::CreateService do ...@@ -423,7 +423,7 @@ describe Issues::CreateService do
end end
end end
context 'when recaptcha was not verified' do context 'when reCAPTCHA was not verified' do
before do before do
expect_next_instance_of(Spam::SpamActionService) do |spam_service| expect_next_instance_of(Spam::SpamActionService) do |spam_service|
expect(spam_service).to receive_messages(check_for_spam?: true) expect(spam_service).to receive_messages(check_for_spam?: true)
......
...@@ -85,7 +85,7 @@ describe Spam::SpamActionService do ...@@ -85,7 +85,7 @@ describe Spam::SpamActionService do
allow(Spam::SpamVerdictService).to receive(:new).and_return(fake_verdict_service) allow(Spam::SpamVerdictService).to receive(:new).and_return(fake_verdict_service)
end end
context 'when recaptcha was already verified' do context 'when reCAPTCHA was already verified' do
let(:recaptcha_verified) { true } let(:recaptcha_verified) { true }
it "doesn't check with the SpamVerdictService" do it "doesn't check with the SpamVerdictService" do
...@@ -102,7 +102,7 @@ describe Spam::SpamActionService do ...@@ -102,7 +102,7 @@ describe Spam::SpamActionService do
end end
end end
context 'when recaptcha was not verified' do context 'when reCAPTCHA was not verified' do
let(:recaptcha_verified) { false } let(:recaptcha_verified) { false }
context 'when spammable attributes have not changed' do context 'when spammable attributes have not changed' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment