Skip to content

Commit

Permalink
Add translated error message for provider code taken
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie committed Dec 22, 2023
1 parent 06df3db commit 3b78a77
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Provider < ApplicationRecord
validates :provider_code,
uniqueness: {
case_sensitive: false,
message: "Provider already exists!"
message: I18n.t(
".activerecord.errors.models.provider.attributes.provider_code.taken"
)
}
end
7 changes: 7 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
en:
activerecord:
errors:
models:
provider:
attributes:
provider_code:
taken: Provider already exists
organisations: Organisations
schools: Schools
providers: Providers
Expand Down
2 changes: 1 addition & 1 deletion spec/models/provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
it do
is_expected.to validate_uniqueness_of(
:provider_code,
).case_insensitive.with_message("Provider already exists!")
).case_insensitive.with_message("Provider already exists")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
then_i_see_a_dropdown_item_for("Provider 1")
when_i_click_the_dropdown_item_for("Provider 1")
and_i_click_continue
then_i_see_an_error("Provider already exists!")
then_i_see_an_error("Provider already exists")
end

private
Expand Down

0 comments on commit 3b78a77

Please sign in to comment.