Skip to content

Commit

Permalink
Merge pull request opf#17212 from opf/chore/unflicker-contract-spec
Browse files Browse the repository at this point in the history
[chore] make flickering disappear
  • Loading branch information
Kharonus authored Nov 15, 2024
2 parents 5a003d3 + d3f6955 commit 7c53804
Showing 1 changed file with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,31 @@
it "is invalid" do
result = subject.call(params)
expect(result).to be_failure
expect(result.errors.to_h).to include(label: ["must be unique within the same hierarchy level."])
expect(result.errors.to_h).to include(label: [I18n.t("dry_validation.errors.rules.label.not_unique")])
end

context "if locale is set to 'de'" do
context "if another locale is set" do
let(:mordor) { "agh burzum-ishi krimpatul" }

before do
I18n.config.enforce_available_locales = false
I18n.backend.store_translations(
:mo,
{ dry_validation: {
errors: { rules: { label: { not_unique: mordor } } }
} }
)
end

after do
I18n.config.enforce_available_locales = true
end

it "is invalid with localized validation errors" do
I18n.with_locale(:de) do
I18n.with_locale(:mo) do
result = subject.call(params)
expect(result).to be_failure
expect(result.errors.to_h).to include(label: ["muss innerhalb der gleichen Hierarchieebene eindeutig sein."])
expect(result.errors.to_h).to include(label: [mordor])
end
end
end
Expand All @@ -89,7 +105,7 @@
it "is invalid with localized validation errors" do
result = subject.call(params)
expect(result).to be_failure
expect(result.errors.to_h).to include(short: ["must be unique within the same hierarchy level."])
expect(result.errors.to_h).to include(short: [I18n.t("dry_validation.errors.rules.short.not_unique")])
end
end

Expand All @@ -108,7 +124,7 @@
it "is invalid" do
result = subject.call(params)
expect(result).to be_failure
expect(result.errors.to_h).to include(short: ["must be a string"])
expect(result.errors.to_h).to include(short: [I18n.t("dry_validation.errors.str?")])
end
end

Expand Down

0 comments on commit 7c53804

Please sign in to comment.