spec/integration/braintree/package_tracking_spec.rb in braintree-4.20.0 vs spec/integration/braintree/package_tracking_spec.rb in braintree-4.21.0

- old
+ new

@@ -1,20 +1,19 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") +require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper") +# NEXT_MAJOR_VERSION Remove paypal_tracking_id assertions, use paypal_tracker_id going forward describe Braintree::Transaction do describe "self.package_tracking" do + let(:customer) { Braintree::Customer.create! } it "returns validation error message from gateway api" do - # Create Transaction result = Braintree::Transaction.sale( :amount => "100", + :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment, :options => { :submit_for_settlement => true }, - :paypal_account => { - :payer_id => "fake-payer-id", - :payment_id => "fake-payment-id", - }, ) expect(result.success?).to eq(true) # Carrier name is required @@ -25,21 +24,16 @@ invalidResult = Braintree::Transaction.package_tracking(result.transaction.id, {carrier: "UPS"}) expect(invalidResult.message).to eq("Tracking number is required.") end it "successfully calls gateway API and adds package tracking information" do - - # Create Transaction result = Braintree::Transaction.sale( :amount => "100", + :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment, :options => { :submit_for_settlement => true }, - :paypal_account => { - :payer_id => "fake-payer-id", - :payment_id => "fake-payment-id", - }, ) expect(result.success?).to eq(true) # Create First Package with 2 products @@ -75,12 +69,13 @@ # First package is shipped by the merchant expect(firstPackageResult.success?).to eq(true) expect(firstPackageResult.transaction.packages[0].id).not_to be_nil expect(firstPackageResult.transaction.packages[0].carrier).to eq("UPS") expect(firstPackageResult.transaction.packages[0].tracking_number).to eq("tracking_number_1") + expect(firstPackageResult.transaction.packages[0].paypal_tracker_id).to be_nil + expect(firstPackageResult.transaction.packages[0].paypal_tracking_id).to be_nil - # Create second package with 1 product secondPackageResult = Braintree::Transaction.package_tracking( result.transaction.id, { carrier: "FEDEX", @@ -100,12 +95,36 @@ # Second package is shipped by the merchant expect(secondPackageResult.success?).to eq(true) expect(secondPackageResult.transaction.packages[1].id).not_to be_nil expect(secondPackageResult.transaction.packages[1].carrier).to eq("FEDEX") expect(secondPackageResult.transaction.packages[1].tracking_number).to eq("tracking_number_2") + expect(secondPackageResult.transaction.packages[1].paypal_tracker_id).to be_nil + expect(secondPackageResult.transaction.packages[1].paypal_tracking_id).to be_nil # Find transaction gives both packages - findTransaction = Braintree::Transaction.find(result.transaction.id) - expect(findTransaction.packages.length).to eq(2) + transaction = Braintree::Transaction.find(result.transaction.id) + expect(transaction.packages.length).to eq(2) + expect(transaction.packages[0].id).not_to be_nil + expect(transaction.packages[0].carrier).to eq("UPS") + expect(transaction.packages[0].tracking_number).to eq("tracking_number_1") + #In test environment, since we do not have jobstream setup paypal tracker id is going to be nil, this is just to access we could access it + expect(transaction.packages[0].paypal_tracker_id).to be_nil + expect(transaction.packages[0].paypal_tracking_id).to be_nil + + expect(transaction.packages[1].id).not_to be_nil + expect(transaction.packages[1].carrier).to eq("FEDEX") + expect(transaction.packages[1].tracking_number).to eq("tracking_number_2") + expect(transaction.packages[1].paypal_tracker_id).to be_nil + expect(transaction.packages[1].paypal_tracking_id).to be_nil end + + it "retrieves paypal_tracker_id successfully" do + transaction = Braintree::Transaction.find("package_tracking_tx") + expect(transaction.packages.length).to eq(2) + expect(transaction.packages[0].paypal_tracker_id).to eq("paypal_tracker_id_1") + expect(transaction.packages[0].paypal_tracking_id).to be_nil + + expect(transaction.packages[1].paypal_tracker_id).to eq("paypal_tracker_id_2") + expect(transaction.packages[1].paypal_tracking_id).to be_nil + end end -end \ No newline at end of file +end