From 6a7920ad75f216e52c26a5d87a16e59ad21393fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 27 Sep 2017 20:05:31 +0200 Subject: [PATCH] FIX: wasn't able to change default theme --- app/controllers/admin/themes_controller.rb | 7 +++---- spec/controllers/admin/themes_controller_spec.rb | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb index eb36ea4ade6..1ba250abf3f 100644 --- a/app/controllers/admin/themes_controller.rb +++ b/app/controllers/admin/themes_controller.rb @@ -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 diff --git a/spec/controllers/admin/themes_controller_spec.rb b/spec/controllers/admin/themes_controller_spec.rb index 16947e17566..ee4dc41930b 100644 --- a/spec/controllers/admin/themes_controller_spec.rb +++ b/spec/controllers/admin/themes_controller_spec.rb @@ -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