Skip to content

Commit

Permalink
Cleanup specs a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
amaierhofer committed Dec 18, 2024
1 parent 062a04f commit ab3cca4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 7 additions & 4 deletions spec/models/wizards/signup/abo_magazin_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions spec/models/wizards/signup/abo_touren_portal_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ab3cca4

Please sign in to comment.