mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 15:32:26 +08:00
ab0b034404
This was likely introduced with the refactor to make ColorSchemeColor a database object. Add a test so this doesn't happen again. Also test other basics of the WizardSerializer. For some reason, the .as_json left Ruby objects in; I solved this with a round trip through JSON during the test.
26 lines
671 B
Ruby
26 lines
671 B
Ruby
# frozen_string_literal: true
|
|
|
|
class WizardSerializer < ApplicationSerializer
|
|
attributes :start, :completed, :current_color_scheme
|
|
|
|
has_many :steps, serializer: WizardStepSerializer, embed: :objects
|
|
|
|
def start
|
|
object.start.id
|
|
end
|
|
|
|
def completed
|
|
object.completed?
|
|
end
|
|
|
|
def current_color_scheme
|
|
color_scheme = Theme.where(id: SiteSetting.default_theme_id).first&.color_scheme
|
|
colors = color_scheme ? color_scheme.colors : ColorScheme.base.colors
|
|
|
|
# The frontend expects the color hexs to start with '#'
|
|
colors_with_hash = {}
|
|
colors.each { |color| colors_with_hash[color.name] = color.hex_with_hash }
|
|
colors_with_hash
|
|
end
|
|
end
|