Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] make flickering disappear #17212

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Kharonus marked this conversation as resolved.
Show resolved Hide resolved
I18n.backend.store_translations(
:mo,
{ dry_validation: {
errors: { rules: { label: { not_unique: mordor } } }
} }
)
end

after do
I18n.config.enforce_available_locales = true
end
Comment on lines +86 to +88
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I see the comment above, this will also leak, no? Would it be better to store the original value and reassign it here, or is that overkill?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this is the original one. It is also the default. Not sure, if we should bother with variable assignment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's all good, you get to make a call. My idea was to be a bit extra defensive. If we (or Rails) ever decides to make a change to this default 🙃 which is very unlikely.


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
Loading