Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'upstream/master'

  • Loading branch information...
commit 56e38e5f87bf52ab83d5bd583b89388190502a44 2 parents 57f9bdf + e990030
Eric Lee authored
Showing with 35 additions and 1 deletion.
  1. +2 −1  lib/recurly/base.rb
  2. +33 −0 spec/integration/billing_info_spec.rb
View
3  lib/recurly/base.rb
@@ -106,9 +106,10 @@ def load_errors_from_array(new_errors, save_cache = false)
if field.blank?
errors[:base] << message
+ next
end
- humanized_name = field.humanize.downcase
+ humanized_name = field.to_s.humanize.downcase
message = message[(humanized_name.size + 1)..-1] if message[0, humanized_name.size + 1].downcase == "#{humanized_name} "
errors.add field.to_sym, message
View
33 spec/integration/billing_info_spec.rb
@@ -111,5 +111,38 @@ def verify_billing_info(billing_info, billing_attributes)
}.to raise_error ActiveResource::ResourceNotFound
end
end
+
+ describe "set the appropriate error" do
+ use_vcr_cassette "billing/errors/#{timestamp}"
+ let(:account){ Factory.create_account("billing-errors-#{timestamp}") }
+
+ it "should set an error on base if the card number is blank" do
+ @billing_attributes = Factory.billing_attributes({
+ :account_code => account.account_code,
+ :first_name => account.first_name,
+ :last_name => account.last_name,
+ :credit_card => {
+ :number => '',
+ },
+ })
+
+ billing_info = BillingInfo.create(@billing_attributes)
+ billing_info.errors[:base].count.should == 1
+ end
+
+ it "should set an error if the card number is invalid" do
+ @billing_attributes = Factory.billing_attributes({
+ :account_code => account.account_code,
+ :first_name => account.first_name,
+ :last_name => account.last_name,
+ :credit_card => {
+ :number => '4000-0000-0000-0002',
+ },
+ })
+
+ billing_info = BillingInfo.create(@billing_attributes)
+ billing_info.errors.count.should == 1
+ end
+ end
end
end

0 comments on commit 56e38e5

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