Sha256: 2257511de781c46b293e3529365665e048f3975a6e39ee49fdd517164117ec70

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require "solidus_stripe_spec_helper"

RSpec.describe SolidusStripe::Webhook::ChargeSubscriber do
  describe "#sync_refunds" do
    it "synchronizes refunds" do
      SolidusStripe::Seeds.refund_reasons
      payment_method = create(:solidus_stripe_payment_method)
      stripe_payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123")
      payment = create(:payment,
        amount: 10,
        payment_method: payment_method,
        response_code: stripe_payment_intent.id,
        state: "completed")
      stripe_charge = Stripe::Charge.construct_from(id: "ch_123", payment_intent: "pi_123")
      allow(Stripe::Refund).to receive(:list).with(payment_intent: stripe_payment_intent.id).and_return(
        Stripe::ListObject.construct_from(
          data: [{ id: "re_123", amount: 1000, currency: "usd", metadata: {} }]
        )
      )
      event = SolidusStripe::Webhook::EventWithContextFactory.from_object(
        payment_method: payment_method,
        object: stripe_charge,
        type: "charge.refunded"
      ).solidus_stripe_object

      described_class.new.sync_refunds(event)

      expect(payment.refunds.count).to be(1)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_stripe-5.0.2 spec/subscribers/solidus_stripe/webhook/charge_subscriber_spec.rb
solidus_stripe-5.0.1 spec/subscribers/solidus_stripe/webhook/charge_subscriber_spec.rb
solidus_stripe-5.0.0 spec/subscribers/solidus_stripe/webhook/charge_subscriber_spec.rb
solidus_stripe-5.0.0.rc.3 spec/subscribers/solidus_stripe/webhook/charge_subscriber_spec.rb
solidus_stripe-5.0.0.rc.2 spec/subscribers/solidus_stripe/webhook/charge_subscriber_spec.rb
solidus_stripe-5.0.0.rc.1 spec/subscribers/solidus_stripe/webhook/charge_subscriber_spec.rb