Skip to content

Commit

Permalink
Add model spec for saving records
Browse files Browse the repository at this point in the history
  • Loading branch information
njaeggi committed Dec 17, 2024
1 parent 5c4bde0 commit a567673
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 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 @@ -104,6 +104,13 @@ def build(params = required_attrs)
expect(max.subscriptions).to be_empty
expect(newsletter.people).to be_empty
end

it "saves role for current_user when logged in" do
allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:admin))
expect(wizard).to be_valid
expect { wizard.save! }.not_to change { Person.count }
expect(people(:admin).roles.last.type).to eq Group::AboBasicLogin::BasicLogin.sti_name
end
end

describe "steps" do
Expand Down
7 changes: 7 additions & 0 deletions spec/models/wizards/signup/abo_magazin_wizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ def build(params = required_attrs)
.with(kind_of(Person), group, true)
end
end

it "saves role for current_user when logged in" do
allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:admin))
expect(wizard).to be_valid
expect { wizard.save! }.not_to change { Person.count }
expect(people(:admin).roles.last.type).to eq Group::AboMagazin::Abonnent.sti_name
end
end

describe "#calculate_costs" do
Expand Down
7 changes: 7 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 @@ -114,6 +114,13 @@ def build(params = required_attrs)
expect(max.subscriptions).to have(1).item
expect(newsletter.people).to eq [max]
end

it "saves role for current_user when logged in" do
allow_any_instance_of(Wizards::Signup::AboBasicLoginWizard).to receive(:current_user).and_return(people(:admin))
expect(wizard).to be_valid
expect { wizard.save! }.not_to change { Person.count }
expect(people(:admin).roles.last.type).to eq Group::AboTourenPortal::Abonnent.sti_name
end
end

describe "steps" do
Expand Down

0 comments on commit a567673

Please sign in to comment.