-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from ministryofjustice/error-message-update
Error message update
- Loading branch information
Showing
16 changed files
with
149 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
@import 'colours'; | ||
|
||
|
||
|
||
div.field_with_errors input { | ||
border-color: $error-colour; | ||
} | ||
|
||
div.form-group > div.field_with_errors { | ||
div.form-group div.field_with_errors { | ||
border-left: 2px solid $error-colour; | ||
padding-left: 10px; | ||
} | ||
|
||
div.field_with_errors > label.error { | ||
div.field_with_errors label.error { | ||
color: $error-colour; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#r2_calculator { | ||
.row { | ||
margin-top:1em; | ||
.form-group { | ||
margin-bottom:1em; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,13 @@ class User < ActiveRecord::Base | |
scope :sorted_by_email, -> { all.order(:email) } | ||
|
||
email_regex = /\A([^@\s]+)@(hmcts\.gsi|digital\.justice)\.gov\.uk\z/i | ||
email_message = <<-END.gsub(/^\s+\|/, '').gsub(/\n/, '') | ||
|you’re not able to create an account with this email | ||
| address. Only '[email protected]' emails can be used. For more help, | ||
| contact us via #{Settings.mail_tech_support} | ||
END | ||
|
||
validates :email, format: { with: email_regex, on: :create, message: email_message } | ||
validates :role, :name, presence: true | ||
validates :email, format: { | ||
with: email_regex, | ||
on: [:create, :update], | ||
allow_nil: true, | ||
message: I18n.t('dictionary.invalid_email', email: Settings.mail_tech_support) | ||
} | ||
validates :role, inclusion: { | ||
in: ROLES, | ||
message: "%{value} is not a valid role", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
h2 | ||
= t 'devise.invitations.edit.header' | ||
= form_for resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put } do |f| | ||
= devise_error_messages! | ||
= f.hidden_field :invitation_token | ||
p | ||
= f.label :password | ||
br | ||
= f.password_field :password | ||
p | ||
= f.label :password_confirmation | ||
br | ||
= f.password_field :password_confirmation | ||
p | ||
.row | ||
.small-12.columns | ||
.form-group | ||
.row | ||
.columns.small-12 | ||
= f.label :password, resource.errors[:password].join(', ').html_safe, class: 'error' if resource.errors[:password].present? | ||
.row | ||
.columns.small-12.medium-8.large-5 | ||
= f.label :password | ||
= f.text_field :password, { class: 'form-control' } | ||
.row | ||
.small-12.columns | ||
.form-group | ||
.row | ||
.columns.small-12 | ||
= f.label :password_confirmation, resource.errors[:password_confirmation].join(', ').html_safe, class: 'error' if resource.errors[:password_confirmation].present? | ||
.row | ||
.columns.small-12.medium-8.large-5 | ||
= f.label :password_confirmation | ||
= f.text_field :password_confirmation, { class: 'form-control' } | ||
.actions | ||
= f.submit t("devise.invitations.edit.submit_button"), class: 'button btn tiny' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,40 @@ | ||
h2 | ||
= t "devise.invitations.new.header" | ||
= form_for resource, as: resource_name, url: user_invitation_path, html: {:method => :post} do |f| | ||
= devise_error_messages! | ||
- resource.class.invite_key_fields.each do |field| | ||
p | ||
= f.label field | ||
br | ||
= f.text_field field | ||
p | ||
.form-group | ||
= f.label :name | ||
= f.text_field :name, { class: 'form-control' } | ||
.form-group | ||
= f.label(:roles, 'Role') | ||
= f.collection_select :role, User::ROLES, :to_s, :humanize | ||
.form-group | ||
= f.label(:office_id, 'Office') | ||
= f.collection_select :office_id, Office.all, :id, :name | ||
.row | ||
.small-12.columns | ||
.form-group | ||
.row | ||
.columns.small-12 | ||
= f.label field, resource.errors[field].join(', ').html_safe, class: 'error' if resource.errors[field].present? | ||
.row | ||
.columns.small-12.medium-8.large-5 | ||
= f.label field | ||
= f.text_field field | ||
.row | ||
.small-12.columns | ||
.form-group | ||
.row | ||
.columns.small-12 | ||
= f.label :name, resource.errors[:name].join(', ').html_safe, class: 'error' if resource.errors[:name].present? | ||
.row | ||
.columns.small-12.medium-8.large-5 | ||
= f.label :name | ||
= f.text_field :name, { class: 'form-control' } | ||
.row | ||
.small-12.columns | ||
.form-group | ||
.row | ||
.columns.small-12.medium-8.large-5 | ||
= f.label(:roles, 'Role') | ||
= f.collection_select :role, User::ROLES, :to_s, :humanize | ||
.row | ||
.small-12.columns | ||
.form-group | ||
.row | ||
.columns.small-12.medium-8.large-5 | ||
= f.label(:office_id, 'Office') | ||
= f.collection_select :office_id, Office.all, :id, :name | ||
p | ||
= f.submit t("devise.invitations.new.submit_button"), class: 'button btn tiny' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
h2 Forgot your password? | ||
#instructions Enter your email address and click ‘get new password’. You’ll receive an email with a link to create a new password. | ||
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| | ||
= devise_error_messages! | ||
.field | ||
= f.label :email | ||
= f.email_field :email, autofocus: true | ||
.row | ||
.small-12.columns | ||
.form-group | ||
.row | ||
.columns.small-12 | ||
= f.label :email, resource.errors[:email].join(', ').html_safe, class: 'error' if resource.errors[:email].present? | ||
.row | ||
.columns.small-12.medium-8.large-5 | ||
= f.label :email | ||
= f.text_field :email, { class: 'form-control' } | ||
.actions | ||
= f.submit "Send me reset password instructions", class: 'button btn tiny' | ||
= render "devise/shared/links" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
# available at http://guides.rubyonrails.org/i18n.html. | ||
|
||
en: | ||
dictionary: | ||
invalid_email: "You’re not able to create an account with this email address. Only '[email protected]' emails can be used. For more help, <a href='mailto:%{email}'>contact us</a>" | ||
descriptors: | ||
r2_calculator: 'Income check' | ||
feedback: 'Feedback' | ||
|
@@ -31,6 +33,18 @@ en: | |
activerecord: | ||
errors: | ||
models: | ||
user: | ||
attributes: | ||
email: | ||
blank: 'Enter your email address' | ||
not_found: That email is not registered on our system | ||
name: | ||
blank: You must enter a name for the user | ||
password: | ||
blank: You must enter a password of at least %{count} characters | ||
too_short: The password should be at least %{count} characters | ||
password_confirmation: | ||
confirmation: This must match the password above | ||
dwp_check: | ||
attributes: | ||
last_name: | ||
|
@@ -42,6 +56,9 @@ en: | |
blank: 'Enter the applicant’s National Insurance number' | ||
invalid: 'Enter 2 letters, 6 numbers and 1 letter for the National Insurance number' | ||
attributes: | ||
user: | ||
password: New password | ||
password_confirmation: Confirm new password | ||
feedback: | ||
experience: 'What is your experience of using the service so far?' | ||
ideas: 'Do you have any ideas for how this service could be improved?' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,9 +45,8 @@ | |
end | ||
|
||
it 'has an informative error message for non white listed emails' do | ||
message = "you’re not able to create an account with this email address. Only '[email protected]' emails can be used. For more help, contact us via #{Settings.mail_tech_support}" | ||
user.valid? | ||
expect(user.errors.messages[:email].first).to match message | ||
expect(user.errors.messages[:email].first).to match I18n.t('dictionary.invalid_email', email: Settings.mail_tech_support) | ||
end | ||
end | ||
end | ||
|