From 5c4bde03382176119fe0d4c4415cf5a4888aef2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20J=C3=A4ggi?= Date: Tue, 17 Dec 2024 15:54:42 +0100 Subject: [PATCH] Add specs for current steps --- .../wizards/signup/abo_basic_login_wizard_spec.rb | 12 ++++++++++++ .../wizards/signup/abo_magazin_wizard_spec.rb | 14 ++++++++++++++ .../signup/abo_touren_portal_wizard_spec.rb | 12 ++++++++++++ 3 files changed, 38 insertions(+) diff --git a/spec/models/wizards/signup/abo_basic_login_wizard_spec.rb b/spec/models/wizards/signup/abo_basic_login_wizard_spec.rb index 15b2cb800..6c51657d7 100644 --- a/spec/models/wizards/signup/abo_basic_login_wizard_spec.rb +++ b/spec/models/wizards/signup/abo_basic_login_wizard_spec.rb @@ -105,4 +105,16 @@ def build(params = required_attrs) expect(newsletter.people).to be_empty end end + + describe "steps" do + it "starts at main email field step when not logged in" do + expect(wizard.step_at(0)).to be_instance_of(Wizards::Steps::Signup::MainEmailField) + expect(wizard.step_at(1)).to be_instance_of(Wizards::Steps::Signup::AboBasicLogin::PersonFields) + end + + it "starts at person fields step when logged in" do + allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:admin)) + expect(wizard.step_at(0)).to be_instance_of(Wizards::Steps::Signup::AboBasicLogin::PersonFields) + end + end end diff --git a/spec/models/wizards/signup/abo_magazin_wizard_spec.rb b/spec/models/wizards/signup/abo_magazin_wizard_spec.rb index aa216ad28..8e9cf68a8 100644 --- a/spec/models/wizards/signup/abo_magazin_wizard_spec.rb +++ b/spec/models/wizards/signup/abo_magazin_wizard_spec.rb @@ -141,4 +141,18 @@ def build(params = required_attrs) expect(wizard.calculated_costs).to eq(76) end end + + describe "steps" do + it "starts at main email field step when not logged in" do + expect(wizard.step_at(0)).to be_instance_of(Wizards::Steps::Signup::MainEmailField) + expect(wizard.step_at(1)).to be_instance_of(Wizards::Steps::Signup::AboMagazin::PersonFields) + expect(wizard.step_at(2)).to be_instance_of(Wizards::Steps::Signup::AboMagazin::Summary) + end + + it "starts at person fields step when logged in" do + allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:admin)) + expect(wizard.step_at(0)).to be_instance_of(Wizards::Steps::Signup::AboMagazin::PersonFields) + expect(wizard.step_at(1)).to be_instance_of(Wizards::Steps::Signup::AboMagazin::Summary) + end + end end diff --git a/spec/models/wizards/signup/abo_touren_portal_wizard_spec.rb b/spec/models/wizards/signup/abo_touren_portal_wizard_spec.rb index 2aad5a471..3d68d2113 100644 --- a/spec/models/wizards/signup/abo_touren_portal_wizard_spec.rb +++ b/spec/models/wizards/signup/abo_touren_portal_wizard_spec.rb @@ -115,4 +115,16 @@ def build(params = required_attrs) expect(newsletter.people).to eq [max] end end + + describe "steps" do + it "starts at main email field step when not logged in" do + expect(wizard.step_at(0)).to be_instance_of(Wizards::Steps::Signup::MainEmailField) + expect(wizard.step_at(1)).to be_instance_of(Wizards::Steps::Signup::AboTourenPortal::PersonFields) + end + + it "starts at person fields step when logged in" do + allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:admin)) + expect(wizard.step_at(0)).to be_instance_of(Wizards::Steps::Signup::AboTourenPortal::PersonFields) + end + end end