gitlab-org--gitlab-foss/app/views/shared/_recaptcha_form.html.haml
Stan Hu c527eadb74 Fix the reCAPTCHA spec failures by not rendering the widget in test mode
We've seen changes in behavior in the reCAPTCHA widget that led to test failures.
To avoid these issues, don't render the widget at all in test mode.

Closes #45138
2018-04-06 14:25:08 -07:00

20 lines
904 B
Text

- resource_name = spammable.class.model_name.singular
- humanized_resource_name = spammable.class.model_name.human.downcase
- script = local_assigns.fetch(:script, true)
- method = params[:action] == 'create' ? :post : :put
- has_submit = local_assigns.fetch(:has_submit, true)
= form_for resource_name, method: method, html: { class: 'recaptcha-form js-recaptcha-form' } do |f|
.recaptcha
- params[resource_name].each do |field, value|
= hidden_field(resource_name, field, value: value)
= hidden_field_tag(:spam_log_id, spammable.spam_log.id)
= hidden_field_tag(:recaptcha_verification, true)
= recaptcha_tags script: script, callback: 'recaptchaDialogCallback' unless Rails.env.test?
-# Yields a block with given extra params.
= yield
- if has_submit
.row-content-block.footer-block
= f.submit "Submit #{humanized_resource_name}", class: 'btn btn-create'