Sha256: 94363a89ecea13a12267aa761bc4589fc563a916b2caaadedb8e4b61d8e47a23

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require_relative '../../test_helper'

module PagarMe
  class RecipientTest < Test::Unit::TestCase

    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 }

      [:bank_code, :agencia, :conta_dv, :conta, :document_number, :legal_name].each do |missing_attr|
        assert_has_error_param exception, "bank_account[#{missing_attr}]"
      end
      assert_nil recipient.date_created
    end

    should 'be able to search' do
      recipient = 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

3 entries across 3 versions & 1 rubygems

Version Path
pagarme-2.1.2 test/pagarme/resources/recipient_test.rb
pagarme-2.1.1 test/pagarme/resources/recipient_test.rb
pagarme-2.1.0 test/pagarme/resources/recipient_test.rb