From bd1328c189126e3844a5d90ec7518995de3e707f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 14 Oct 2016 11:09:55 +0200 Subject: [PATCH] FIX: show the wizard to developers too --- lib/wizard.rb | 18 ++++++++---------- spec/components/wizard_spec.rb | 7 ------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/wizard.rb b/lib/wizard.rb index 5fc99bee7fe..0ae5e6ac59a 100644 --- a/lib/wizard.rb +++ b/lib/wizard.rb @@ -36,7 +36,7 @@ class Wizard end def steps_with_fields - @steps_with_fields ||= @steps.select {|s| s.has_fields? } + @steps_with_fields ||= @steps.select(&:has_fields?) end def start @@ -54,7 +54,7 @@ class Wizard end def create_updater(step_id, fields) - step = @steps.find {|s| s.id == step_id.dasherize} + step = @steps.find { |s| s.id == step_id.dasherize } Wizard::StepUpdater.new(@user, step, fields) end @@ -76,15 +76,13 @@ class Wizard def requires_completion? return false unless SiteSetting.wizard_enabled? - admins = User.where("admin = true AND id <> ? AND auth_token_updated_at IS NOT NULL", - Discourse.system_user.id).order(:auth_token_updated_at) + first_admin = User.where(admin: true) + .where.not(id: Discourse.system_user.id) + .where.not(auth_token_updated_at: nil) + .order(:auth_token_updated_at) + .first - # In development mode all admins are developers, so the logic is a bit screwy: - unless Rails.env.development? - admins = admins.select {|a| !Guardian.new(a).is_developer? } - end - - admins.present? && admins.first == @user && !completed? && (Topic.count < 15) + @user.present? && first_admin == @user && !completed? && (Topic.count < 15) end end diff --git a/spec/components/wizard_spec.rb b/spec/components/wizard_spec.rb index 6771df76cef..951b72e8845 100644 --- a/spec/components/wizard_spec.rb +++ b/spec/components/wizard_spec.rb @@ -114,13 +114,6 @@ describe Wizard do expect(build_simple(Fabricate.build(:user)).requires_completion?).to eq(false) end - it "is false for a developer" do - developer = Fabricate(:admin) - Developer.create!(user_id: developer.id) - - expect(build_simple(developer).requires_completion?).to eq(false) - end - it "it's false when the wizard is disabled" do SiteSetting.wizard_enabled = false admin = Fabricate(:admin)