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

Testing and fixtures #644

Open
dvodvo opened this issue Aug 3, 2024 · 0 comments
Open

Testing and fixtures #644

dvodvo opened this issue Aug 3, 2024 · 0 comments

Comments

@dvodvo
Copy link

dvodvo commented Aug 3, 2024

The rails documentation says scant little, to this day, about testing or fixtures
https://guides.rubyonrails.org/i18n.html.

I have seen different apporaches suggested.

  • under fixtures, have a directory with the class name and inside it a translations.yml file
  • having a mobility/string_translations.yml (and sister text_translation) set up.
    The latter feels more natural, as it reflects the database structure.

Yet, for a given class

class Promotion < ApplicationRecord
  extend Mobility

  translates :description_public, type: :text

a fixture, with stock scaffold generation, for promotions.yml

full:
  description_internal: MyText
  description_public: MyText

and a mobility/text_translations.yml with

promo_full:
  translatable_id: promotions(:full).id
  translatable_type: "Promotion"
  key: "description_public"
  value: "full_full"
  locale: "en"
  created_at: <%= Time.now %>
  updated_at: <%= Time.now %>

when intercepted in a test

puts promotions(:full).description_public_en.inspect
puts promotions(:full).description_public.inspect

yields nil for both.

So this is an issue (for which, admittedly Rails doc does not help).
To which I might attempt a documentation PR... However, I still do not see how to resolve the Minitest fixture issue.

[Sorry for corss-posting, but since I realised , post facto, the issue was marked closed, it might not pop up]
Originally posted by @dvodvo in #626 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant