Files
openfoodnetwork/spec/models/billable_period_spec.rb
Maikel Linke cd7721a127 Using date and time of current timezone
Using Time.zone.now and Date.current instead of Time.now and Date.today.
This should make all specs timezone independent.
2015-12-10 11:38:41 +11:00

28 lines
1.0 KiB
Ruby

require 'spec_helper'
describe Customer, type: :model do
describe 'ensure_correct_adjustment' do
let!(:start_of_july) { Time.zone.now.beginning_of_year + 6.months }
let!(:user) { create(:user) }
let!(:invoice) { create(:order, user: user) }
let!(:billable_period) { create(:billable_period, owner: user, begins_at: start_of_july, ends_at: start_of_july + 12.days) }
before do
allow(billable_period).to receive(:bill) { 99 }
allow(billable_period).to receive(:adjustment_label) { "Label for adjustment" }
Spree::Config.set({ account_bill_inc_tax: true })
Spree::Config.set({ account_bill_tax_rate: 0.1 })
end
context "when no adjustment currently exists" do
it "creates an adjustment on the given order" do
expect(invoice.total_tax).to eq 0.0
expect(billable_period.adjustment).to be nil
billable_period.ensure_correct_adjustment_for(invoice)
expect(billable_period.adjustment).to be_a Spree::Adjustment
expect(invoice.total_tax).to eq 9.0
end
end
end
end