spec/litle/base_plugin_spec.rb in killbill-litle-1.2.1 vs spec/litle/base_plugin_spec.rb in killbill-litle-1.3.0
- old
+ new
@@ -30,11 +30,11 @@
end
it 'should reset payment methods' do
kb_account_id = '129384'
- @plugin.get_payment_methods(kb_account_id, false, nil).size.should == 0
+ @plugin.get_payment_methods(kb_account_id).size.should == 0
verify_pms kb_account_id, 0
# Create a pm with a kb_payment_method_id
Killbill::Litle::LitlePaymentMethod.create :kb_account_id => kb_account_id,
:kb_payment_method_id => 'kb-1',
@@ -42,36 +42,45 @@
verify_pms kb_account_id, 1
# Add some in KillBill and reset
payment_methods = []
# Random order... Shouldn't matter...
- payment_methods << Killbill::Plugin::Model::PaymentMethodInfoPlugin.new(kb_account_id, 'kb-3', false, 'litle-3')
- payment_methods << Killbill::Plugin::Model::PaymentMethodInfoPlugin.new(kb_account_id, 'kb-2', false, 'litle-2')
- payment_methods << Killbill::Plugin::Model::PaymentMethodInfoPlugin.new(kb_account_id, 'kb-4', false, 'litle-4')
+ payment_methods << create_pm_info_plugin(kb_account_id, 'kb-3', false, 'litle-3')
+ payment_methods << create_pm_info_plugin(kb_account_id, 'kb-2', false, 'litle-2')
+ payment_methods << create_pm_info_plugin(kb_account_id, 'kb-4', false, 'litle-4')
@plugin.reset_payment_methods kb_account_id, payment_methods
verify_pms kb_account_id, 4
# Add a payment method without a kb_payment_method_id
Killbill::Litle::LitlePaymentMethod.create :kb_account_id => kb_account_id,
:litle_token => 'litle-5'
- @plugin.get_payment_methods(kb_account_id, false, nil).size.should == 5
+ @plugin.get_payment_methods(kb_account_id).size.should == 5
# Verify we can match it
- payment_methods << Killbill::Plugin::Model::PaymentMethodInfoPlugin.new(kb_account_id, 'kb-5', false, 'litle-5')
+ payment_methods << create_pm_info_plugin(kb_account_id, 'kb-5', false, 'litle-5')
@plugin.reset_payment_methods kb_account_id, payment_methods
verify_pms kb_account_id, 5
@plugin.stop_plugin
end
private
def verify_pms(kb_account_id, size)
- pms = @plugin.get_payment_methods(kb_account_id, false, nil)
+ pms = @plugin.get_payment_methods(kb_account_id)
pms.size.should == size
pms.each do |pm|
pm.account_id.should == kb_account_id
pm.is_default.should == false
pm.external_payment_method_id.should == 'litle-' + pm.payment_method_id.split('-')[1]
end
+ end
+
+ def create_pm_info_plugin(kb_account_id, kb_payment_method_id, is_default, external_payment_method_id)
+ pm_info_plugin = Killbill::Plugin::Model::PaymentMethodInfoPlugin.new
+ pm_info_plugin.account_id = kb_account_id
+ pm_info_plugin.payment_method_id = kb_payment_method_id
+ pm_info_plugin.is_default = is_default
+ pm_info_plugin.external_payment_method_id = external_payment_method_id
+ pm_info_plugin
end
end