Files
openfoodnetwork/spec/features/admin/payments_spec.rb
Pau Perez 5815d1a4a4 Make #outstanding_balance return an OrderBalance
This will let us branch by abstraction. All existing calls to
`#outstanding_balance` will go through `OrderBalance` hence, will
check the feature toggle.

Note that by default, `OrderBalance` will end up calling
`#old_outstanding_balance`. As the name states, that's exactly what
`#outstanding_balance` was so far. This means no consumers will see any
change in behavior. We just added on item in the call stack (sort of).
2021-03-22 11:45:12 +01:00

39 lines
1.0 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
feature '
As an admin
I want to manage payments
' do
include AuthenticationHelper
let(:order) { create(:completed_order_with_fees) }
describe "payments/new" do
it "displays the order balance as the default payment amount" do
login_as_admin_and_visit spree.new_admin_order_payment_path order
expect(page).to have_content I18n.t(:new_payment)
expect(page).to have_field(:payment_amount, with: order.outstanding_balance.to_f)
end
end
context "with sensitive payment fee" do
before do
payment_method = create(:payment_method, distributors: [order.distributor])
# This calculator doesn't handle a `nil` order well.
# That has been useful in finding bugs. ;-)
payment_method.calculator = Calculator::FlatPercentItemTotal.new
payment_method.save!
end
it "renders the new payment page" do
login_as_admin_and_visit spree.new_admin_order_payment_path order
expect(page).to have_content I18n.t(:new_payment)
end
end
end