summaryrefslogtreecommitdiff
path: root/test/models
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-30 16:50:19 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-30 16:50:19 +0200
commit37c542bee952193ebfbced8529b8699e2712fdc8 (patch)
treedf8d70c586002a08b85ba1143a93f9444215ff63 /test/models
parent970f0daaa7097d1a34cf3daa6266b80b93c190a9 (diff)
Localise model validation messages and refusal reasons
Diffstat (limited to 'test/models')
-rw-r--r--test/models/node_test.rb17
-rw-r--r--test/models/related_asset_test.rb2
2 files changed, 18 insertions, 1 deletions
diff --git a/test/models/node_test.rb b/test/models/node_test.rb
index c5b0d6a2..c1316ea6 100644
--- a/test/models/node_test.rb
+++ b/test/models/node_test.rb
@@ -919,4 +919,21 @@ class NodeTest < ActiveSupport::TestCase
919 node.reload 919 node.reload
920 assert_raises(ActiveRecord::RecordInvalid) { node.publish_draft! } 920 assert_raises(ActiveRecord::RecordInvalid) { node.publish_draft! }
921 end 921 end
922
923 test "refusals localise their message rather than hardcoding it" do
924 trash = Node.trash
925
926 I18n.with_locale(:de) do
927 error = assert_raises(ActiveRecord::RecordInvalid) { trash.trash! }
928 assert_includes error.message,
929 I18n.t("activerecord.errors.models.node.attributes.base.trash_the_trash")
930 end
931
932 I18n.with_locale(:en) do
933 trash.errors.clear
934 error = assert_raises(ActiveRecord::RecordInvalid) { trash.trash! }
935 assert_includes error.message,
936 I18n.t("activerecord.errors.models.node.attributes.base.trash_the_trash")
937 end
938 end
922end 939end
diff --git a/test/models/related_asset_test.rb b/test/models/related_asset_test.rb
index bb86ddbb..ea7c3d35 100644
--- a/test/models/related_asset_test.rb
+++ b/test/models/related_asset_test.rb
@@ -29,7 +29,7 @@ class RelatedAssetTest < ActiveSupport::TestCase
29 29
30 related.headline = true 30 related.headline = true
31 assert_not related.valid? 31 assert_not related.valid?
32 assert_includes related.errors[:headline], "can only be set on image or PDF assets" 32 assert_includes related.errors[:headline], I18n.t("activerecord.errors.models.related_asset.attributes.headline.images_and_pdfs_only")
33 end 33 end
34 34
35 test "the headline validation does not raise when asset is missing" do 35 test "the headline validation does not raise when asset is missing" do