FIX: wasn't able to change default theme
This commit is contained in:
parent
7578d8fc44
commit
6a7920ad75
|
@ -178,11 +178,10 @@ class Admin::ThemesController < Admin::AdminController
|
||||||
|
|
||||||
def update_default_theme
|
def update_default_theme
|
||||||
if theme_params.key?(:default)
|
if theme_params.key?(:default)
|
||||||
is_default = theme_params[:default]
|
is_default = theme_params[:default].to_s == "true"
|
||||||
|
if @theme.key == SiteSetting.default_theme_key && !is_default
|
||||||
if @theme.key == SiteSetting.default_theme_key && is_default == "false"
|
|
||||||
Theme.clear_default!
|
Theme.clear_default!
|
||||||
elsif is_default == "true"
|
elsif is_default
|
||||||
@theme.set_default!
|
@theme.set_default!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,8 +100,10 @@ describe Admin::ThemesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context ' .update' do
|
context ' .update' do
|
||||||
|
let(:theme) { Theme.create(name: 'my name', user_id: -1) }
|
||||||
|
|
||||||
it 'can change default theme' do
|
it 'can change default theme' do
|
||||||
theme = Theme.create(name: 'my name', user_id: -1)
|
SiteSetting.default_theme_key = nil
|
||||||
|
|
||||||
put :update, params: {
|
put :update, params: {
|
||||||
id: theme.id, theme: { default: true }
|
id: theme.id, theme: { default: true }
|
||||||
|
@ -111,7 +113,6 @@ describe Admin::ThemesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can unset default theme' do
|
it 'can unset default theme' do
|
||||||
theme = Theme.create(name: 'my name', user_id: -1)
|
|
||||||
SiteSetting.default_theme_key = theme.key
|
SiteSetting.default_theme_key = theme.key
|
||||||
|
|
||||||
put :update, params: {
|
put :update, params: {
|
||||||
|
@ -122,7 +123,6 @@ describe Admin::ThemesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates a theme' do
|
it 'updates a theme' do
|
||||||
theme = Theme.new(name: 'my name', user_id: -1)
|
|
||||||
theme.set_field(target: :common, name: :scss, value: '.body{color: black;}')
|
theme.set_field(target: :common, name: :scss, value: '.body{color: black;}')
|
||||||
theme.save
|
theme.save
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue