diff --git a/app/models/color_scheme.rb b/app/models/color_scheme.rb index a1cda887a5b..3713d5299c8 100644 --- a/app/models/color_scheme.rb +++ b/app/models/color_scheme.rb @@ -112,15 +112,8 @@ class ColorScheme < ActiveRecord::Base end def self.lookup_hex_for_name(name) - Discourse.plugin_themes.each do |pt| - if pt.color_scheme - found = pt.color_scheme[name.to_sym] - return found if found - end - end - - # Can't use `where` here because base doesn't allow it - (base).colors.find {|c| c.name == name }.try(:hex) || :nil + enabled_color_scheme = Theme.where(key: SiteSetting.default_theme_key).first&.color_scheme + (enabled_color_scheme || base).colors.find {|c| c.name == name }.try(:hex) || :nil end def self.hex_for_name(name) diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb index f37d78d78dd..43c8918bbf6 100644 --- a/spec/mailers/user_notifications_spec.rb +++ b/spec/mailers/user_notifications_spec.rb @@ -244,6 +244,26 @@ describe UserNotifications do expect(html).to_not include hidden.raw expect(html).to_not include user_deleted.raw end + + it "uses theme color" do + cs = Fabricate(:color_scheme, name: 'Fancy', color_scheme_colors: [ + Fabricate(:color_scheme_color, name: 'header_primary', hex: 'F0F0F0'), + Fabricate(:color_scheme_color, name: 'header_background', hex: '1E1E1E'), + Fabricate(:color_scheme_color, name: 'tertiary', hex: '858585') + ]) + theme = Theme.create!( + name: 'my name', + user_id: Fabricate(:admin).id, + user_selectable: true, + color_scheme_id: cs.id + ) + theme.set_default! + + html = subject.html_part.body.to_s + expect(html).to include 'F0F0F0' + expect(html).to include '1E1E1E' + expect(html).to include '858585' + end end end