mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Remove default val for colors step if a default theme has been set.
Running through the wizard after a default theme has been configured will always revert the default theme to the light theme.
This commit is contained in:
@@ -183,6 +183,20 @@ describe Wizard::StepUpdater do
|
||||
end
|
||||
end
|
||||
|
||||
context "with an existing default theme" do
|
||||
fab!(:theme) { Fabricate(:theme) }
|
||||
|
||||
before do
|
||||
theme.set_default!
|
||||
end
|
||||
|
||||
it "should not update the default theme when no option has been selected" do
|
||||
expect do
|
||||
wizard.create_updater('colors', {}).update
|
||||
end.to_not change { SiteSetting.default_theme_id }
|
||||
end
|
||||
end
|
||||
|
||||
context "without an existing theme" do
|
||||
before do
|
||||
Theme.delete_all
|
||||
@@ -203,14 +217,19 @@ describe Wizard::StepUpdater do
|
||||
|
||||
context 'light theme' do
|
||||
it "creates the theme" do
|
||||
updater = wizard.create_updater('colors', {})
|
||||
updater = wizard.create_updater('colors',
|
||||
theme_previews: ColorScheme::LIGHT_THEME_ID
|
||||
)
|
||||
|
||||
expect { updater.update }.to change { Theme.count }.by(1)
|
||||
|
||||
theme = Theme.last
|
||||
|
||||
expect(theme.user_id).to eq(wizard.user.id)
|
||||
expect(theme.color_scheme).to eq(ColorScheme.find_by(name: 'Light'))
|
||||
|
||||
expect(theme.color_scheme).to eq(ColorScheme.find_by(name:
|
||||
ColorScheme::LIGHT_THEME_ID
|
||||
))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -145,4 +145,32 @@ describe Wizard::Builder do
|
||||
expect(login_required_field.id).to eq('privacy')
|
||||
end
|
||||
end
|
||||
|
||||
context "colors step" do
|
||||
fab!(:theme) { Fabricate(:theme) }
|
||||
let(:colors_step) { wizard.steps.find { |s| s.id == 'colors' } }
|
||||
let(:field) { colors_step.fields.first }
|
||||
|
||||
describe "when the default theme has not been override" do
|
||||
before do
|
||||
SiteSetting.find_by(name: "default_theme_id").destroy!
|
||||
end
|
||||
|
||||
it 'should set the right default values' do
|
||||
expect(field.required).to eq(true)
|
||||
expect(field.value).to eq(ColorScheme::LIGHT_THEME_ID)
|
||||
end
|
||||
end
|
||||
|
||||
describe "when the default them hass been override" do
|
||||
before do
|
||||
theme.set_default!
|
||||
end
|
||||
|
||||
it 'should set the right default values' do
|
||||
expect(field.required).to eq(false)
|
||||
expect(field.value).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user