Use lowercased cc_type in CreditCard service

This commit is contained in:
Rob Harrington
2017-09-14 10:22:24 +10:00
parent e14b017f1f
commit 4785f3eacc
2 changed files with 32 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
describe 'CreditCard service', ->
CreditCard = null
beforeEach ->
module 'Darkswarm'
module ($provide)->
$provide.value "savedCreditCards", []
$provide.value "railsFlash", null
null
inject (_CreditCard_)->
CreditCard = _CreditCard_
describe "process_params", ->
beforeEach ->
CreditCard.secrets =
card:
exp_month: "12"
exp_year: "2030"
last4: "1234"
cc_type: 'mastercard'
token: "token123"
it "uses cc_type, rather than fetching the brand from the card", ->
# This is important for processing the card with activemerchant
process_params = CreditCard.process_params()
expect(process_params['exp_month']).toEqual "12"
expect(process_params['exp_year']).toEqual "2030"
expect(process_params['last4']).toEqual "1234"
expect(process_params['token']).toEqual "token123"
expect(process_params['cc_type']).toEqual "mastercard"