mirror of
https://github.com/discourse/discourse.git
synced 2024-12-04 16:53:39 +08:00
0b7ed8ffaf
* FEATURE: backend support for user-selectable components * fix problems with previewing default theme * rename preview_key => preview_theme_id * omit default theme from child themes dropdown and try a different fix * cache & freeze stylesheets arrays
44 lines
1.7 KiB
Ruby
44 lines
1.7 KiB
Ruby
require 'rails_helper'
|
|
|
|
describe ChildTheme do
|
|
describe "validations" do
|
|
it "doesn't allow children to become parents or parents to become children" do
|
|
theme = Fabricate(:theme)
|
|
child = Fabricate(:theme)
|
|
|
|
child_theme = ChildTheme.new(parent_theme: theme, child_theme: child)
|
|
expect(child_theme.valid?).to eq(true)
|
|
child_theme.save!
|
|
|
|
grandchild = Fabricate(:theme)
|
|
child_theme = ChildTheme.new(parent_theme: child, child_theme: grandchild)
|
|
expect(child_theme.valid?).to eq(false)
|
|
expect(child_theme.errors.full_messages).to contain_exactly(I18n.t("themes.errors.no_multilevels_components"))
|
|
|
|
grandparent = Fabricate(:theme)
|
|
child_theme = ChildTheme.new(parent_theme: grandparent, child_theme: theme)
|
|
expect(child_theme.valid?).to eq(false)
|
|
expect(child_theme.errors.full_messages).to contain_exactly(I18n.t("themes.errors.no_multilevels_components"))
|
|
end
|
|
|
|
it "doesn't allow a user selectable theme to be a child" do
|
|
parent = Fabricate(:theme)
|
|
selectable_theme = Fabricate(:theme, user_selectable: true)
|
|
|
|
child_theme = ChildTheme.new(parent_theme: parent, child_theme: selectable_theme)
|
|
expect(child_theme.valid?).to eq(false)
|
|
expect(child_theme.errors.full_messages).to contain_exactly(I18n.t("themes.errors.component_no_user_selectable"))
|
|
end
|
|
|
|
it "doesn't allow a default theme to be child" do
|
|
parent = Fabricate(:theme)
|
|
default = Fabricate(:theme)
|
|
default.set_default!
|
|
|
|
child_theme = ChildTheme.new(parent_theme: parent, child_theme: default)
|
|
expect(child_theme.valid?).to eq(false)
|
|
expect(child_theme.errors.full_messages).to contain_exactly(I18n.t("themes.errors.component_no_default"))
|
|
end
|
|
end
|
|
end
|