<commit_before>require 'test_helper'

module CardgateTestCases

  class TransactionsTestCases < Test::Unit::TestCase

    def stub_cardgate_connection
      cardgate_connection do |stubs|
        stubs.get('/rest/v1/transactions/2307824') { [200, {}, CardgateFixtures::TRANSACTION_WITHOUT_CUSTOMER] }
        stubs.get('/rest/v1/transactions/2307825') { [200, {}, CardgateFixtures::TRANSACTION_WITH_CUSTOMER] }
        stubs.get('/rest/v1/transactions/2307826') { [200, {}, nil] }
      end
    end

    def test_transaction_without_customer
      cardgate_connection = stub_cardgate_connection()

      Cardgate::Gateway.stubs(:connection).returns(cardgate_connection)

      transaction = Cardgate::Transactions.find(2307824)

      assert transaction.is_a? Cardgate::Transaction

      assert_equal 200, transaction.status
      assert_nil transaction.first_name
      assert_equal 'ideal', transaction.payment_method
      assert_equal '2014-04-22T15:19:01', transaction.timestamp
      assert_equal 5112, transaction.site_id
      assert_equal 'EUR', transaction.currency
      assert_equal 100, transaction.amount
      assert_equal 'test4', transaction.ref
      assert_equal 2307824, transaction.transaction_id
    end<commit_msg>Fix stubbing transactions<commit_after>require 'test_helper'

module CardgateTestCases

  class TransactionsTestCases < Test::Unit::TestCase

    def stub_cardgate_connection
      cardgate_connection do |stubs|
        stubs.get('/rest/v1/transactions/2307824/') { [200, {}, CardgateFixtures::TRANSACTION_WITHOUT_CUSTOMER] }
        stubs.get('/rest/v1/transactions/2307825/') { [200, {}, CardgateFixtures::TRANSACTION_WITH_CUSTOMER] }
        stubs.get('/rest/v1/transactions/2307826/') { [200, {}, nil] }
      end
    end

    def test_transaction_without_customer
      cardgate_connection = stub_cardgate_connection()

      Cardgate::Gateway.stubs(:connection).returns(cardgate_connection)

      transaction = Cardgate::Transactions.find(2307824)

      assert transaction.is_a? Cardgate::Transaction

      assert_equal 200, transaction.status
      assert_nil transaction.first_name
      assert_equal 'ideal', transaction.payment_method
      assert_equal '2014-04-22T15:19:01', transaction.timestamp
      assert_equal 5112, transaction.site_id
      assert_equal 'EUR', transaction.currency
      assert_equal 100, transaction.amount
      assert_equal 'test4', transaction.ref
      assert_equal 2307824, transaction.transaction_id
    end
{'fraction_non_alphanumeric': 0.09594540345242875, 'fraction_numerical': 0.05780810919309514, 'mean_word_length': 4.10655737704918, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5493337', 'n_tokens_mistral': 837, 'n_tokens_neox': 732, 'n_words': 121}