braintree 2.74.0 → 4.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/braintree.gemspec +13 -7
- data/lib/braintree/account_updater_daily_report.rb +2 -2
- data/lib/braintree/ach_mandate.rb +2 -1
- data/lib/braintree/address/country_names.rb +4 -1
- data/lib/braintree/address.rb +30 -38
- data/lib/braintree/address_gateway.rb +12 -2
- data/lib/braintree/advanced_search.rb +8 -0
- data/lib/braintree/apple_pay.rb +29 -0
- data/lib/braintree/apple_pay_card.rb +28 -4
- data/lib/braintree/apple_pay_gateway.rb +37 -0
- data/lib/braintree/apple_pay_options.rb +19 -0
- data/lib/braintree/authorization_adjustment.rb +23 -0
- data/lib/braintree/base_module.rb +10 -0
- data/lib/braintree/bin_data.rb +33 -0
- data/lib/braintree/client_token.rb +3 -3
- data/lib/braintree/client_token_gateway.rb +3 -1
- data/lib/braintree/configuration.rb +57 -10
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +6 -2
- data/lib/braintree/connected_merchant_status_transitioned.rb +6 -2
- data/lib/braintree/credentials_parser.rb +5 -1
- data/lib/braintree/credit_card.rb +53 -107
- data/lib/braintree/credit_card_gateway.rb +43 -30
- data/lib/braintree/credit_card_verification.rb +61 -21
- data/lib/braintree/credit_card_verification_gateway.rb +19 -6
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +51 -98
- data/lib/braintree/customer_gateway.rb +30 -23
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +3 -1
- data/lib/braintree/disbursement.rb +24 -2
- data/lib/braintree/dispute/evidence.rb +24 -0
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -3
- data/lib/braintree/dispute/status_history.rb +18 -0
- data/lib/braintree/dispute/transaction.rb +20 -0
- data/lib/braintree/dispute/transaction_details.rb +2 -1
- data/lib/braintree/dispute.rb +114 -10
- data/lib/braintree/dispute_gateway.rb +142 -0
- data/lib/braintree/dispute_search.rb +31 -0
- data/lib/braintree/document_upload.rb +37 -0
- data/lib/braintree/document_upload_gateway.rb +38 -0
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +328 -109
- data/lib/braintree/error_result.rb +8 -1
- data/lib/braintree/exceptions.rb +5 -3
- data/lib/braintree/exchange_rate.rb +13 -0
- data/lib/braintree/exchange_rate_quote.rb +24 -0
- data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
- data/lib/braintree/exchange_rate_quote_input.rb +21 -0
- data/lib/braintree/exchange_rate_quote_request.rb +18 -0
- data/lib/braintree/exchange_rate_quote_response.rb +18 -0
- data/lib/braintree/facilitated_details.rb +21 -0
- data/lib/braintree/facilitator_details.rb +2 -1
- data/lib/braintree/gateway.rb +29 -11
- data/lib/braintree/google_pay_card.rb +61 -0
- data/lib/braintree/granted_payment_instrument_update.rb +23 -0
- data/lib/braintree/graphql_client.rb +34 -0
- data/lib/braintree/http.rb +81 -20
- data/lib/braintree/local_payment_completed.rb +23 -0
- data/lib/braintree/local_payment_expired.rb +21 -0
- data/lib/braintree/local_payment_funded.rb +22 -0
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +11 -4
- data/lib/braintree/merchant_account/address_details.rb +4 -1
- data/lib/braintree/merchant_account/business_details.rb +4 -1
- data/lib/braintree/merchant_account/funding_details.rb +6 -1
- data/lib/braintree/merchant_account/individual_details.rb +7 -2
- data/lib/braintree/merchant_account.rb +23 -10
- data/lib/braintree/merchant_account_gateway.rb +13 -1
- data/lib/braintree/merchant_gateway.rb +2 -2
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +5 -2
- data/lib/braintree/oauth_gateway.rb +8 -14
- data/lib/braintree/paginated_result.rb +3 -1
- data/lib/braintree/payment_instrument_type.rb +11 -11
- data/lib/braintree/payment_method.rb +20 -12
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +82 -54
- data/lib/braintree/payment_method_nonce.rb +22 -8
- data/lib/braintree/payment_method_nonce_details.rb +40 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +19 -2
- data/lib/braintree/payment_method_parser.rb +28 -0
- data/lib/braintree/paypal_account.rb +10 -1
- data/lib/braintree/plan.rb +25 -5
- data/lib/braintree/plan_gateway.rb +100 -0
- data/lib/braintree/processor_response_types.rb +7 -0
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +12 -2
- data/lib/braintree/samsung_pay_card.rb +83 -0
- data/lib/braintree/sepa_direct_debit_account.rb +60 -0
- data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
- data/lib/braintree/settlement_batch_summary.rb +2 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
- data/lib/braintree/subscription/status_details.rb +8 -1
- data/lib/braintree/subscription.rb +56 -41
- data/lib/braintree/subscription_gateway.rb +25 -2
- data/lib/braintree/successful_result.rb +23 -1
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +13 -0
- data/lib/braintree/test/nonce.rb +28 -20
- data/lib/braintree/test/transaction_amounts.rb +1 -0
- data/lib/braintree/three_d_secure_info.rb +34 -2
- data/lib/braintree/transaction/address_details.rb +24 -4
- data/lib/braintree/transaction/apple_pay_details.rb +20 -2
- data/lib/braintree/transaction/credit_card_details.rb +45 -6
- data/lib/braintree/transaction/customer_details.rb +8 -1
- data/lib/braintree/transaction/disbursement_details.rb +6 -1
- data/lib/braintree/transaction/google_pay_details.rb +41 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/local_payment_details.rb +24 -0
- data/lib/braintree/transaction/paypal_details.rb +26 -4
- data/lib/braintree/transaction/paypal_here_details.rb +23 -0
- data/lib/braintree/transaction/{masterpass_card_details.rb → samsung_pay_card_details.rb} +21 -6
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +5 -1
- data/lib/braintree/transaction/subscription_details.rb +4 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +8 -1
- data/lib/braintree/transaction/venmo_account_details.rb +5 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +19 -4
- data/lib/braintree/transaction.rb +201 -188
- data/lib/braintree/transaction_gateway.rb +124 -30
- data/lib/braintree/transaction_line_item.rb +40 -0
- data/lib/braintree/transaction_line_item_gateway.rb +19 -0
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +6 -3
- data/lib/braintree/unknown_payment_method.rb +3 -2
- data/lib/braintree/us_bank_account.rb +24 -8
- data/lib/braintree/us_bank_account_gateway.rb +0 -1
- data/lib/braintree/us_bank_account_verification.rb +81 -0
- data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
- data/lib/braintree/us_bank_account_verification_search.rb +19 -0
- data/lib/braintree/util.rb +79 -9
- data/lib/braintree/validation_error.rb +13 -3
- data/lib/braintree/validation_error_collection.rb +2 -1
- data/lib/braintree/venmo_account.rb +11 -4
- data/lib/braintree/venmo_profile_data.rb +23 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +29 -13
- data/lib/braintree/webhook_notification.rb +66 -26
- data/lib/braintree/webhook_notification_gateway.rb +5 -3
- data/lib/braintree/webhook_testing.rb +2 -2
- data/lib/braintree/webhook_testing_gateway.rb +721 -55
- data/lib/braintree/xml/generator.rb +6 -4
- data/lib/braintree/xml/parser.rb +22 -35
- data/lib/braintree/xml/rexml.rb +4 -5
- data/lib/braintree.rb +60 -22
- data/lib/ssl/api_braintreegateway_com.ca.crt +50 -0
- data/spec/fixtures/files/bt_logo.png +0 -0
- data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
- data/spec/fixtures/files/malformed_pdf.pdf +1 -0
- data/spec/fixtures/files/too_long.pdf +0 -0
- data/spec/integration/braintree/add_on_spec.rb +3 -3
- data/spec/integration/braintree/address_spec.rb +30 -113
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +63 -0
- data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -32
- data/spec/integration/braintree/client_api/spec_helper.rb +104 -65
- data/spec/integration/braintree/credit_card_spec.rb +460 -615
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +222 -6
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +810 -498
- data/spec/integration/braintree/discount_spec.rb +1 -1
- data/spec/integration/braintree/dispute_search_spec.rb +167 -0
- data/spec/integration/braintree/dispute_spec.rb +333 -0
- data/spec/integration/braintree/document_upload_spec.rb +87 -0
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +72 -0
- data/spec/integration/braintree/http_spec.rb +12 -4
- data/spec/integration/braintree/merchant_account_spec.rb +74 -26
- data/spec/integration/braintree/merchant_spec.rb +39 -13
- data/spec/integration/braintree/oauth_spec.rb +18 -25
- data/spec/integration/braintree/payment_method_nonce_spec.rb +239 -5
- data/spec/integration/braintree/payment_method_spec.rb +882 -300
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +416 -0
- data/spec/integration/braintree/paypal_account_spec.rb +32 -31
- data/spec/integration/braintree/plan_spec.rb +82 -0
- data/spec/integration/braintree/samsung_pay_card_spec.rb +144 -0
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +196 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +274 -180
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +18 -18
- data/spec/integration/braintree/transaction_line_item_spec.rb +38 -0
- data/spec/integration/braintree/transaction_search_spec.rb +280 -152
- data/spec/integration/braintree/transaction_spec.rb +3709 -1175
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +438 -0
- data/spec/integration/braintree/us_bank_account_spec.rb +38 -17
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +27 -6
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +26 -23
- data/spec/unit/braintree/address_spec.rb +1 -9
- data/spec/unit/braintree/apple_pay_card_spec.rb +104 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +108 -33
- data/spec/unit/braintree/credit_card_spec.rb +62 -33
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +51 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +39 -6
- data/spec/unit/braintree/customer_spec.rb +107 -27
- data/spec/unit/braintree/disbursement_spec.rb +59 -7
- data/spec/unit/braintree/dispute_search_spec.rb +66 -0
- data/spec/unit/braintree/dispute_spec.rb +472 -8
- data/spec/unit/braintree/document_upload_spec.rb +35 -0
- data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
- data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
- data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
- data/spec/unit/braintree/http_spec.rb +93 -5
- data/spec/unit/braintree/local_payment_completed_spec.rb +50 -0
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +30 -1
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +40 -6
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
- data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/subscription_spec.rb +2 -2
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +34 -6
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +19 -3
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +111 -0
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +171 -55
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +93 -0
- data/spec/unit/braintree/util_spec.rb +162 -19
- data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
- data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +546 -114
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- data/spec/unit/braintree/xml_spec.rb +31 -24
- data/spec/unit/braintree_spec.rb +1 -0
- metadata +290 -198
- data/README.rdoc +0 -93
- data/lib/braintree/amex_express_checkout_card.rb +0 -26
- data/lib/braintree/android_pay_card.rb +0 -35
- data/lib/braintree/coinbase_account.rb +0 -25
- data/lib/braintree/europe_bank_account.rb +0 -34
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -46
- data/lib/braintree/ideal_payment_gateway.rb +0 -18
- data/lib/braintree/masterpass_card.rb +0 -66
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -14
- data/lib/braintree/transaction/android_pay_details.rb +0 -17
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -13
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/httpsd.pid +0 -1
- data/spec/integration/braintree/coinbase_spec.rb +0 -31
- data/spec/integration/braintree/ideal_payment_spec.rb +0 -87
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -2,174 +2,377 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
2
|
|
3
3
|
describe Braintree::ValidationErrorCollection do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
context "blue response" do
|
6
|
+
describe "initialize" do
|
7
|
+
it "builds an error object given an array of hashes" do
|
8
|
+
hash = {:errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}]}
|
9
|
+
collection = Braintree::ValidationErrorCollection.new(hash)
|
10
|
+
error = collection[0]
|
11
|
+
error.attribute.should == "some model attribute"
|
12
|
+
error.code.should == 1
|
13
|
+
error.message.should == "bad juju"
|
14
|
+
end
|
13
15
|
end
|
14
|
-
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
describe "for" do
|
18
|
+
it "provides access to nested errors" do
|
19
|
+
hash = {
|
20
|
+
:errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}],
|
21
|
+
:nested => {
|
22
|
+
:errors => [{:attribute => "number", :code => 2, :message => "badder juju"}]
|
23
|
+
}
|
22
24
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
errors = Braintree::ValidationErrorCollection.new(hash)
|
26
|
+
errors.for(:nested).on(:number)[0].code.should == 2
|
27
|
+
errors.for(:nested).on(:number)[0].message.should == "badder juju"
|
28
|
+
errors.for(:nested).on(:number)[0].attribute.should == "number"
|
29
|
+
end
|
28
30
|
end
|
29
|
-
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
describe "inspect" do
|
33
|
+
it "shows the errors at the current level" do
|
34
|
+
errors = Braintree::ValidationErrorCollection.new(:errors => [
|
35
|
+
{:attribute => "name", :code => "code1", :message => "message1"},
|
36
|
+
{:attribute => "name", :code => "code2", :message => "message2"}
|
37
|
+
])
|
38
|
+
errors.inspect.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1, (code2) message2]>"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "shows errors 1 level deep" do
|
42
|
+
errors = Braintree::ValidationErrorCollection.new(
|
43
|
+
:errors => [
|
44
|
+
{:attribute => "name", :code => "code1", :message => "message1"},
|
45
|
+
],
|
46
|
+
:level1 => {
|
47
|
+
:errors => [{:attribute => "name", :code => "code2", :message => "message2"}]
|
48
|
+
},
|
49
|
+
)
|
50
|
+
errors.inspect.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2]>"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "shows errors 2 levels deep" do
|
54
|
+
errors = Braintree::ValidationErrorCollection.new(
|
55
|
+
:errors => [
|
56
|
+
{:attribute => "name", :code => "code1", :message => "message1"},
|
57
|
+
],
|
58
|
+
:level1 => {
|
59
|
+
:errors => [{:attribute => "name", :code => "code2", :message => "message2"}],
|
60
|
+
:level2 => {
|
61
|
+
:errors => [{:attribute => "name", :code => "code3", :message => "message3"}],
|
62
|
+
}
|
63
|
+
},
|
64
|
+
)
|
65
|
+
errors.inspect.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2], level1/level2:[(code3) message3]>"
|
66
|
+
end
|
38
67
|
end
|
39
68
|
|
40
|
-
|
41
|
-
errors
|
42
|
-
:errors => [
|
43
|
-
{:attribute => "name", :code =>
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
69
|
+
describe "on" do
|
70
|
+
it "returns an array of errors on the given attribute" do
|
71
|
+
errors = Braintree::ValidationErrorCollection.new(:errors => [
|
72
|
+
{:attribute => "name", :code => 1, :message => "is too long"},
|
73
|
+
{:attribute => "name", :code => 2, :message => "contains invalid chars"},
|
74
|
+
{:attribute => "not name", :code => 3, :message => "is invalid"}
|
75
|
+
])
|
76
|
+
errors.on("name").size.should == 2
|
77
|
+
errors.on("name").map { |e| e.code }.should == [1, 2]
|
78
|
+
end
|
79
|
+
|
80
|
+
it "has indifferent access" do
|
81
|
+
errors = Braintree::ValidationErrorCollection.new(:errors => [
|
82
|
+
{:attribute => "name", :code => 3, :message => "is too long"},
|
83
|
+
])
|
84
|
+
errors.on(:name).size.should == 1
|
85
|
+
errors.on(:name)[0].code.should == 3
|
86
|
+
|
87
|
+
end
|
50
88
|
end
|
51
89
|
|
52
|
-
|
53
|
-
|
54
|
-
:errors => [
|
55
|
-
{:attribute => "
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
90
|
+
describe "deep_size" do
|
91
|
+
it "returns the size for a non-nested collection" do
|
92
|
+
errors = Braintree::ValidationErrorCollection.new(:errors => [
|
93
|
+
{:attribute => "one", :code => 1, :message => "is too long"},
|
94
|
+
{:attribute => "two", :code => 2, :message => "contains invalid chars"},
|
95
|
+
{:attribute => "thr", :code => 3, :message => "is invalid"}
|
96
|
+
])
|
97
|
+
errors.deep_size.should == 3
|
98
|
+
end
|
99
|
+
|
100
|
+
it "returns the size of nested errors as well" do
|
101
|
+
errors = Braintree::ValidationErrorCollection.new(
|
102
|
+
:errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}],
|
103
|
+
:nested => {
|
104
|
+
:errors => [{:attribute => "number", :code => 2, :message => "badder juju"}]
|
105
|
+
},
|
106
|
+
)
|
107
|
+
errors.deep_size.should == 2
|
108
|
+
end
|
109
|
+
|
110
|
+
it "returns the size of multiple nestings of errors" do
|
111
|
+
errors = Braintree::ValidationErrorCollection.new(
|
112
|
+
:errors => [
|
113
|
+
{:attribute => "one", :code => 1, :message => "bad juju"},
|
114
|
+
{:attribute => "two", :code => 1, :message => "bad juju"}],
|
115
|
+
:nested => {
|
116
|
+
:errors => [{:attribute => "three", :code => 2, :message => "badder juju"}],
|
117
|
+
:nested_again => {
|
118
|
+
:errors => [{:attribute => "four", :code => 2, :message => "badder juju"}]
|
119
|
+
}
|
120
|
+
},
|
121
|
+
:same_level => {
|
122
|
+
:errors => [{:attribute => "five", :code => 2, :message => "badder juju"}],
|
123
|
+
},
|
124
|
+
)
|
125
|
+
errors.deep_size.should == 5
|
126
|
+
end
|
65
127
|
end
|
66
|
-
end
|
67
128
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
129
|
+
describe "deep_errors" do
|
130
|
+
it "returns errors from all levels" do
|
131
|
+
errors = Braintree::ValidationErrorCollection.new(
|
132
|
+
:errors => [
|
133
|
+
{:attribute => "one", :code => 1, :message => "bad juju"},
|
134
|
+
{:attribute => "two", :code => 2, :message => "bad juju"}],
|
135
|
+
:nested => {
|
136
|
+
:errors => [{:attribute => "three", :code => 3, :message => "badder juju"}],
|
137
|
+
:nested_again => {
|
138
|
+
:errors => [{:attribute => "four", :code => 4, :message => "badder juju"}]
|
139
|
+
}
|
140
|
+
},
|
141
|
+
:same_level => {
|
142
|
+
:errors => [{:attribute => "five", :code => 5, :message => "badder juju"}],
|
143
|
+
},
|
144
|
+
)
|
145
|
+
errors.deep_errors.map { |e| e.code }.sort.should == [1, 2, 3, 4, 5]
|
146
|
+
end
|
77
147
|
end
|
78
148
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
149
|
+
describe "shallow_errors" do
|
150
|
+
it "returns errors on one level" do
|
151
|
+
errors = Braintree::ValidationErrorCollection.new(
|
152
|
+
:errors => [
|
153
|
+
{:attribute => "one", :code => 1, :message => "bad juju"},
|
154
|
+
{:attribute => "two", :code => 2, :message => "bad juju"}],
|
155
|
+
:nested => {
|
156
|
+
:errors => [{:attribute => "three", :code => 3, :message => "badder juju"}],
|
157
|
+
:nested_again => {
|
158
|
+
:errors => [{:attribute => "four", :code => 4, :message => "badder juju"}]
|
159
|
+
}
|
160
|
+
},
|
161
|
+
)
|
162
|
+
errors.shallow_errors.map { |e| e.code }.should == [1, 2]
|
163
|
+
errors.for(:nested).shallow_errors.map { |e| e.code }.should == [3]
|
164
|
+
end
|
85
165
|
|
166
|
+
it "returns an clone of the real array" do
|
167
|
+
errors = Braintree::ValidationErrorCollection.new(
|
168
|
+
:errors => [
|
169
|
+
{:attribute => "one", :code => 1, :message => "bad juju"},
|
170
|
+
{:attribute => "two", :code => 2, :message => "bad juju"}],
|
171
|
+
)
|
172
|
+
errors.shallow_errors.pop
|
173
|
+
errors.shallow_errors.map { |e| e.code }.should == [1, 2]
|
174
|
+
end
|
86
175
|
end
|
87
176
|
end
|
88
177
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
178
|
+
context "graphql response" do
|
179
|
+
describe "initialize" do
|
180
|
+
it "builds an error object given an array of hashes" do
|
181
|
+
hash = {:errors => [{
|
182
|
+
:message => "bad juju",
|
183
|
+
:untracked_param => "don't look",
|
184
|
+
:path=>["one", "two"],
|
185
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"1"}
|
186
|
+
}]}
|
187
|
+
collection = Braintree::ValidationErrorCollection.new(hash)
|
188
|
+
error = collection[0]
|
189
|
+
error.attribute.should == "two"
|
190
|
+
error.code.should == 1
|
191
|
+
error.message.should == "bad juju"
|
192
|
+
!error.respond_to? :untracked_param
|
193
|
+
end
|
97
194
|
end
|
98
195
|
|
99
|
-
|
100
|
-
errors
|
101
|
-
|
102
|
-
|
103
|
-
|
196
|
+
describe "for" do
|
197
|
+
it "provides access to nested errors" do
|
198
|
+
hash = {
|
199
|
+
:errors => [{
|
200
|
+
:message => "bad juju",
|
201
|
+
:path=>["one", "two"],
|
202
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"1"}
|
203
|
+
}],
|
204
|
+
:nested => {
|
205
|
+
:errors => [{
|
206
|
+
:message => "badder juju",
|
207
|
+
:path=>["nested_attribute"],
|
208
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"2"}
|
209
|
+
}]
|
210
|
+
}
|
104
211
|
}
|
105
|
-
|
106
|
-
|
212
|
+
errors = Braintree::ValidationErrorCollection.new(hash)
|
213
|
+
errors.for(:nested).on(:nested_attribute)[0].code.should == 2
|
214
|
+
errors.for(:nested).on(:nested_attribute)[0].message.should == "badder juju"
|
215
|
+
errors.for(:nested).on(:nested_attribute)[0].attribute.should == "nested_attribute"
|
216
|
+
end
|
107
217
|
end
|
108
218
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
:
|
219
|
+
describe "deep_size" do
|
220
|
+
it "returns the size for a non-nested collection" do
|
221
|
+
hash = {
|
222
|
+
:errors => [{
|
223
|
+
:message => "bad juju",
|
224
|
+
:path=>["one", "two"],
|
225
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"1"}
|
226
|
+
},{
|
227
|
+
:message => "bad juju 2",
|
228
|
+
:path=>["three", "four"],
|
229
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"2"}
|
230
|
+
},{
|
231
|
+
:message => "bad juju 3",
|
232
|
+
:path=>["five", "six"],
|
233
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"2"}
|
234
|
+
}],
|
235
|
+
}
|
236
|
+
errors = Braintree::ValidationErrorCollection.new(hash)
|
237
|
+
errors.deep_size.should == 3
|
238
|
+
end
|
239
|
+
|
240
|
+
it "returns the size of nested errors as well" do
|
241
|
+
hash = {
|
242
|
+
:errors => [{
|
243
|
+
:message => "bad juju",
|
244
|
+
:path=>["one", "two"],
|
245
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"1"}
|
246
|
+
}],
|
247
|
+
:nested => {
|
248
|
+
:errors => [{
|
249
|
+
:message => "badder juju",
|
250
|
+
:path=>["nested_attribute"],
|
251
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"2"}
|
252
|
+
}]
|
118
253
|
}
|
119
|
-
},
|
120
|
-
:same_level => {
|
121
|
-
:errors => [{ :attribute => "five", :code => 2, :message => "badder juju"}],
|
122
254
|
}
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
end
|
255
|
+
errors = Braintree::ValidationErrorCollection.new(hash)
|
256
|
+
errors.deep_size.should == 2
|
257
|
+
end
|
127
258
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
:
|
259
|
+
it "returns the size of multiple nestings of errors" do
|
260
|
+
hash = {
|
261
|
+
:errors => [{
|
262
|
+
:message => "bad juju",
|
263
|
+
:path=>["attribute1"],
|
264
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"1"}
|
265
|
+
}],
|
266
|
+
:nested => {
|
267
|
+
:errors => [{
|
268
|
+
:message => "bad juju",
|
269
|
+
:path=>["attribute2"],
|
270
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"2"}
|
271
|
+
},{
|
272
|
+
:message => "bad juju",
|
273
|
+
:path=>["attribute3"],
|
274
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"3"}
|
275
|
+
}],
|
276
|
+
:deeply_nested => {
|
277
|
+
:errors => [{
|
278
|
+
:message => "bad juju",
|
279
|
+
:path=>["attribute4"],
|
280
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"4"}
|
281
|
+
}]
|
282
|
+
}
|
283
|
+
},
|
136
284
|
:nested_again => {
|
137
|
-
:errors => [{
|
285
|
+
:errors => [{
|
286
|
+
:message => "bad juju",
|
287
|
+
:path=>["attribute5"],
|
288
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"5"}
|
289
|
+
}]
|
138
290
|
}
|
139
|
-
},
|
140
|
-
:same_level => {
|
141
|
-
:errors => [{ :attribute => "five", :code => 5, :message => "badder juju"}],
|
142
291
|
}
|
143
|
-
|
144
|
-
|
292
|
+
errors = Braintree::ValidationErrorCollection.new(hash)
|
293
|
+
errors.deep_size.should == 5
|
294
|
+
end
|
145
295
|
end
|
146
|
-
end
|
147
296
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
297
|
+
describe "deep_errors" do
|
298
|
+
it "returns errors from all levels" do
|
299
|
+
hash = {
|
300
|
+
:errors => [{
|
301
|
+
:message => "bad juju",
|
302
|
+
:path=>["attribute1"],
|
303
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"1"}
|
304
|
+
}],
|
305
|
+
:nested => {
|
306
|
+
:errors => [{
|
307
|
+
:message => "bad juju",
|
308
|
+
:path=>["attribute2"],
|
309
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"2"}
|
310
|
+
},{
|
311
|
+
:message => "bad juju",
|
312
|
+
:path=>["attribute3"],
|
313
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"3"}
|
314
|
+
}],
|
315
|
+
:deeply_nested => {
|
316
|
+
:errors => [{
|
317
|
+
:message => "bad juju",
|
318
|
+
:path=>["attribute4"],
|
319
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"4"}
|
320
|
+
}]
|
321
|
+
}
|
322
|
+
},
|
156
323
|
:nested_again => {
|
157
|
-
:errors => [{
|
324
|
+
:errors => [{
|
325
|
+
:message => "bad juju",
|
326
|
+
:path=>["attribute5"],
|
327
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"5"}
|
328
|
+
}]
|
158
329
|
}
|
159
330
|
}
|
160
|
-
|
161
|
-
|
162
|
-
|
331
|
+
errors = Braintree::ValidationErrorCollection.new(hash)
|
332
|
+
errors.deep_errors.map { |e| e.code }.sort.should == [1, 2, 3, 4, 5]
|
333
|
+
end
|
163
334
|
end
|
164
335
|
|
165
|
-
|
166
|
-
errors
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
336
|
+
describe "shallow_errors" do
|
337
|
+
it "returns errors on one level" do
|
338
|
+
hash = {
|
339
|
+
:errors => [{
|
340
|
+
:message => "bad juju",
|
341
|
+
:path=>["attribute1"],
|
342
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"1"}
|
343
|
+
}],
|
344
|
+
:nested => {
|
345
|
+
:errors => [{
|
346
|
+
:message => "bad juju",
|
347
|
+
:path=>["attribute2"],
|
348
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"2"}
|
349
|
+
},{
|
350
|
+
:message => "bad juju",
|
351
|
+
:path=>["attribute3"],
|
352
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"3"}
|
353
|
+
}],
|
354
|
+
:deeply_nested => {
|
355
|
+
:errors => [{
|
356
|
+
:message => "bad juju",
|
357
|
+
:path=>["attribute4"],
|
358
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"4"}
|
359
|
+
}]
|
360
|
+
}
|
361
|
+
},
|
362
|
+
:nested_again => {
|
363
|
+
:errors => [{
|
364
|
+
:message => "bad juju",
|
365
|
+
:path=>["attribute5"],
|
366
|
+
:extensions=> {:errorClass=>"VALIDATION", :legacyCode=>"5"}
|
367
|
+
}]
|
368
|
+
}
|
369
|
+
}
|
370
|
+
errors = Braintree::ValidationErrorCollection.new(hash)
|
371
|
+
errors.shallow_errors.map { |e| e.code }.should == [1]
|
372
|
+
errors.for(:nested).shallow_errors.map { |e| e.code }.should == [2,3]
|
373
|
+
errors.for(:nested).for(:deeply_nested).shallow_errors.map { |e| e.code }.should == [4]
|
374
|
+
errors.for(:nested_again).shallow_errors.map { |e| e.code }.should == [5]
|
375
|
+
end
|
173
376
|
end
|
174
377
|
end
|
175
378
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::VenmoProfileData do
|
4
|
+
describe "self.new" do
|
5
|
+
it "is protected" do
|
6
|
+
expect do
|
7
|
+
Braintree::VenmoProfileData.new
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "self._new" do
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
14
|
+
|
15
|
+
params = {
|
16
|
+
username: "a-username",
|
17
|
+
first_name: "a-first-name",
|
18
|
+
last_name: "a-last-name",
|
19
|
+
phone_number: "12312312343",
|
20
|
+
email: "a-email",
|
21
|
+
}
|
22
|
+
|
23
|
+
payment_method_customer_data_updated = Braintree::VenmoProfileData._new(params)
|
24
|
+
|
25
|
+
payment_method_customer_data_updated.username.should eq("a-username")
|
26
|
+
payment_method_customer_data_updated.first_name.should eq("a-first-name")
|
27
|
+
payment_method_customer_data_updated.last_name.should eq("a-last-name")
|
28
|
+
payment_method_customer_data_updated.phone_number.should eq("12312312343")
|
29
|
+
payment_method_customer_data_updated.email.should eq("a-email")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|