Skip to content

Commit

Permalink
add specs around the payment callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohnish Thallavajhula committed Mar 5, 2015
1 parent fe3e2b6 commit 59e7f85
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/models/payment_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
require 'rails_helper'

RSpec.describe Payment do
describe '#update_bill_attributes' do
context 'when the bill is non-recurring' do
let(:payment) do
payment = create(:payment)
payment.bill.update(repeat_interval: create(:repeat_interval, interval: 'one_time'))
payment
end

it 'marks the bill as inactive' do
payment.update_bill_attributes
expect(payment.bill.inactive?).to be_truthy
end
end

context 'when the bill is recurring' do
let(:payment) { create(:payment) }

it 'updates the bills due date' do
payment.update_bill_attributes
expect(payment.bill.next_due_date.strftime('%m/%d/%Y')).to eql(2.months.since.strftime('%m/%d/%Y'))
end
end
end
end

0 comments on commit 59e7f85

Please sign in to comment.