mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:22 +08:00
FIX: ColorScheme color missing was returning "nil"
This commit is contained in:
parent
c677877e4f
commit
5a32a70d6c
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_dependency 'distributed_cache'
|
||||
|
||||
class ColorScheme < ActiveRecord::Base
|
||||
|
@ -108,12 +110,12 @@ class ColorScheme < ActiveRecord::Base
|
|||
|
||||
def self.lookup_hex_for_name(name)
|
||||
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
|
||||
(enabled_color_scheme || base).colors.find { |c| c.name == name }.try(:hex) || "nil"
|
||||
end
|
||||
|
||||
def self.hex_for_name(name)
|
||||
hex_cache[name] ||= lookup_hex_for_name(name)
|
||||
hex_cache[name] == :nil ? nil : hex_cache[name]
|
||||
hex_cache[name] == "nil" ? nil : hex_cache[name]
|
||||
end
|
||||
|
||||
def colors=(arr)
|
||||
|
|
|
@ -62,11 +62,11 @@ describe ColorScheme do
|
|||
end
|
||||
|
||||
it "returns nil for a missing attribute" do
|
||||
expect(described_class.hex_for_name('undefined')).to eq nil
|
||||
expect(ColorScheme.hex_for_name('undefined')).to eq nil
|
||||
end
|
||||
|
||||
it "returns the base color for an attribute" do
|
||||
expect(described_class.hex_for_name('second_one')).to eq base_colors[:second_one]
|
||||
expect(ColorScheme.hex_for_name('second_one')).to eq base_colors[:second_one]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user