#NEWLINE# def test_update_from_transparent_redirect_and_make_default( self ) : #NEWLINE# #INDENT# customer = Customer . create ( { #NEWLINE# #INDENT# 'credit_card' : { #NEWLINE# #INDENT# 'number' : '4111111111111111' , #NEWLINE# 'expiration_date' : '05/2012' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) . customer #NEWLINE# card1 = customer . credit_cards [ 0 ] #NEWLINE# card2 = CreditCard . create ( { #NEWLINE# #INDENT# 'customer_id' : customer . id , #NEWLINE# 'number' : '4111111111111111' , #NEWLINE# 'expiration_date' : '05/2014' , #NEWLINE# #UNINDENT# } ) . credit_card #NEWLINE# self . assertTrue ( card1 . default ) #NEWLINE# self . assertFalse ( card2 . default ) #NEWLINE# tr_data = { #NEWLINE# #INDENT# 'payment_method_token' : card2 . token , #NEWLINE# 'credit_card' : { #NEWLINE# #INDENT# 'options' : { #NEWLINE# #INDENT# 'make_default' : True , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# post_params = { #NEWLINE# #INDENT# 'tr_data' : CreditCard . tr_data_for_update ( tr_data , 'http://example.com/path' ) , #NEWLINE# 'credit_card[cardholder_name]' : 'New Cardholder Name' , #NEWLINE# 'credit_card[expiration_date]' : '05/2014' , #NEWLINE# #UNINDENT# } #NEWLINE# query_string = TestHelper . simulate_tr_form_post ( post_params , CreditCard . transparent_redirect_update_url ( ) ) #NEWLINE# result = CreditCard . confirm_transparent_redirect ( query_string ) #NEWLINE# self . assertFalse ( CreditCard . find ( post_params . token ) . default ) #NEWLINE# self . assertTrue ( CreditCard . find ( card2 . token ) . default )