From 68c57ab09a4e1d0be3b6479e797c3a4fec5dd19a Mon Sep 17 00:00:00 2001 From: Louis Kirkham Date: Wed, 2 Aug 2023 17:12:12 +0100 Subject: [PATCH] Adds custom blank errors for admin user forms --- config/locales/en.yml | 12 +++++++++++- spec/features/account/collaborators_spec.rb | 2 +- spec/models/assessor_assignment_spec.rb | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 93eb8956ad..300127caa8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -60,8 +60,10 @@ en: activerecord: errors: + full_messages: + format: "{{message}}" messages: - blank: This field cannot be blank + blank: "%{attribute} is empty - it is a required field and must be filled in" accepted: Must be accepted taken: "This %{attribute} has already been taken" too_long: "%{attribute} is too long (maximum is %{count} characters)" @@ -71,6 +73,10 @@ en: models: user: attributes: + email: + invalid: "Email is invalid - enter a valid email address" + role: + blank: "Account type is empty - it is a required field and an option should be selected from the following list" password: weak_password: Your new password must be more complex. admin: @@ -81,6 +87,10 @@ en: attributes: password: weak_password: Your new password must be more complex. + assessor_assignment: + attributes: + position: + blank: "is empty - it is a required field and an option should be selected from the following list" time: formats: diff --git a/spec/features/account/collaborators_spec.rb b/spec/features/account/collaborators_spec.rb index 0acfbbb710..1702c0f3ce 100644 --- a/spec/features/account/collaborators_spec.rb +++ b/spec/features/account/collaborators_spec.rb @@ -101,7 +101,7 @@ end within(".collaborator_email") do - expect_to_see "This field cannot be blank" + expect_to_see "Email is empty - it is a required field and must be filled in" end end diff --git a/spec/models/assessor_assignment_spec.rb b/spec/models/assessor_assignment_spec.rb index c20a44a857..35e9fdac80 100644 --- a/spec/models/assessor_assignment_spec.rb +++ b/spec/models/assessor_assignment_spec.rb @@ -211,7 +211,7 @@ it 'should return error' do assessor_assignment = build :assessor_assignment, position: nil, form_answer: form assessor_assignment.valid? - expect(assessor_assignment.as_json).to eq({ :error => ["Position This field cannot be blank"] }) + expect(assessor_assignment.as_json).to eq({ :error => ["Position is empty - it is a required field and an option should be selected from the following list"] }) end it 'should return empty json' do