From 4f9a7aa769eaaaed82a3aa57d7a5591444879282 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 16 Sep 2016 11:48:47 -0400 Subject: [PATCH] FIX: Prompt for the wizard for the first admin who logs in --- lib/wizard.rb | 3 ++- spec/components/wizard_spec.rb | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/wizard.rb b/lib/wizard.rb index d30917f1931..5fc99bee7fe 100644 --- a/lib/wizard.rb +++ b/lib/wizard.rb @@ -76,7 +76,8 @@ class Wizard def requires_completion? return false unless SiteSetting.wizard_enabled? - admins = User.where("admin = true and id <> ?", Discourse.system_user.id).order(:created_at) + admins = User.where("admin = true AND id <> ? AND auth_token_updated_at IS NOT NULL", + Discourse.system_user.id).order(:auth_token_updated_at) # In development mode all admins are developers, so the logic is a bit screwy: unless Rails.env.development? diff --git a/spec/components/wizard_spec.rb b/spec/components/wizard_spec.rb index 067e2bd143b..6771df76cef 100644 --- a/spec/components/wizard_spec.rb +++ b/spec/components/wizard_spec.rb @@ -127,12 +127,12 @@ describe Wizard do expect(build_simple(admin).requires_completion?).to eq(false) end - it "it's true for the first admin" do + it "it's true for the first admin who logs in" do admin = Fabricate(:admin) - expect(build_simple(admin).requires_completion?).to eq(true) + second_admin = Fabricate(:admin, auth_token_updated_at: Time.now) - second_admin = Fabricate(:admin) - expect(build_simple(second_admin).requires_completion?).to eq(false) + expect(build_simple(admin).requires_completion?).to eq(false) + expect(build_simple(second_admin).requires_completion?).to eq(true) end it "is false for staff when complete" do