Sha256: f37013f3f892e67419f56b2a838d00e1a4dcf0e531999791df72ca69f7fb63d2

Contents?: true

Size: 1.73 KB

Versions: 17

Compression:

Stored size: 1.73 KB

Contents

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

17 entries across 17 versions & 1 rubygems

Version Path
solidus_backend-2.5.2 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.5.1 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.5.0 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.5.0.rc1 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.5.0.beta2 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.5.0.beta1 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.4.2 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.4.1 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.3.1 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.4.0 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.4.0.rc1 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.4.0.beta1 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.3.0 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.3.0.rc3 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.3.0.rc2 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.3.0.rc1 spec/features/admin/orders/return_payment_state_spec.rb
solidus_backend-2.3.0.beta1 spec/features/admin/orders/return_payment_state_spec.rb