diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rb index e84a0ed0e83..ebceac32698 100644 --- a/lib/stylesheet/manager.rb +++ b/lib/stylesheet/manager.rb @@ -251,7 +251,7 @@ class Stylesheet::Manager raise "attempting to look up theme digest for invalid field" end - Digest::SHA1.hexdigest scss.to_s + Digest::SHA1.hexdigest(scss.to_s + color_scheme_digest.to_s) end def color_scheme_digest diff --git a/spec/controllers/admin/themes_controller_spec.rb b/spec/controllers/admin/themes_controller_spec.rb index efc9a51f475..b2c1bf7e54f 100644 --- a/spec/controllers/admin/themes_controller_spec.rb +++ b/spec/controllers/admin/themes_controller_spec.rb @@ -28,7 +28,6 @@ describe Admin::ThemesController do expect(upload.id).not_to be_nil expect(JSON.parse(response.body)["upload_id"]).to eq(upload.id) end - end context '.import' do diff --git a/spec/models/color_scheme_spec.rb b/spec/models/color_scheme_spec.rb index 4d07dac97d9..a19f86dcfe6 100644 --- a/spec/models/color_scheme_spec.rb +++ b/spec/models/color_scheme_spec.rb @@ -8,6 +8,21 @@ describe ColorScheme do {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 it "can take colors" do c = ColorScheme.new(valid_params) @@ -27,7 +42,7 @@ describe ColorScheme do Fabricate(:color_scheme_color, name: 'third_one', hex: base_colors[:third_one])]) } before do - described_class.stubs(:base).returns(base) + ColorScheme.stubs(:base).returns(base) end it "creates a new color scheme" do