Skip to content

Commit

Permalink
🥗🧹 Tobias: Define Payment relationships and attributes
Browse files Browse the repository at this point in the history
This is not super important to the actual feature, but it does mean that
the `Payment` has clearly defined relationships, with tests that confirm
the relationship.

It also adds a spec to check that the `#amount` value operates as a
monetized value; which doesn't seem like it does that much beyond giving
us an injection point for layering in additional details.
  • Loading branch information
zspencer committed Jan 29, 2024
1 parent 6686e51 commit e79e2b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/furniture/tobias/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Tobias
class Payment < ApplicationRecord
self.table_name = "tobias_payments"

belongs_to :payout
belongs_to :payout, inverse_of: :payments

monetize :amount_cents
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "faker"
require "pundit/rspec"
require "simplecov"
require "money-rails/test_helpers"

SimpleCov.start do
enable_coverage :branch
Expand Down
11 changes: 11 additions & 0 deletions spec/tobias/payment_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require "rails_helper"

RSpec.describe Tobias::Payment, type: :model do
describe "#payout" do
it { is_expected.to belong_to(:payout).inverse_of(:payments) }
end

describe "#amount" do
it { is_expected.to monetize(:amount) }
end
end

0 comments on commit e79e2b6

Please sign in to comment.