Skip to content

Commit

Permalink
Update valid_month and valid_expiry_year to coerce string arguments t…
Browse files Browse the repository at this point in the history
…o integers
  • Loading branch information
Cody Fauser committed May 6, 2010
1 parent 82c7408 commit 3fe363d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG

* Update valid_month and valid_expiry_year to coerce string arguments to integers [cody]
* Add support for displaying credit cards with PayPal Express. Use the :allow_guest_checkout => true option when setting up the transaction [Edward Ocampo-Gooding]
* Use card_brand method for checking for checks in Sage and Beanstream [cody]
* Add JCB and Diners Club to LinkPoint [Soleone]
Expand Down
4 changes: 2 additions & 2 deletions lib/active_merchant/billing/credit_card_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def self.included(base)
end

def valid_month?(month)
(1..12).include?(month)
(1..12).include?(month.to_i)
end

def valid_expiry_year?(year)
(Time.now.year..Time.now.year + 20).include?(year)
(Time.now.year..Time.now.year + 20).include?(year.to_i)
end

def valid_start_year?(year)
Expand Down
13 changes: 13 additions & 0 deletions test/unit/credit_card_methods_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ def test_should_be_able_to_identify_valid_start_years
assert_false valid_start_year?(1987)
end

def test_valid_start_year_can_handle_strings
assert valid_start_year?("2009")
end

def test_valid_month_can_handle_strings
assert valid_month?("1")
end

def test_valid_expiry_year_can_handle_strings
year = Time.now.year + 1
assert valid_expiry_year?(year.to_s)
end

def test_should_be_able_to_identify_valid_issue_numbers
assert valid_issue_number?(1)
assert valid_issue_number?(10)
Expand Down

0 comments on commit 3fe363d

Please sign in to comment.