Skip to content

Commit b1ed2a3

Browse files
authored
Create StringInquirer only if beitragskategorie is present (#1625)
1 parent 87dc1ac commit b1ed2a3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

app/models/sac_cas/role.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ def membership_years
9191
end
9292

9393
def beitragskategorie
94-
ActiveSupport::StringInquirer.new(super)
94+
ActiveSupport::StringInquirer.new(super) if super
9595
end
9696
end

spec/models/role_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,16 @@ def create_role(**attrs)
430430
expect(role.termination_reason_text).to eq "Sonstiger Grund"
431431
end
432432
end
433+
434+
context "#beitragskategorie" do
435+
it "returns beitragskategorie as string active support string inquirer" do
436+
role = roles(:mitglied)
437+
expect(role.beitragskategorie.class).to eq(ActiveSupport::StringInquirer)
438+
end
439+
440+
it "returns empty string if beitragskategorie is nil" do
441+
role = roles(:abonnent_alpen)
442+
expect(role.beitragskategorie).to be_nil
443+
end
444+
end
433445
end

0 commit comments

Comments
 (0)