From 28cd49f02ba97478bf3ed88b44f515b90ceb5b98 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 16 Sep 2016 12:13:54 -0400 Subject: [PATCH] Split Logos and Icons into separate steps --- config/locales/server.en.yml | 4 ++++ lib/wizard/builder.rb | 9 ++++++++- spec/components/step_updater_spec.rb | 17 ++++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index ec0b07266..074c1819a 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -3306,6 +3306,10 @@ en: logo_small_url: label: "Small Logo" description: "The small logo image at the top left of your site, should be a square shape, seen when scrolling down." + + icons: + title: "Icons" + fields: favicon_url: label: "Small Icon" description: "A favicon for your site. To work correctly over a CDN it must be a png." diff --git a/lib/wizard/builder.rb b/lib/wizard/builder.rb index ddd120c2a..5ed314c26 100644 --- a/lib/wizard/builder.rb +++ b/lib/wizard/builder.rb @@ -133,11 +133,18 @@ class Wizard @wizard.append_step('logos') do |step| step.add_field(id: 'logo_url', type: 'image', value: SiteSetting.logo_url) step.add_field(id: 'logo_small_url', type: 'image', value: SiteSetting.logo_small_url) + + step.on_update do |updater| + updater.apply_settings(:logo_url, :logo_small_url) + end + end + + @wizard.append_step('icons') do |step| step.add_field(id: 'favicon_url', type: 'image', value: SiteSetting.favicon_url) step.add_field(id: 'apple_touch_icon_url', type: 'image', value: SiteSetting.apple_touch_icon_url) step.on_update do |updater| - updater.apply_settings(:logo_url, :logo_small_url, :favicon_url, :apple_touch_icon_url) + updater.apply_settings(:favicon_url, :apple_touch_icon_url) end end diff --git a/spec/components/step_updater_spec.rb b/spec/components/step_updater_spec.rb index 7d44280e9..648d10803 100644 --- a/spec/components/step_updater_spec.rb +++ b/spec/components/step_updater_spec.rb @@ -165,20 +165,31 @@ describe Wizard::StepUpdater do it "updates the fields correctly" do updater = wizard.create_updater('logos', logo_url: '/uploads/logo.png', - logo_small_url: '/uploads/logo-small.png', - favicon_url: "/uploads/favicon.png", - apple_touch_icon_url: "/uploads/apple.png") + logo_small_url: '/uploads/logo-small.png') updater.update expect(updater).to be_success expect(wizard.completed_steps?('logos')).to eq(true) expect(SiteSetting.logo_url).to eq('/uploads/logo.png') expect(SiteSetting.logo_small_url).to eq('/uploads/logo-small.png') + end + end + + context "icons step" do + it "updates the fields correctly" do + updater = wizard.create_updater('icons', + favicon_url: "/uploads/favicon.png", + apple_touch_icon_url: "/uploads/apple.png") + updater.update + + expect(updater).to be_success + expect(wizard.completed_steps?('icons')).to eq(true) expect(SiteSetting.favicon_url).to eq('/uploads/favicon.png') expect(SiteSetting.apple_touch_icon_url).to eq('/uploads/apple.png') end end + context "invites step" do let(:invites) { return [{ email: 'regular@example.com', role: 'regular'},