mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-04 06:55:00 +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 a2b0c193df
24 lines
748 B
Ruby
24 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
|