Sha256: d3cedf551428005e33aa618488234618f3ef6a84c2c3d879bc8280957db7f7ba

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require_relative '../../test_helper'

module PagarMe
  class RecipientTest < PagarMeTestCase

    should 'be able to create a recipient with bank_account data' do
      recipient = PagarMe::Recipient.create recipient_with_nested_bank_account_params
      assert_not_nil recipient.date_created
    end

    should 'be able to create a recipient with bank_account id' do
      bank_account = PagarMe::BankAccount.create bank_account_params
      recipient    = PagarMe::Recipient.create recipient_params(bank_account_id: bank_account.id)

      assert_not_nil recipient.date_created
    end

    should 'not be able to create a recipient without bank_account data' do
      recipient = PagarMe::Recipient.new recipient_params
      exception = assert_raises(PagarMe::ValidationError){ recipient.create }
      assert_has_error_param exception, 'bank_account_id'
      assert_nil recipient.date_created
    end

    should 'be able to search' do
      PagarMe::Recipient.create recipient_with_nested_bank_account_params

      bank_account_doc_number = bank_account_params[:document_number]
      recipients = PagarMe::Recipient.find_by 'bank_account[document_number]' => bank_account_doc_number

      assert recipients.size > 0
      recipients.each do |recipient|
        assert_equal recipient.bank_account.document_number, bank_account_doc_number
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pagarme-2.1.3 test/pagarme/resources/recipient_test.rb