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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 21:18:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 21:18:33 +0300
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/controllers/concerns
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/controllers/concerns')
-rw-r--r--spec/controllers/concerns/spammable_actions_spec.rb33
1 files changed, 18 insertions, 15 deletions
diff --git a/spec/controllers/concerns/spammable_actions_spec.rb b/spec/controllers/concerns/spammable_actions_spec.rb
index 25d5398c9da..7bd5a76e60c 100644
--- a/spec/controllers/concerns/spammable_actions_spec.rb
+++ b/spec/controllers/concerns/spammable_actions_spec.rb
@@ -69,8 +69,11 @@ RSpec.describe SpammableActions do
end
context 'when spammable.render_recaptcha? is true' do
+ let(:spam_log) { instance_double(SpamLog, id: 123) }
+ let(:captcha_site_key) { 'abc123' }
+
before do
- expect(spammable).to receive(:render_recaptcha?) { true }
+ expect(spammable).to receive(:render_recaptcha?).at_least(:once) { true }
end
context 'when format is :html' do
@@ -83,24 +86,24 @@ RSpec.describe SpammableActions do
context 'when format is :json' do
let(:format) { :json }
- let(:recaptcha_html) { '<recaptcha-html/>' }
- it 'renders json with recaptcha_html' do
- expect(controller).to receive(:render_to_string).with(
- {
- partial: 'shared/recaptcha_form',
- formats: :html,
- locals: {
- spammable: spammable,
- script: false,
- has_submit: false
- }
- }
- ) { recaptcha_html }
+ before do
+ expect(spammable).to receive(:spam?) { false }
+ expect(spammable).to receive(:spam_log) { spam_log }
+ expect(Gitlab::CurrentSettings).to receive(:recaptcha_site_key) { captcha_site_key }
+ end
+ it 'renders json with spam_action_response_fields' do
subject
- expect(json_response).to eq({ 'recaptcha_html' => recaptcha_html })
+ expected_json_response = HashWithIndifferentAccess.new(
+ {
+ spam: false,
+ needs_captcha_response: true,
+ spam_log_id: spam_log.id,
+ captcha_site_key: captcha_site_key
+ })
+ expect(json_response).to eq(expected_json_response)
end
end
end