FIX: Wizard icons step fields have incorrect values.

https://meta.discourse.org/t/is-the-wizard-supposed-to-not-let-you-skip-adding-icons/102417
This commit is contained in:
Guo Xiang Tan 2018-11-22 14:19:36 +08:00
parent ba280f9cf3
commit 596e09aaf9
2 changed files with 45 additions and 6 deletions

View File

@ -154,8 +154,8 @@ class Wizard
end
@wizard.append_step('icons') do |step|
step.add_field(id: 'favicon', type: 'image', value: SiteSetting.favicon)
step.add_field(id: 'apple_touch_icon', type: 'image', value: SiteSetting.apple_touch_icon)
step.add_field(id: 'favicon', type: 'image', value: SiteSetting.site_favicon_url)
step.add_field(id: 'apple_touch_icon', type: 'image', value: SiteSetting.site_apple_touch_icon_url)
step.on_update do |updater|
updater.apply_settings(:favicon)

View File

@ -4,11 +4,11 @@ require 'wizard/builder'
describe Wizard::Builder do
let(:moderator) { Fabricate.build(:moderator) }
let(:wizard) { Wizard::Builder.new(moderator).build }
it "returns a wizard with steps when enabled" do
SiteSetting.wizard_enabled = true
wizard = Wizard::Builder.new(moderator).build
expect(wizard).to be_present
expect(wizard.steps).to be_present
end
@ -22,7 +22,6 @@ describe Wizard::Builder do
it "returns a wizard without steps when disabled" do
SiteSetting.wizard_enabled = false
wizard = Wizard::Builder.new(moderator).build
expect(wizard).to be_present
expect(wizard.steps).to be_blank
end
@ -30,13 +29,53 @@ describe Wizard::Builder do
it "returns wizard with disabled invites step when local_logins are off" do
SiteSetting.enable_local_logins = false
wizard = Wizard::Builder.new(moderator).build
invites_step = wizard.steps.find { |s| s.id == "invites" }
expect(invites_step.fields).to be_blank
expect(invites_step.disabled).to be_truthy
end
context 'logos step' do
let(:logos_step) { wizard.steps.find { |s| s.id == 'logos' } }
it 'should set the right default value for the fields' do
upload = Fabricate(:upload)
upload2 = Fabricate(:upload)
SiteSetting.logo = upload
SiteSetting.logo_small = upload2
fields = logos_step.fields
logo_field = fields.first
logo_small_field = fields.last
expect(logo_field.id).to eq('logo')
expect(logo_field.value).to eq(upload.url)
expect(logo_small_field.id).to eq('logo_small')
expect(logo_small_field.value).to eq(upload2.url)
end
end
context 'icons step' do
let(:icons_step) { wizard.steps.find { |s| s.id == 'icons' } }
it 'should set the right default value for the fields' do
upload = Fabricate(:upload)
upload2 = Fabricate(:upload)
SiteSetting.favicon = upload
SiteSetting.apple_touch_icon = upload2
fields = icons_step.fields
favicon_field = fields.first
apple_touch_icon_field = fields.last
expect(favicon_field.id).to eq('favicon')
expect(favicon_field.value).to eq(upload.url)
expect(apple_touch_icon_field.id).to eq('apple_touch_icon')
expect(apple_touch_icon_field.value).to eq(upload2.url)
end
end
context 'introduction step' do
let(:wizard) { Wizard::Builder.new(moderator).build }
let(:introduction_step) { wizard.steps.find { |s| s.id == 'introduction' } }