FIX: correctly invalidate theme css cache on scheme change
This commit is contained in:
parent
04b5516bf2
commit
7d9b5514ba
|
@ -251,7 +251,7 @@ class Stylesheet::Manager
|
||||||
raise "attempting to look up theme digest for invalid field"
|
raise "attempting to look up theme digest for invalid field"
|
||||||
end
|
end
|
||||||
|
|
||||||
Digest::SHA1.hexdigest scss.to_s
|
Digest::SHA1.hexdigest(scss.to_s + color_scheme_digest.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def color_scheme_digest
|
def color_scheme_digest
|
||||||
|
|
|
@ -28,7 +28,6 @@ describe Admin::ThemesController do
|
||||||
expect(upload.id).not_to be_nil
|
expect(upload.id).not_to be_nil
|
||||||
expect(JSON.parse(response.body)["upload_id"]).to eq(upload.id)
|
expect(JSON.parse(response.body)["upload_id"]).to eq(upload.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context '.import' do
|
context '.import' do
|
||||||
|
|
|
@ -8,6 +8,21 @@ describe ColorScheme do
|
||||||
{name: '$secondary_background_color', hex: '888888'}
|
{name: '$secondary_background_color', hex: '888888'}
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
it "correctly invalidates theme css when changed" do
|
||||||
|
scheme = ColorScheme.create_from_base(name: 'Bob')
|
||||||
|
theme = Theme.new(name: 'Amazing Theme', color_scheme_id: scheme.id, user_id: -1)
|
||||||
|
theme.set_field(name: :scss, target: :desktop, value: '.bob {color: $primary;}')
|
||||||
|
theme.save!
|
||||||
|
|
||||||
|
href = Stylesheet::Manager.stylesheet_href(:desktop_theme, theme.key)
|
||||||
|
|
||||||
|
ColorSchemeRevisor.revise(scheme, colors: [{ name: 'primary', hex: 'bbb' }])
|
||||||
|
|
||||||
|
href2 = Stylesheet::Manager.stylesheet_href(:desktop_theme, theme.key)
|
||||||
|
|
||||||
|
expect(href).not_to eq(href2)
|
||||||
|
end
|
||||||
|
|
||||||
describe "new" do
|
describe "new" do
|
||||||
it "can take colors" do
|
it "can take colors" do
|
||||||
c = ColorScheme.new(valid_params)
|
c = ColorScheme.new(valid_params)
|
||||||
|
@ -27,7 +42,7 @@ describe ColorScheme do
|
||||||
Fabricate(:color_scheme_color, name: 'third_one', hex: base_colors[:third_one])]) }
|
Fabricate(:color_scheme_color, name: 'third_one', hex: base_colors[:third_one])]) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
described_class.stubs(:base).returns(base)
|
ColorScheme.stubs(:base).returns(base)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a new color scheme" do
|
it "creates a new color scheme" do
|
||||||
|
|
Loading…
Reference in New Issue