[katello-devel] Breaking translation bug

David Davis daviddavis at redhat.com
Wed Oct 3 13:43:04 UTC 2012


So there's a bug that's happening only in Jenkins where we're getting these failures:

Changeset Changeset should adding content fail adding content from not promoted repository should fail on add package
     Failure/Error: lambda { @changeset.add_package!("pack", @prod) }.
       expected ActiveRecord::RecordInvalid with message matching /has not been promoted/, got #<ActiveRecord::RecordInvalid: translation missing: User_#<RSpec::Core::ExampleGroup::Nested_66::Nested_3::Nested_6:0x7f5b6bc44c08>.activerecord.errors.messages.record_invalid>
     # ./spec/models/changeset_spec.rb:175

The problem is that in the controller we're setting I18n.locale to current_user's default_locale and we're mocking current_user in a lot of cases so the locale just ends up being some mock-type data. Then when it runs the model specs, it fails in jenkins because the locale is not en (for English). It happens only on some systems because it depends on which order the specs are run (model then controller vs. controller then model). 

There's a few different way to fix this from happening, each with their faults:

1. Just set the default_locale to en for the user mocked models. Problem: if we ever end up testing non-English locales or if someone forgets to stub #default_locale, the changeset specs will break again.

2. Reset the locale before each rspec test. Problem: I am not aware of a good place to do this.

3. Reset the locale on an as-needed basis. Problem: This is kind of a hack but then again it's probably a bad idea for any spec to assume the locale is set to en.

Any thoughts?

Thanks.

David




More information about the katello-devel mailing list