Skip to content

Commit

Permalink
Add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
njaeggi committed Nov 21, 2024
1 parent 10b4dcf commit fd363e8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spec/models/memberships/join_zusatzsektion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,24 @@ def create_role(key, role, owner: person, **attrs)
ActiveRecord::Base.transaction do
expect(join_sektion).to be_valid
expect { join_sektion.save! }.to change { person.reload.roles.count }.by(1)
.and not_change { ExternalInvoice::SacMembership.count }
.and not_change { Delayed::Job.where("handler like '%CreateMembershipInvoiceJob%'").count }
end
end

it "prefers to create role in NeuanmeldungenSektion group" do
expect { join_sektion.save! }.to change { person.reload.roles.count }.by(1)
.and not_change { ExternalInvoice::SacMembership.count }
.and not_change { Delayed::Job.where("handler like '%CreateMembershipInvoiceJob%'").count }
expect(role.group).to eq groups(:matterhorn_neuanmeldungen_sektion)
expect(role.type).to eq "Group::SektionsNeuanmeldungenSektion::NeuanmeldungZusatzsektion"
end

it "falls back to create role in NeuanmeldungenSektionNv group" do
groups(:matterhorn_neuanmeldungen_sektion).destroy
expect { join_sektion.save! }.to change { person.reload.roles.count }.by(1)
.and change { ExternalInvoice::SacMembership.count }.by(1)
.and change { Delayed::Job.where("handler like '%CreateMembershipInvoiceJob%'").count }.by(1)
expect(role.group).to eq groups(:matterhorn_neuanmeldungen_nv)
expect(role.type).to eq "Group::SektionsNeuanmeldungenNv::NeuanmeldungZusatzsektion"
end
Expand All @@ -179,12 +185,16 @@ def create_role(key, role, owner: person, **attrs)
neuanmeldungen = Fabricate(Group::SektionsNeuanmeldungenSektion.sti_name,
parent: sektion)
expect { join_sektion.save! }.to change { person.reload.roles.count }.by(1)
.and not_change { ExternalInvoice::SacMembership.count }
.and not_change { Delayed::Job.where("handler like '%CreateMembershipInvoiceJob%'").count }
expect(role.group).to eq neuanmeldungen
expect(role.type).to eq "Group::SektionsNeuanmeldungenSektion::NeuanmeldungZusatzsektion"
end

it "falls back to create role in NeuanmeldungenSektionNv group" do
expect { join_sektion.save! }.to change { person.reload.roles.count }.by(1)
.and change { ExternalInvoice::SacMembership.count }.by(1)
.and change { Delayed::Job.where("handler like '%CreateMembershipInvoiceJob%'").count }.by(1)
expect(role.group).to eq groups(:bluemlisalp_ortsgruppe_ausserberg_neuanmeldungen_nv)
expect(role.type).to eq "Group::SektionsNeuanmeldungenNv::NeuanmeldungZusatzsektion"
end
Expand Down Expand Up @@ -231,6 +241,8 @@ def create_sac_family(person, *others)
expect do
expect(join_sektion.save!).to eq true
end.to change { Role.count }.by(2)
.and not_change { ExternalInvoice::SacMembership.count }
.and not_change { Delayed::Job.where("handler like '%CreateMembershipInvoiceJob%'").count }
expect(role.beitragskategorie).to eq "family"
expect(role(other).beitragskategorie).to eq "family"
end
Expand Down

0 comments on commit fd363e8

Please sign in to comment.