-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
Regression in 0.9.3 #404
Comments
Thanks for letting us know :)
Do you have some small code that would reproduce this problem?
… On 23 Jan 2018, at 23:32, Clemens Kofler ***@***.***> wrote:
What I tried to do
I have a Rails app with RSpec tests that use Faker (1.8.7) for fake data generation.
I updated i18n to 0.9.3 to have all my gems at their most recent version.
What I expected to happen
I expected the test suite to pass since no changes apart from gem updates were made.
What actually happened
The whole test suite exploded with variations of the following message:
I18n::MissingTranslationData:
translation missing: en.faker.name.first_name
I could isolate this to i18n: When I downgraded to 0.9.1, everything worked fine – but with 0.9.3 it breaks, so my assumption is that it's related to i18n, not faker.
Versions of i18n, rails, and anything else you think is neccessary
Ruby 2.4.2
Rails 5.1.4
i18n 0.9.3
faker 1.8.7
Let me know if you need any further information.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sure, here are some snippets with what I think are the most important areas: # config/application.rb
config.i18n.default_locale = :de
config.i18n.locale = :de
config.i18n.available_locales = [:de]
# spec/support/faker.rb
if defined?(Faker)
# we only set this in environments that support fixture/factory data
# (i.e. currently development, test and staging)
DEFAULT_PASSWORD = '12345678' unless defined?(DEFAULT_PASSWORD)
I18n.enforce_available_locales = false # faker questionably sets this to true
Faker::Config.locale = :de
end
# spec/factories/users.rb
FactoryBot.define do
factory :user do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
end
end
# spec/models/user_spec.rb
RSpec.describe User, type: :model do
subject(:user) { FactoryBot.create(:user) } # <= whenever a test calls the subject, it explodes
end Hope that helps. |
Thanks @clemens. I've attempted to reproduce this issue in a brand new Rails 5.1.4 application: https://github.com/radar/i18n-404-repro I was following the steps you've graciously provided. I was unable to reproduce this issue. The test in that application is still passing for me:
Perhaps there's one (or more) steps that are missing? Could you try cloning down the application and see if you could reproduce the issue? Very interested to get to the bottom of this but it's hard for me to do that if I am unable to reproduce the issue. Thank you for your assistance. |
I had this same/similar problem it was solved by adding 'en' to our our list of |
@radar I'll try to create a failing app later today/tomorrow. @tneems The problem is: We're using faker in both development (to fill the database with fake data) and test. While there certainly isn't any harm in adding |
Thanks @clemens. An app that I can use to reproduce this issue on my machine would be extremely useful :)
… On 28 Jan 2018, at 03:55, Clemens Kofler ***@***.***> wrote:
@radar I'll try to create a failing app later today/tomorrow.
@tneems The problem is: We're using faker in both development (to fill the database with fake data) and test. While there certainly isn't any harm in adding :en and not enforcing available locales in development, I prefer to have the dev/prod configs differ as little as possible.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@radar Here you go: https://github.com/clemens/i18n-regression In this setup (i18n 0.9.3), the test fails. When you comment in the line in the Hope this helps |
I think I even just found the culprit by accident in the very first commit after 0.9.1: 5077ef9. This seems to be an optimization which doesn't store translations for locales that aren't in the It looks like https://github.com/stympy/faker/pull/1133/files introduces workarounds in faker tests which become necessary for the same reason. Based on a gut feeling (I haven't fully reflected this), I see three possibilities to approach this:
|
Thinking about this some more, I actually think the Faker fix should be independent of the fix of this regression. I could provide PRs for both approaches if desired. Just let me know. |
Hi @clemens. Thanks for providing some excellent steps to reproduce this issue. I believe that while there is a change in I think the way to sort out this problem is to change Faker's behaviour, particularly the There is absolutely no guarantee that Faker does have the proper translations (at least in the So what I think you should do is open a PR on faker to remove that As a substitute, may I suggest using |
This regression also breaks the i18n pipeline in my team's Rails application ( Even if the performance optimization may be worthwhile, I believe there is still a regression here in that the existing
Given this documentation, the expected behavior is that when |
Thanks for confirming @wjordan. Could you please try 0.9.4? If it still causes an issue, please show me an app which reproduces it and I can take a look. Thanks! |
@radar here's a minimal repro script in a
#!/bin/bash
RAILS_PATH=${RAILS_PATH:-/tmp/issue-404}
RAILS_VERSION=${RAILS_VERSION:-5.1.4}
I18N_VERSION=${I18N_VERSION:-0.9.4}
rm -rf ${RAILS_PATH}
rails _${RAILS_VERSION}_ new ${RAILS_PATH} -q > /dev/null
pushd ${RAILS_PATH} > /dev/null
sed -i '/Rails::Application/a config.i18n.enforce_available_locales = false\nconfig.i18n.available_locales = ["en-US"]' config/application.rb
echo "gem 'i18n', '${I18N_VERSION}'" >> Gemfile
bundle update i18n --quiet
DISABLE_SPRING=1 bin/rails r "puts I18n.t 'hello'"
popd > /dev/null
|
What I tried to do
I have a Rails app with RSpec tests that use Faker (1.8.7) for fake data generation.
I updated i18n to 0.9.3 to have all my gems at their most recent version.
What I expected to happen
I expected the test suite to pass since no changes apart from gem updates were made.
What actually happened
The whole test suite exploded with variations of the following message:
I could isolate this to i18n: When I downgraded to 0.9.1, everything worked fine – but with 0.9.3 it breaks, so my assumption is that it's related to i18n, not faker.
Versions of i18n, rails, and anything else you think is necessary
Let me know if you need any further information.
The text was updated successfully, but these errors were encountered: