From 8051b6fd70ce4349cf84ba7ae7567f61f3785743 Mon Sep 17 00:00:00 2001 From: Andreas Maierhofer Date: Wed, 18 Dec 2024 18:10:25 +0100 Subject: [PATCH] Cleanup specs a bit --- spec/models/wizards/signup/abo_magazin_wizard_spec.rb | 11 +++++++---- .../wizards/signup/abo_touren_portal_wizard_spec.rb | 8 +++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/spec/models/wizards/signup/abo_magazin_wizard_spec.rb b/spec/models/wizards/signup/abo_magazin_wizard_spec.rb index d752c9a83..70ffc6f85 100644 --- a/spec/models/wizards/signup/abo_magazin_wizard_spec.rb +++ b/spec/models/wizards/signup/abo_magazin_wizard_spec.rb @@ -164,22 +164,25 @@ def build(params = required_attrs) end describe "#member_or_applied?" do + let(:person) { people(:mitglied) } + let(:group) { groups(:abo_die_alpen) } + before do - allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:mitglied)) + allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(person) end it "returns true when user has abonnent role" do - Group::AboMagazin::Abonnent.create!(person: people(:mitglied), group: groups(:abo_die_alpen)) + Group::AboMagazin::Abonnent.create!(person:, group:) expect(wizard.member_or_applied?).to be_truthy end it "returns true when user has neuanmeldung role" do - Group::AboMagazin::Neuanmeldung.create!(person: people(:mitglied), group: groups(:abo_die_alpen)) + Group::AboMagazin::Neuanmeldung.create!(person:, group:) expect(wizard.member_or_applied?).to be_truthy end it "returns true when user has gratis abonnent role" do - Group::AboMagazin::Gratisabonnent.create!(person: people(:mitglied), group: groups(:abo_die_alpen)) + Group::AboMagazin::Gratisabonnent.create!(person:, group:) expect(wizard.member_or_applied?).to be_truthy 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 a1a2c219d..335f98393 100644 --- a/spec/models/wizards/signup/abo_touren_portal_wizard_spec.rb +++ b/spec/models/wizards/signup/abo_touren_portal_wizard_spec.rb @@ -136,17 +136,19 @@ def build(params = required_attrs) end describe "#member_or_applied?" do + let(:person) { people(:mitglied) } + before do - allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:mitglied)) + allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(person) end it "returns true when user has abonnent role" do - Group::AboTourenPortal::Abonnent.create!(person: people(:mitglied), group: group) + Group::AboTourenPortal::Abonnent.create!(person:, group:) expect(wizard.member_or_applied?).to be_truthy end it "returns true when user has neuanmeldung role" do - Group::AboTourenPortal::Neuanmeldung.create!(person: people(:mitglied), group: group) + Group::AboTourenPortal::Neuanmeldung.create!(person:, group:) expect(wizard.member_or_applied?).to be_truthy end