Skip to content

Commit

Permalink
Add null safe approach in extend_membership_duration
Browse files Browse the repository at this point in the history
  • Loading branch information
njaeggi committed Feb 10, 2025
1 parent 87dc1ac commit df7a05b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/domain/invoices/sac_memberships/membership_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def update_membership_status

def extend_membership_duration
relevant_roles_for(person.sac_membership.stammsektion_role).each do |role|
role.update!(end_on: [Date.new(year).end_of_year, role.end_on].max)
role.update!(end_on: [Date.new(year).end_of_year, role.end_on || Date.new(0)].max)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ def updated_roles_count
Role.update_all(end_on: end_of_next_year + 5.years)
expect(updated_roles_count).to eq(0)
end

it "does not raise error when current stammsektion role does not have end_on defined" do
mitglied.update_column(:end_on, nil)
except(subject.update_membership_status).not_to raise_error
end
end

context "family" do
Expand Down

0 comments on commit df7a05b

Please sign in to comment.