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/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 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")