Sha256: 11e9600e588004821899646f051df6fbe4d34391bc9ca2fad9636252b8a62fcc

Contents?: true

Size: 1.35 KB

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
pagarme-2.4.0 test/pagarme/resources/recipient_test.rb
pagarme-2.3.0 test/pagarme/resources/recipient_test.rb
pagarme-2.2.3 test/pagarme/resources/recipient_test.rb
pagarme-2.2.2 test/pagarme/resources/recipient_test.rb
pagarme-2.2.1 test/pagarme/resources/recipient_test.rb
pagarme-2.2.0 test/pagarme/resources/recipient_test.rb
pagarme-2.1.4 test/pagarme/resources/recipient_test.rb