Browse Source

CLDC-2830 Update devise error messages (#2042)

* Update error messages

* Udate invalid token message

* Update validation/error message order for password
pull/2046/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
dcf980a22b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/user.rb
  2. 2
      config/locales/devise.en.yml
  3. 4
      config/locales/en.yml
  4. 2
      spec/requests/auth/passwords_controller_spec.rb
  5. 2
      spec/requests/users_controller_spec.rb

2
app/models/user.rb

@ -15,8 +15,8 @@ class User < ApplicationRecord
validates :email, uniqueness: { allow_blank: true, case_sensitive: true, if: :will_save_change_to_email? }
validates :email, format: { with: Devise.email_regexp, allow_blank: true, if: :will_save_change_to_email? }
validates :password, presence: { if: :password_required? }
validates :password, confirmation: { if: :password_required? }
validates :password, length: { within: Devise.password_length, allow_blank: true }
validates :password, confirmation: { if: :password_required? }
after_validation :send_data_protection_confirmation_reminder, if: :is_dpo_changed?

2
config/locales/devise.en.yml

@ -62,7 +62,7 @@ en:
messages:
already_confirmed: "Email has already been confirmed. Sign in."
blank: "can’t be blank"
confirmation: "Password confirmation doesn’t match new password"
confirmation: "The passwords you entered do not match. Try again."
confirmation_period_expired: "Email needs to be confirmed within %{period}. Request a new link below."
expired: "Token has expired. Request a new token."
not_found: "was not found"

4
config/locales/en.yml

@ -164,7 +164,9 @@ en:
blank: "Select role"
password:
blank: Enter a password
too_short: Password is too short (minimum is %{count} characters)
too_short: The password you entered is too short. Enter a password that is %{count} characters or longer.
reset_password_token:
invalid: "That link is invalid. Check you are using the correct link."
merge_request:
attributes:
absorbing_organisation_id:

2
spec/requests/auth/passwords_controller_spec.rb

@ -107,7 +107,7 @@ RSpec.describe Auth::PasswordsController, type: :request do
put "/account/password", headers: headers, params: params
expect(response).to have_http_status(:unprocessable_entity)
expect(page).to have_css("h1", text: "Reset your password")
expect(page).to have_content("doesn’t match new password")
expect(page).to have_content("passwords you entered do not match")
end
end

2
spec/requests/users_controller_spec.rb

@ -67,7 +67,7 @@ RSpec.describe UsersController, type: :request do
expect(response).to have_http_status(:unprocessable_entity)
expect(page).to have_css("h1", class: "govuk-heading-l", text: "Change your password")
expect(page).to have_selector("#error-summary-title")
expect(page).to have_content("Password confirmation doesn’t match new password")
expect(page).to have_content("passwords you entered do not match")
end
end
end

Loading…
Cancel
Save