FIX: Wizard icons step fields have incorrect values

FIX: Wizard icons step fields have incorrect values.

From 596e09aaf9c45abe3758ebaea6787e34844bf365 Mon Sep 17 00:00:00 2001
From: Guo Xiang Tan <tgx_world@hotmail.com>
Date: Thu, 22 Nov 2018 14:19:36 +0800
Subject: [PATCH] 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

diff --git a/lib/wizard/builder.rb b/lib/wizard/builder.rb
index ec33a32..ba6b615 100644
--- a/lib/wizard/builder.rb
+++ b/lib/wizard/builder.rb
@@ -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)
diff --git a/spec/components/wizard/wizard_builder_spec.rb b/spec/components/wizard/wizard_builder_spec.rb
index a9cc3f0..78dc44a 100644
--- a/spec/components/wizard/wizard_builder_spec.rb
+++ b/spec/components/wizard/wizard_builder_spec.rb
@@ -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' } }

GitHub

2 Likes

This commit has been mentioned on Discourse Meta. There might be relevant details there: