mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Spec admin display of Taler payment actions
This should satisfy code coverage.
This commit is contained in:
@@ -238,6 +238,8 @@ FactoryBot.define do
|
||||
factory :completed_order_with_fees, parent: :order_with_distributor do
|
||||
transient do
|
||||
payment_fee { 5 }
|
||||
payment_calculator { build(:calculator_per_item, preferred_amount: payment_fee) }
|
||||
payment_method { build(:payment_method, calculator: payment_calculator) }
|
||||
shipping_fee { 3 }
|
||||
shipping_tax_category { nil }
|
||||
end
|
||||
@@ -250,11 +252,9 @@ FactoryBot.define do
|
||||
product = create(:simple_product)
|
||||
create(:line_item, order:, product:)
|
||||
|
||||
payment_calculator = build(:calculator_per_item, preferred_amount: evaluator.payment_fee)
|
||||
payment_method = create(:payment_method, calculator: payment_calculator)
|
||||
create(:payment, order:,
|
||||
amount: order.total,
|
||||
payment_method:,
|
||||
payment_method: evaluator.payment_method,
|
||||
state: 'checkout')
|
||||
|
||||
create(:shipping_method_with, :shipping_fee, shipping_fee: evaluator.shipping_fee,
|
||||
|
||||
8
spec/support/table_helper.rb
Normal file
8
spec/support/table_helper.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module TableHelper
|
||||
# Selector for table row that has the given string
|
||||
def row_containing(value)
|
||||
find(:xpath, "(//tr[contains(., '#{value}')])")
|
||||
end
|
||||
end
|
||||
52
spec/system/admin/payments_taler_spec.rb
Normal file
52
spec/system/admin/payments_taler_spec.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'system_helper'
|
||||
|
||||
RSpec.describe "Admin -> Order -> Payments" do
|
||||
include AuthenticationHelper
|
||||
include TableHelper
|
||||
|
||||
let(:distributor) { build(:distributor_enterprise) }
|
||||
let(:order) { create(:completed_order_with_fees, distributor:, payments: [payment]) }
|
||||
let(:payment) {
|
||||
build(:payment, :completed, payment_method: taler, source: taler, response_code: "taler-id-1")
|
||||
}
|
||||
let(:taler) {
|
||||
Spree::PaymentMethod::Taler.new(
|
||||
name: "Taler",
|
||||
distributors: [distributor],
|
||||
environment: "test",
|
||||
preferred_backend_url: "https://taler.example.com",
|
||||
preferred_api_key: "sandbox",
|
||||
)
|
||||
}
|
||||
|
||||
before do
|
||||
login_as distributor.owner
|
||||
end
|
||||
|
||||
it "allows to refund a Taler payment" do
|
||||
order_status = {
|
||||
order_status: "paid",
|
||||
contract_terms: {
|
||||
amount: "KUDOS:2",
|
||||
}
|
||||
}
|
||||
order_endpoint = "https://taler.example.com/private/orders/taler-id-1"
|
||||
refund_endpoint = "https://taler.example.com/private/orders/taler-id-1/refund"
|
||||
stub_request(:get, order_endpoint).to_return(body: order_status.to_json)
|
||||
stub_request(:post, refund_endpoint).to_return(body: "{}")
|
||||
|
||||
visit spree.admin_order_payments_path(order.number)
|
||||
|
||||
within row_containing("Taler") do
|
||||
expect(page).to have_text "COMPLETED"
|
||||
expect(page).to have_link class: "icon-void"
|
||||
|
||||
click_link class: "icon-void"
|
||||
|
||||
expect(page).to have_text "VOID"
|
||||
expect(page).not_to have_link class: "icon-void"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user