Move form field partial to a component
This way it's easier to test; changing it will also be easier. During my experiments I made a mistake which wasn't covered by the test suite. We're adding a test for this case. Note we're using `i18n_content` in the component instead of `content` because there's already a `content` method provided by ViewComponent.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::SiteCustomization::InformationTexts::FormFieldComponent do
|
||||
after { I18n.backend.reload! }
|
||||
|
||||
it "uses the I18n translation when the record exists without a database translation" do
|
||||
I18n.backend.store_translations(:en, { testing: "It works!" })
|
||||
content = I18nContent.create!(key: "testing")
|
||||
|
||||
render_inline Admin::SiteCustomization::InformationTexts::FormFieldComponent.new(content, locale: :en)
|
||||
|
||||
expect(page).to have_field with: "It works!"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user