mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 15:24:33 +08:00
FEATURE: backend support for user-selectable components
* 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
This commit is contained in:
@ -49,7 +49,7 @@ describe Admin::ThemesController do
|
||||
|
||||
it 'can import a theme with an upload' do
|
||||
upload = Fabricate(:upload)
|
||||
theme = Theme.new(name: 'with-upload', user_id: -1)
|
||||
theme = Fabricate(:theme)
|
||||
upload = UploadCreator.new(image, "logo.png").create_for(-1)
|
||||
theme.set_field(target: :common, name: :logo, upload_id: upload.id, type: :theme_upload_var)
|
||||
theme.save!
|
||||
@ -93,7 +93,7 @@ describe Admin::ThemesController do
|
||||
ColorScheme.destroy_all
|
||||
Theme.destroy_all
|
||||
|
||||
theme = Theme.new(name: 'my name', user_id: -1)
|
||||
theme = Fabricate(:theme)
|
||||
theme.set_field(target: :common, name: :scss, value: '.body{color: black;}')
|
||||
theme.set_field(target: :desktop, name: :after_header, value: '<b>test</b>')
|
||||
|
||||
@ -141,7 +141,7 @@ describe Admin::ThemesController do
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
let(:theme) { Theme.create(name: 'my name', user_id: -1) }
|
||||
let(:theme) { Fabricate(:theme) }
|
||||
|
||||
it 'can change default theme' do
|
||||
SiteSetting.default_theme_id = -1
|
||||
@ -169,7 +169,7 @@ describe Admin::ThemesController do
|
||||
theme.set_field(target: :common, name: :scss, value: '.body{color: black;}')
|
||||
theme.save
|
||||
|
||||
child_theme = Theme.create(name: 'my name', user_id: -1)
|
||||
child_theme = Fabricate(:theme)
|
||||
|
||||
upload = Fabricate(:upload)
|
||||
|
||||
@ -198,5 +198,17 @@ describe Admin::ThemesController do
|
||||
expect(json["theme"]["child_themes"].length).to eq(1)
|
||||
expect(UserHistory.where(action: UserHistory.actions[:change_theme]).count).to eq(1)
|
||||
end
|
||||
|
||||
it 'returns the right error message' do
|
||||
parent = Fabricate(:theme)
|
||||
parent.add_child_theme!(theme)
|
||||
|
||||
put "/admin/themes/#{theme.id}.json", params: {
|
||||
theme: { default: true }
|
||||
}
|
||||
|
||||
expect(response.status).to eq(400)
|
||||
expect(JSON.parse(response.body)["errors"].first).to include(I18n.t("themes.errors.component_no_default"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user