spec/unit/braintree/transaction_spec.rb in braintree-3.3.0 vs spec/unit/braintree/transaction_spec.rb in braintree-3.4.0
- old
+ new
@@ -43,10 +43,18 @@
Braintree::Transaction.submit_for_settlement("invalid-transaction-id")
end.to raise_error(ArgumentError, "transaction_id is invalid")
end
end
+ describe "self.adjust_authorization" do
+ it "raises an ArgumentError if transaction_id is an invalid format" do
+ expect do
+ Braintree::Transaction.adjust_authorization("invalid-transaction-id", "10.00")
+ end.to raise_error(ArgumentError, "transaction_id is invalid")
+ end
+ end
+
describe "self.update_details" do
it "raises an ArgumentError if transaction_id is an invalid format" do
expect do
Braintree::Transaction.update_details("invalid-transaction-id")
end.to raise_error(ArgumentError, "transaction_id is invalid")
@@ -64,11 +72,11 @@
:company => "Ledner LLC",
:email => "adam.taylor@lednerllc.com",
:website => "lednerllc.com",
:phone => "1-999-652-4189 x56883",
:fax => "012-161-8055"
- }
+ },
)
transaction.customer_details.id.should == "123"
transaction.customer_details.first_name.should == "Adam"
transaction.customer_details.last_name.should == "Taylor"
transaction.customer_details.company.should == "Ledner LLC"
@@ -86,11 +94,11 @@
:settlement_amount => "120.00",
:settlement_currency_iso_code => "USD",
:settlement_currency_exchange_rate => "1",
:funds_held => false,
:success => true
- }
+ },
)
disbursement = transaction.disbursement_details
disbursement.disbursement_date.should == Date.parse("2013-04-03")
disbursement.settlement_amount.should == "120.00"
disbursement.settlement_currency_iso_code.should == "USD"
@@ -117,11 +125,11 @@
:commercial => "No",
:payroll => "Unknown",
:product_id => "Unknown",
:country_of_issuance => "Narnia",
:issuing_bank => "Mr Tumnus"
- }
+ },
)
transaction.credit_card_details.token.should == "mzg2"
transaction.credit_card_details.bin.should == "411111"
transaction.credit_card_details.last_4.should == "1111"
transaction.credit_card_details.card_type.should == "Visa"
@@ -145,11 +153,11 @@
:three_d_secure_info => {
:enrolled => "Y",
:liability_shifted => true,
:liability_shift_possible => true,
:status => "authenticate_successful",
- }
+ },
)
transaction.three_d_secure_info.enrolled.should == "Y"
transaction.three_d_secure_info.status.should == "authenticate_successful"
transaction.three_d_secure_info.liability_shifted.should == true
@@ -159,13 +167,13 @@
it "sets up history attributes in status_history" do
time = Time.utc(2010,1,14)
transaction = Braintree::Transaction._new(
:gateway,
:status_history => [
- { :timestamp => time, :amount => "12.00", :transaction_source => "API",
- :user => "larry", :status => Braintree::Transaction::Status::Authorized },
- { :timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API",
+ {:timestamp => time, :amount => "12.00", :transaction_source => "API",
+ :user => "larry", :status => Braintree::Transaction::Status::Authorized},
+ {:timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API",
:user => "curly", :status => "scheduled_for_settlement"}
])
transaction.status_history.size.should == 2
transaction.status_history[0].user.should == "larry"
transaction.status_history[0].amount.should == "12.00"
@@ -178,12 +186,12 @@
it "sets up authorization_adjustments" do
timestamp = Time.utc(2010,1,14)
transaction = Braintree::Transaction._new(
:gateway,
:authorization_adjustments => [
- { :timestamp => timestamp, :processor_response_code => "1000", :processor_response_text => "Approved", :amount => "12.00", :success => true },
- { :timestamp => timestamp, :processor_response_code => "3000", :processor_response_text => "Processor Network Unavailable - Try Again", :amount => "12.34", :success => false },
+ {:timestamp => timestamp, :processor_response_code => "1000", :processor_response_text => "Approved", :amount => "12.00", :success => true},
+ {:timestamp => timestamp, :processor_response_code => "3000", :processor_response_text => "Processor Network Unavailable - Try Again", :amount => "12.34", :success => false},
])
transaction.authorization_adjustments.size.should == 2
transaction.authorization_adjustments[0].amount.should == "12.00"
transaction.authorization_adjustments[0].success.should == true
transaction.authorization_adjustments[0].timestamp.should == timestamp
@@ -197,11 +205,11 @@
end
it "handles receiving custom as an empty string" do
transaction = Braintree::Transaction._new(
:gateway,
- :custom => "\n "
+ :custom => "\n ",
)
end
it "accepts amount as either a String or a BigDecimal" do
Braintree::Transaction._new(:gateway, :amount => "12.34").amount.should == BigDecimal("12.34")
@@ -215,19 +223,19 @@
end
it "handles nil risk_data" do
transaction = Braintree::Transaction._new(
:gateway,
- :risk_data => nil
+ :risk_data => nil,
)
transaction.risk_data.should be_nil
end
it "accepts network_transaction_id" do
transaction = Braintree::Transaction._new(
:gateway,
- :network_transaction_id => "123456789012345"
+ :network_transaction_id => "123456789012345",
)
transaction.network_transaction_id.should == "123456789012345"
end
it "accepts network_response code and network_response_text" do
@@ -305,12 +313,12 @@
transaction.refunded?.should == false
end
end
describe "sale" do
- let(:mock_response) { {:transaction => {}}}
- let(:http_stub) { double('http_stub').as_null_object }
+ let(:mock_response) { {:transaction => {}} }
+ let(:http_stub) { double("http_stub").as_null_object }
RSpec::Matchers.define :skip_advanced_fraud_check_value_is do |value|
match { |params| params[:transaction][:options][:skip_advanced_fraud_checking] == value }
end
@@ -324,11 +332,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:options => {
:skip_advanced_fraud_checking => true
- }
+ },
)
end
it "accepts skip_advanced_fraud_checking options with value false" do
Braintree::Http.stub(:new).and_return http_stub
@@ -340,11 +348,11 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:options => {
:skip_advanced_fraud_checking => false
- }
+ },
)
end
it "doesn't include skip_advanced_fraud_checking in params if its not specified" do
Braintree::Http.stub(:new).and_return http_stub
@@ -356,10 +364,10 @@
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2009"
},
:options => {
:submit_for_settlement => false
- }
+ },
)
end
end
describe "processed_with_network_token?" do