FIX: wasn't able to change default theme

This commit is contained in:
Régis Hanol 2017-09-27 20:05:31 +02:00
parent 7578d8fc44
commit 6a7920ad75
2 changed files with 6 additions and 7 deletions

View File

@ -178,11 +178,10 @@ class Admin::ThemesController < Admin::AdminController
def update_default_theme
if theme_params.key?(:default)
is_default = theme_params[:default]
if @theme.key == SiteSetting.default_theme_key && is_default == "false"
is_default = theme_params[:default].to_s == "true"
if @theme.key == SiteSetting.default_theme_key && !is_default
Theme.clear_default!
elsif is_default == "true"
elsif is_default
@theme.set_default!
end
end

View File

@ -100,8 +100,10 @@ describe Admin::ThemesController do
end
context ' .update' do
let(:theme) { Theme.create(name: 'my name', user_id: -1) }
it 'can change default theme' do
theme = Theme.create(name: 'my name', user_id: -1)
SiteSetting.default_theme_key = nil
put :update, params: {
id: theme.id, theme: { default: true }
@ -111,7 +113,6 @@ describe Admin::ThemesController do
end
it 'can unset default theme' do
theme = Theme.create(name: 'my name', user_id: -1)
SiteSetting.default_theme_key = theme.key
put :update, params: {
@ -122,7 +123,6 @@ describe Admin::ThemesController do
end
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.save