[katello-devel] Breaking translation bug

Partha Aji paji at redhat.com
Wed Oct 3 15:47:01 UTC 2012


----- Original Message -----
> From: "David Davis" <daviddavis at redhat.com>
> To: jrist at redhat.com
> Cc: "katello-devel" <katello-devel at redhat.com>
> Sent: Wednesday, October 3, 2012 10:02:43 AM
> Subject: Re: [katello-devel] Breaking translation bug
> 
> Eric brought up another option: have the test script run the
> models/controllers/etc separately. Then we wouldn't have globals
> bleed over from the controllers to models and vice versa.
> 
> Also, there might be other options as well that I may not be thinking
> of.
> 
> David
> 
> 
> ----- Original Message -----
> From: "Jason Rist" <jrist at redhat.com>
> To: "David Davis" <daviddavis at redhat.com>
> Cc: "katello-devel" <katello-devel at redhat.com>
> Sent: Wednesday, October 3, 2012 9:50:45 AM
> Subject: Re: [katello-devel] Breaking translation bug
> 
> On Wed 03 Oct 2012 07:43:04 AM MDT, David Davis wrote:
> > 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
> >
> > _______________________________________________
> > katello-devel mailing list
> > katello-devel at redhat.com
> > https://www.redhat.com/mailman/listinfo/katello-devel
> 
> Are those the only options? I'd like if we didn't assume this was all
> English, so 3 looks the best...
> 

I 'd go with 2 ideally, but even 1 is ok as long as resetting the default locale is simple to do and documented. I mean 99% of the tests are going to be en_us. Not worth spending time figuring out. The special cases where we test i18n we should have some simple way to reset the locale. Not worth spending much more time on those test IMO.

Partha




More information about the katello-devel mailing list