Files
grecia/spec/components/layout/common_html_attributes_component_spec.rb
Javi Martín 2c0ede3aaa Use the dir attribute in dashboard and mailer layouts
We forgot to do so in commit d827768c0. In order to avoid the same
mistake in the future, we're extracting a method to get these
attributes. We're also adding tests, since we didn't have any tests to
check that the `dir` attribute was properly set.
2022-11-11 01:39:29 +01:00

35 lines
872 B
Ruby

require "rails_helper"
describe Layout::CommonHTMLAttributesComponent do
let(:component) { Layout::CommonHTMLAttributesComponent.new }
it "includes the default language by default" do
render_inline component
expect(page.text).to eq 'lang="en"'
end
it "includes the current language" do
I18n.with_locale(:es) { render_inline component }
expect(page.text).to eq 'lang="es"'
end
context "RTL languages" do
let!(:default_enforce) { I18n.enforce_available_locales }
before do
I18n.enforce_available_locales = false
allow(I18n).to receive(:available_locales).and_return(%i[ar en es])
end
after { I18n.enforce_available_locales = default_enforce }
it "includes the dir attribute" do
I18n.with_locale(:ar) { render_inline component }
expect(page.text).to eq 'dir="rtl" lang="ar"'
end
end
end