Skip to content

Commit

Permalink
Add spec to check if wizard is viewable
Browse files Browse the repository at this point in the history
  • Loading branch information
njaeggi authored and amaierhofer committed Dec 18, 2024
1 parent f86b1ec commit 3dcc5b7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spec/models/wizards/signup/abo_basic_login_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,19 @@ def build(params = required_attrs)
expect(wizard.step_at(0)).to be_instance_of(Wizards::Steps::Signup::AboBasicLogin::PersonFields)
end
end

describe "#member_or_applied?" do
before do
allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:mitglied))
end

it "returns true when user has login" do
expect(wizard.member_or_applied?).to be_truthy
end

it "returns true if user does not have login" do
allow(people(:admin)).to receive(:login?).and_return(false)
expect(wizard.member_or_applied?).to be_falsy
end
end
end
24 changes: 24 additions & 0 deletions spec/models/wizards/signup/abo_magazin_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,28 @@ def build(params = required_attrs)
expect(wizard.step_at(1)).to be_instance_of(Wizards::Steps::Signup::AboMagazin::Summary)
end
end

describe "#member_or_applied?" do
before do
allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:mitglied))
end

it "returns true when user has abonnent role" do
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))
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))
expect(wizard.member_or_applied?).to be_truthy
end

it "returns false if user does not have role" do
expect(wizard.member_or_applied?).to be_falsy
end
end
end
20 changes: 20 additions & 0 deletions spec/models/wizards/signup/abo_touren_portal_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,24 @@ def build(params = required_attrs)
expect(wizard.step_at(0)).to be_instance_of(Wizards::Steps::Signup::AboTourenPortal::PersonFields)
end
end

describe "#member_or_applied?" do
before do
allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:mitglied))
end

it "returns true when user has abonnent role" do
Group::AboTourenPortal::Abonnent.create!(person: people(:mitglied), group: 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)
expect(wizard.member_or_applied?).to be_truthy
end

it "returns false if user does not have role" do
expect(wizard.member_or_applied?).to be_falsy
end
end
end

0 comments on commit 3dcc5b7

Please sign in to comment.