[katello-devel] Breaking translation bug

David Davis daviddavis at redhat.com
Wed Oct 3 14:02:43 UTC 2012


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...

--
Jason E. Rist
Senior Software Engineer
Systems Management and Cloud Enablement
Red Hat, Inc.
+1.919.754.4048
Freenode: jrist
github/identi.ca: knowncitizen




More information about the katello-devel mailing list