Commit f2dfcdc6 authored by Patrick Bajao's avatar Patrick Bajao

Merge branch 'refactor/recapcha-error-message-locale' into 'master'

Refactor: let reCAPTCHA error messages use translation

See merge request gitlab-org/gitlab!81977
parents 839e4d28 867aa0a0
......@@ -78,8 +78,9 @@ module Spammable
end
def recaptcha_error!
self.errors.add(:base, "Your #{spammable_entity_type} has been recognized as spam. "\
"Please, change the content or solve the reCAPTCHA to proceed.")
self.errors.add(:base, _("Your %{spammable_entity_type} has been recognized as spam. "\
"Please, change the content or solve the reCAPTCHA to proceed.") \
% { spammable_entity_type: spammable_entity_type })
end
def unrecoverable_spam_error!
......
......@@ -42389,6 +42389,9 @@ msgstr ""
msgid "Your %{plan} subscription expires on %{expiry_date}"
msgstr ""
msgid "Your %{spammable_entity_type} has been recognized as spam. Please, change the content or solve the reCAPTCHA to proceed."
msgstr ""
msgid "Your %{strong}%{plan_name}%{strong_close} subscription expires on %{strong}%{expires_on}%{strong_close}. After that date, you cannot create issues or merge requests, or use many other features."
msgstr ""
......
......@@ -152,7 +152,7 @@ RSpec.describe ConfirmationsController do
perform_request
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
end
it 'successfully sends password reset when reCAPTCHA is solved' do
......
......@@ -121,7 +121,7 @@ RSpec.describe PasswordsController do
perform_request
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
end
it 'successfully sends password reset when reCAPTCHA is solved' do
......
......@@ -235,7 +235,7 @@ RSpec.describe SessionsController do
unsuccesful_login(user_params)
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(subject.current_user).to be_nil
end
......@@ -259,7 +259,7 @@ RSpec.describe SessionsController do
unsuccesful_login(user_params, sesion_params: { failed_login_attempts: 6 })
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(subject.current_user).to be_nil
end
......@@ -279,7 +279,7 @@ RSpec.describe SessionsController do
unsuccesful_login(user_params)
expect(response).to render_template(:new)
expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(subject.current_user).to be_nil
end
......
......@@ -324,7 +324,7 @@ RSpec.describe 'Signup' do
fill_in_signup_form
expect { click_button 'Register' }.not_to change { User.count }
expect(page).to have_content('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(page).to have_content(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'))
end
end
......
......@@ -55,7 +55,7 @@ RSpec.describe Spammable do
subject { invalidate_if_spam(needs_recaptcha: true) }
it 'has an error related to spam on the model' do
expect(subject.errors.messages[:base]).to match_array /solve the reCAPTCHA/
expect(subject.errors.messages[:base]).to match_array /content or solve the/
end
end
......@@ -63,7 +63,7 @@ RSpec.describe Spammable do
subject { invalidate_if_spam(is_spam: true, needs_recaptcha: true) }
it 'has an error related to spam on the model' do
expect(subject.errors.messages[:base]).to match_array /solve the reCAPTCHA/
expect(subject.errors.messages[:base]).to match_array /content or solve the/
end
end
......
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