Sha256: 93c04ed1e076b7f79bacd1b9513755aee7973f8e4f7d3ad6a54da1ff6604c248

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

require 'rails_helper'

module BloomRemit
  module Txns
    RSpec.describe Post do

      let(:user) do
        build_stubbed(:bloom_remit_dummy_user, bloom_remit_id: "sender-id")
      end
      let(:txn) do
        build_stubbed(:bloom_remit_txn, {
          target_slug: "PLDT",
          sender: user,
          amount: BigDecimal.new(2000),
          account_name: "029925252",
          account_id: "12345678",
        })
      end
      let(:callback_url) do
        Engine.routes.url_helpers.api_v1_txn_url(txn, secret: txn.secret)
      end
      let(:client) { instance_double(BloomRemitClient::Client) }
      let(:response) { build(:bloom_remit_client_create_payment_response) }

      it "posts the txn to Bloom Remit" do
        expect(client).to receive(:create_payment).with(
          sender_id: "sender-id",
          account_name: "029925252",
          account_number: "12345678",
          callback_url: callback_url,
          dest_currency: "PHP",
          orig_currency: "PHP",
          payout_method: "PLDT",
          paid_in_orig_currency: BigDecimal.new(2000),
          receivable_in_dest_currency: BigDecimal.new(2000),
        ).and_return(response)

        resulting_ctx = described_class.execute(txn: txn, client: client)

        expect(resulting_ctx.remote_response).to eq response
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bloom_remit-0.2.1 spec/services/bloom_remit/txns/post_spec.rb
bloom_remit-0.2.0 spec/services/bloom_remit/txns/post_spec.rb
bloom_remit-0.1.0 spec/services/bloom_remit/txns/post_spec.rb