Sha256: 42102ea61b3674890f4e9b49b49842f28338665e86b7968b75bfac2626075add

Contents?: true

Size: 1.76 KB

Versions: 26

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe "Return payment state spec" do
  stub_authorization!

  before do
    Spree::RefundReason.create!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false)
  end

  let!(:order) { create(:shipped_order) }

  # Regression test for https://github.com/spree/spree/issues/6229
  it "refunds and has outstanding_balance of zero", js: true do
    expect(order).to have_attributes(
      total: 110,
      refund_total: 0,
      payment_total: 110,
      outstanding_balance: 0,
      payment_state: 'paid'
    )

    # From an order with a shipped shipment
    visit "/admin/orders/#{order.number}/edit"

    # Create a Return Authorization (select the Original Reimbursement type)
    click_on 'RMA'
    click_on 'New RMA'

    find('.add-item').click # check first (and only) item
    select Spree::StockLocation.first.name, from: 'return_authorization[stock_location_id]', visible: false
    click_on 'Create'

    # Create a Customer Return (select the item from 'Items in Return Authorizations')
    click_on 'Customer Returns'
    click_on 'New Customer Return'

    find('input.add-item').click # check first (and only) item
    select 'Received', from: 'customer_return[return_items_attributes][0][reception_status_event]', visible: false
    select Spree::StockLocation.first.name, from: 'customer_return[stock_location_id]', visible: false
    click_on 'Create'

    # Create reimbursement
    click_on 'Create reimbursement'

    # Reimburse.
    click_on 'Reimburse'

    expect(page).to have_css('tr.reimbursement-refund')

    order.reload

    expect(order).to have_attributes(
      total: 110,
      refund_total: 10,
      payment_total: 100,
      outstanding_balance: 0,
      payment_state: 'paid'
    )
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
solidus_backend-2.6.6 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.7.4 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.7.3 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.6.5 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.7.2 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.6.4 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.6.3 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.7.1 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.6.2 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.14 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.13 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.12 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.11 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.10 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.9 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.8 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.7 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.6 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.5 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend_devise_token_auth-2.8.0.alpha.4 spec/features/admin/orders/return_payment_state_spec.rb