mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 07:33:40 +08:00
6e522e4aad
This PR is a major change to Sass compilation in Discourse. The new version of sass-ruby moves to dart-sass putting we back on the supported version of Sass. It does so while keeping compatibility with the existing method signatures, so minimal change is needed in Discourse for this change. This moves us From: - sassc 2.0.1 (Feb 2019) - libsass 3.5.2 (May 2018) To: - dart-sass 1.58 This update applies the following breaking changes: > > These breaking changes are coming soon or have recently been released: > > [Functions are stricter about which units they allow](https://sass-lang.com/documentation/breaking-changes/function-units) beginning in Dart Sass 1.32.0. > > [Selectors with invalid combinators are invalid](https://sass-lang.com/documentation/breaking-changes/bogus-combinators) beginning in Dart Sass 1.54.0. > > [/ is changing from a division operation to a list separator](https://sass-lang.com/documentation/breaking-changes/slash-div) beginning in Dart Sass 1.33.0. > > [Parsing the special syntax of @-moz-document will be invalid](https://sass-lang.com/documentation/breaking-changes/moz-document) beginning in Dart Sass 1.7.2. > > [Compound selectors could not be extended](https://sass-lang.com/documentation/breaking-changes/extend-compound) in Dart Sass 1.0.0 and Ruby Sass 4.0.0. SCSS files have been migrated automatically using `sass-migrator division app/assets/stylesheets/**/*.scss`
55 lines
2.0 KiB
Ruby
55 lines
2.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe EmailStyleUpdater do
|
|
fab!(:admin) { Fabricate(:admin) }
|
|
let(:default_html) { File.read("#{Rails.root}/app/views/email/default_template.html") }
|
|
let(:updater) { EmailStyleUpdater.new(admin) }
|
|
|
|
def expect_settings_to_be_unset
|
|
expect(SiteSetting.email_custom_template).to_not be_present
|
|
expect(SiteSetting.email_custom_css).to_not be_present
|
|
expect(SiteSetting.email_custom_css_compiled).to_not be_present
|
|
end
|
|
|
|
describe "update" do
|
|
it "can change the settings" do
|
|
expect(updater.update(html: "For you: %{email_content}", css: "h1 { color: blue; }")).to eq(
|
|
true,
|
|
)
|
|
expect(SiteSetting.email_custom_template).to eq("For you: %{email_content}")
|
|
expect(SiteSetting.email_custom_css).to eq("h1 { color: blue; }")
|
|
expect(SiteSetting.email_custom_css_compiled.strip).to eq("h1{color:blue}")
|
|
end
|
|
|
|
it "will not store defaults" do
|
|
updater.update(html: default_html, css: "")
|
|
expect_settings_to_be_unset
|
|
end
|
|
|
|
it "can clear settings if defaults given" do
|
|
SiteSetting.email_custom_template = "For you: %{email_content}"
|
|
SiteSetting.email_custom_css = "h1 { color: blue; }"
|
|
SiteSetting.email_custom_css_compiled = "h1{color:blue}"
|
|
updater.update(html: default_html, css: "")
|
|
expect_settings_to_be_unset
|
|
end
|
|
|
|
it "fails if html is missing email_content" do
|
|
expect(updater.update(html: "No email content", css: "")).to eq(false)
|
|
expect(updater.errors).to include(
|
|
I18n.t("email_style.html_missing_placeholder", placeholder: "%{email_content}"),
|
|
)
|
|
expect_settings_to_be_unset
|
|
end
|
|
|
|
it "fails if css is not valid scss" do
|
|
expect(updater.update(html: "For you: %{email_content}", css: "h1 { color: blue;")).to eq(
|
|
false,
|
|
)
|
|
expect(updater.errors).to_not be_empty
|
|
expect(updater.errors.first).to include('Error: expected "}".')
|
|
expect_settings_to_be_unset
|
|
end
|
|
end
|
|
end
|