FEATURE: allow disabling theme components (#7812)

This allows you to temporarily disable components without having to remove them from a theme. 

This feature is very handy when doing quick fix engineering.
This commit is contained in:
Osama Sayegh
2019-07-03 11:18:11 +03:00
committed by Sam
parent ecf0215ee7
commit 3d64532273
15 changed files with 238 additions and 16 deletions

View File

@ -60,9 +60,9 @@ describe Theme do
end
it "can automatically disable for mismatching version" do
expect(theme.enabled?).to eq(true)
expect(theme.supported?).to eq(true)
theme.create_remote_theme!(remote_url: "", minimum_discourse_version: "99.99.99")
expect(theme.enabled?).to eq(false)
expect(theme.supported?).to eq(false)
expect(Theme.transform_ids([theme.id])).to be_empty
end
@ -72,6 +72,13 @@ describe Theme do
expect(Theme.transform_ids([nil])).to eq([nil])
end
it '#transform_ids filters out disabled components' do
theme.add_child_theme!(child)
expect(Theme.transform_ids([theme.id], extend: true)).to eq([theme.id, child.id])
child.update!(enabled: false)
expect(Theme.transform_ids([theme.id], extend: true)).to eq([theme.id])
end
it "doesn't allow multi-level theme components" do
grandchild = Fabricate(:theme, user: user)
grandparent = Fabricate(:theme, user: user)