Skip to content

Commit

Permalink
rib: add some convenience for reused RIBs
Browse files Browse the repository at this point in the history
  • Loading branch information
freesteph committed Apr 3, 2024
1 parent 9cf9648 commit 92f48c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/rib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ def active?
def inactive?
!active?
end

def reused?
siblings.any?
end

def siblings
Rib.where(iban: iban).excluding(self)
end
end
16 changes: 16 additions & 0 deletions spec/models/rib_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,20 @@
end
end
end

describe "reused?" do
context "without other ribs" do
it "is false" do
expect(rib).not_to be_reused
end
end

context "with multiple RIBS with the same IBAN" do
before { create(:rib, iban: rib.iban) }

it "returns true" do
expect(rib).to be_reused
end
end
end
end

0 comments on commit 92f48c1

Please sign in to comment.