Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

1.1.3

  • Loading branch information...
commit 31f90199d6ce79d0b2826c1f675ef57a27d9ae47 1 parent 1897413
@braintreeps braintreeps authored
View
20 CHANGELOG.rdoc
@@ -1,12 +1,18 @@
+== 1.1.3
+
+* Fixed a bug with empty search results
+* Added support for appending to user agent
+* Finding a customer using id as an integer will now work (even though customer ids are actually strings)
+
== 1.1.2
-* allow passing expiration_month and expiration_year separately
-* updated Customer.find to raise an ArgumentError if given an invalid id
-* added error code for transaction amounts that are too large
-* include Enumerable in Braintree::Errors to iterate over all validation errors
-* added processor_authorization_code attr_reader to Braintree::Transaction
-* added cvv_response_code attr_reader to Braintree::Transaction
-* added deep_errors method to Braintree::ValidationErrorCollection to get errors at every level of nesting
+* Allow passing expiration_month and expiration_year separately
+* Updated Customer.find to raise an ArgumentError if given an invalid id
+* Added error code for transaction amounts that are too large
+* Include Enumerable in Braintree::Errors to iterate over all validation errors
+* Added processor_authorization_code attr_reader to Braintree::Transaction
+* Added cvv_response_code attr_reader to Braintree::Transaction
+* Added deep_errors method to Braintree::ValidationErrorCollection to get errors at every level of nesting
== 1.1.1
View
9 lib/braintree/configuration.rb
@@ -90,6 +90,15 @@ def self.ssl? # :nodoc:
end
end
+ def self.custom_user_agent=(custom_user_agent)
+ @custom_user_agent = custom_user_agent
+ end
+
+ def self.user_agent
+ base_user_agent = "Braintree Ruby Gem #{Braintree::Version::String}"
+ @custom_user_agent ? "#{base_user_agent} (#{@custom_user_agent})" : base_user_agent
+ end
+
def self._default_logger # :nodoc:
logger = Logger.new(STDOUT)
logger.level = Logger::INFO
View
10 lib/braintree/credit_card.rb
@@ -191,11 +191,7 @@ def self._attributes # :nodoc:
end
def self._create_signature # :nodoc:
- [
- :customer_id, :cardholder_name, :cvv, :number, :expiration_date, :expiration_month, :expiration_year, :token,
- {:options => [:verify_card]},
- {:billing_address => [:first_name, :last_name, :company, :country_name, :extended_address, :locality, :region, :postal_code, :street_address]}
- ]
+ _update_signature + [:customer_id]
end
def self._new(*args) # :nodoc:
@@ -226,9 +222,9 @@ def self._do_update(http_verb, url, params) # :nodoc:
def self._update_signature # :nodoc:
[
- :cardholder_name, :cvv, :number, :expiration_date, :expiration_month, :expiration_year, :token,
+ :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, :token,
{:options => [:verify_card]},
- {:billing_address => [:first_name, :last_name, :company, :country_name, :extended_address, :locality, :region, :postal_code, :street_address]}
+ {:billing_address => [:company, :country_name, :extended_address, :first_name, :last_name, :locality, :postal_code, :region, :street_address]}
]
end
View
2  lib/braintree/customer.rb
@@ -79,7 +79,7 @@ def self.delete(customer_id)
end
def self.find(customer_id)
- raise ArgumentError, "customer_id should be a string" unless customer_id.is_a?(String)
+ raise ArgumentError, "customer_id contains invalid characters" unless customer_id.to_s =~ /\A[\w-]+\z/
raise ArgumentError, "customer_id cannot be blank" if customer_id.to_s == ""
response = Http.get("/customers/#{customer_id}")
new(response[:customer])
View
2  lib/braintree/http.rb
@@ -53,7 +53,7 @@ def self._http_do(http_verb, path, body = nil)
connection.start do |http|
request = http_verb.new("#{Configuration.base_merchant_path}#{path}")
request["Accept"] = "application/xml"
- request["User-Agent"] = "Braintree Ruby Gem #{Braintree::Version::String}"
+ request["User-Agent"] = Configuration.user_agent
request["Accept-Encoding"] = "gzip"
request["X-ApiVersion"] = Configuration::API_VERSION
request.basic_auth Configuration.public_key, Configuration.private_key
View
2  lib/braintree/util.rb
@@ -1,7 +1,7 @@
module Braintree
module Util # :nodoc:
def self.extract_attribute_as_array(hash, attribute)
- value = hash.delete(attribute)
+ value = hash.has_key?(attribute) ? hash.delete(attribute) : []
value.is_a?(Array) ? value : [value]
end
View
2  lib/braintree/version.rb
@@ -2,7 +2,7 @@ module Braintree
module Version
Major = 1
Minor = 1
- Tiny = 2
+ Tiny = 3
String = "#{Major}.#{Minor}.#{Tiny}"
end
View
4 spec/integration/braintree/customer_spec.rb
@@ -498,13 +498,13 @@
it "raises an ArgumentError if customer_id is not a string" do
expect do
Braintree::Customer.find(Object.new)
- end.to raise_error(ArgumentError, "customer_id should be a string")
+ end.to raise_error(ArgumentError, "customer_id contains invalid characters")
end
it "raises an ArgumentError if customer_id is blank" do
expect do
Braintree::Customer.find("")
- end.to raise_error(ArgumentError, "customer_id cannot be blank")
+ end.to raise_error(ArgumentError, "customer_id contains invalid characters")
end
it "raises a NotFoundError exception if customer cannot be found" do
View
3  spec/integration/braintree/subscription_spec.rb
@@ -198,10 +198,11 @@
:payment_method_token => @credit_card.token,
:plan_id => TrialPlan[:id],
:trial_period => true,
+ :trial_duration => 2,
:trial_duration_unit => nil
)
result.success?.should == false
- result.errors.for(:subscription)[0].message.should == "Trial Duration Unit is invalid."
+ result.errors.for(:subscription).on(:trial_duration_unit)[0].message.should == "Trial Duration Unit is invalid."
end
end
View
15 spec/unit/braintree/configuration_spec.rb
@@ -197,4 +197,19 @@
end
end
+ describe "self.user_agent" do
+ after :each do
+ Braintree::Configuration.custom_user_agent = nil
+ end
+
+ it "appends the default user_agent with the given value" do
+ Braintree::Configuration.custom_user_agent = "ActiveMerchant 1.2.3"
+ Braintree::Configuration.user_agent.should == "Braintree Ruby Gem #{Braintree::Version::String} (ActiveMerchant 1.2.3)"
+ end
+
+ it "does not append anything if there is no custom_user_agent" do
+ Braintree::Configuration.custom_user_agent = nil
+ Braintree::Configuration.user_agent.should == "Braintree Ruby Gem #{Braintree::Version::String}"
+ end
+ end
end
View
12 spec/unit/braintree/credit_card_spec.rb
@@ -9,6 +9,18 @@
end
end
+ describe "self.create_signature" do
+ it "should include customer_id" do
+ Braintree::CreditCard._create_signature.should include(:customer_id)
+ end
+ end
+
+ describe "self.update_signature" do
+ it "should not include customer_id" do
+ Braintree::CreditCard._update_signature.should_not include(:customer_id)
+ end
+ end
+
describe "self.create_from_transparent_redirect" do
it "raises an exception if the query string is forged" do
expect do
View
6 spec/unit/braintree/util_spec.rb
@@ -137,6 +137,12 @@
result = Braintree::Util.extract_attribute_as_array(hash, :foo)
result.should == ["one", "two"]
end
+
+ it "returns empty array if the attribute is not in the hash" do
+ hash = {:foo => ["one", "two"], :bar => :baz}
+ result = Braintree::Util.extract_attribute_as_array(hash, :quz)
+ result.should == []
+ end
end
describe "self.hash_to_query_string" do

0 comments on commit 31f9019

Please sign in to comment.
Something went wrong with that request. Please try again.