mirror of
https://github.com/discourse/discourse.git
synced 2025-07-14 00:40:39 +08:00

The moment locale files expect `this.` to be the window object. In a type=module, `this` is `undefined`. This commit wraps the moment-timezone definitions in an IIFE to resolve that. Also adds a system spec to prevent future moment-timezone regressions. Followup to a2b0c193dff40278c0a93995cc9b97b05dc8abb2
25 lines
748 B
Ruby
25 lines
748 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Locale choice", type: :system do
|
|
it "loads english locale successfully" do
|
|
visit "/"
|
|
expect(page).to have_css("html[lang='en']")
|
|
expect(page).to have_css(
|
|
"#navigation-bar .categories",
|
|
text: I18n.t("js.filters.categories.title", locale: :en),
|
|
)
|
|
expect(page.evaluate_script("moment.locale()")).to eq("en")
|
|
end
|
|
|
|
it "loads french locale successfully" do
|
|
SiteSetting.default_locale = "fr"
|
|
visit "/"
|
|
expect(page).to have_css("html[lang='fr']")
|
|
expect(page).to have_css(
|
|
"#navigation-bar .categories",
|
|
text: I18n.t("js.filters.categories.title", locale: :fr),
|
|
)
|
|
expect(page.evaluate_script("moment.locale()")).to eq("fr")
|
|
end
|
|
end
|