Refactor theme fields so they support custom theme defined vars

This paves the way to allowing themes to specify uploads and so on.
This commit is contained in:
Sam
2017-05-02 16:01:01 -04:00
parent 1f6ffd5fb0
commit 946f25098f
14 changed files with 120 additions and 52 deletions

View File

@@ -153,14 +153,14 @@ describe StaffActionLogger do
it "logs updated site customizations" do
old_json = ThemeSerializer.new(theme, root:false).to_json
theme.set_field(:common, :scss, "body{margin: 10px;}")
theme.set_field(target: :common, name: :scss, value: "body{margin: 10px;}")
log_record = logger.log_theme_change(old_json, theme)
expect(log_record.previous_value).to be_present
json = ::JSON.parse(log_record.new_value)
expect(json['theme_fields']).to eq([{"name" => "scss", "target" => "common", "value" => "body{margin: 10px;}"}])
expect(json['theme_fields']).to eq([{"name" => "scss", "target" => "common", "value" => "body{margin: 10px;}", "type_id" => 1}])
end
end
@@ -171,14 +171,14 @@ describe StaffActionLogger do
it "creates a new UserHistory record" do
theme = Theme.new(name: 'Banana')
theme.set_field(:common, :scss, "body{margin: 10px;}")
theme.set_field(target: :common, name: :scss, value: "body{margin: 10px;}")
log_record = logger.log_theme_destroy(theme)
expect(log_record.previous_value).to be_present
expect(log_record.new_value).to eq(nil)
json = ::JSON.parse(log_record.previous_value)
expect(json['theme_fields']).to eq([{"name" => "scss", "target" => "common", "value" => "body{margin: 10px;}"}])
expect(json['theme_fields']).to eq([{"name" => "scss", "target" => "common", "value" => "body{margin: 10px;}", "type_id" => 1}])
end
end