2019-09-30 21:07:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
RSpec.describe RecaptchaHelper, type: :helper do
|
2020-06-23 00:09:42 +05:30
|
|
|
let(:session) { {} }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(helper).to receive(:session) { session }
|
|
|
|
end
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
shared_examples 'Gitlab QA bypass' do
|
2023-01-13 00:05:48 +05:30
|
|
|
context 'when it is a QA request' do
|
|
|
|
before do
|
|
|
|
allow(Gitlab::Qa).to receive(:request?).and_return(true)
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it { is_expected.to eq false }
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|
2022-11-25 23:54:43 +05:30
|
|
|
|
|
|
|
describe '.show_recaptcha_sign_up?' do
|
|
|
|
let(:setting_state) { true }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_application_setting(recaptcha_enabled: setting_state)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { helper.show_recaptcha_sign_up? }
|
|
|
|
|
|
|
|
it { is_expected.to eq true }
|
|
|
|
|
|
|
|
context 'when setting is disabled' do
|
|
|
|
let(:setting_state) { false }
|
|
|
|
|
|
|
|
it { is_expected.to eq false }
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'Gitlab QA bypass'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.recaptcha_enabled_on_login?' do
|
|
|
|
let(:setting_state) { true }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_application_setting(login_recaptcha_protection_enabled: setting_state)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { helper.recaptcha_enabled_on_login? }
|
|
|
|
|
|
|
|
it { is_expected.to eq true }
|
|
|
|
|
|
|
|
context 'when setting is disabled' do
|
|
|
|
let(:setting_state) { false }
|
|
|
|
|
|
|
|
it { is_expected.to eq false }
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'Gitlab QA bypass'
|
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|