From 712c15e84515194b499195bd7592b34d3a4eaa94 Mon Sep 17 00:00:00 2001 From: merefield Date: Wed, 21 Jun 2023 09:53:42 +0100 Subject: [PATCH 1/2] FIX: upon revisit, start at step 1 if reset on revisit is set --- lib/custom_wizard/wizard.rb | 2 +- spec/components/custom_wizard/wizard_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/custom_wizard/wizard.rb b/lib/custom_wizard/wizard.rb index 3d62cf25..bb22f873 100644 --- a/lib/custom_wizard/wizard.rb +++ b/lib/custom_wizard/wizard.rb @@ -145,7 +145,7 @@ class CustomWizard::Wizard step.last_step = true end - if step.previous && step.previous.id === last_completed_step_id + if !@restart_on_revisit && step.previous && step.previous.id === last_completed_step_id @start = step.id end end diff --git a/spec/components/custom_wizard/wizard_spec.rb b/spec/components/custom_wizard/wizard_spec.rb index 17151077..3483d211 100644 --- a/spec/components/custom_wizard/wizard_spec.rb +++ b/spec/components/custom_wizard/wizard_spec.rb @@ -226,6 +226,21 @@ describe CustomWizard::Wizard do end end + context "with subscription and restart upon revisit" do + before do + enable_subscription("standard") + @wizard.restart_on_revisit = true + CustomWizard::Template.save(@wizard.as_json) + end + + it "returns to step 1 if option to clear submissions on each visit is set" do + append_steps + expect(@wizard.unfinished?).to eq(true) + progress_step('step_1') + expect(@wizard.start).to eq('step_1') + end + end + context "with subscription and guest wizard" do before do enable_subscription("standard") From d9ace0449fffff6be0ac3ccc97d1fd3cabebb7ac Mon Sep 17 00:00:00 2001 From: merefield Date: Wed, 21 Jun 2023 09:56:46 +0100 Subject: [PATCH 2/2] Bump patch --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 47edb07d..c2a2578a 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-custom-wizard # about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more. -# version: 2.4.5 +# version: 2.4.6 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech