recurly 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of recurly might be problematic. Click here for more details.

@@ -1,87 +0,0 @@
1
- require 'test_helper'
2
- require "test/unit"
3
-
4
- class SubscriptionTest < Test::Unit::TestCase
5
-
6
- def test_create_subscription_new_account
7
- account = Recurly::Account.new(
8
- :account_code => "#{Time.now.to_i}-new-sub-new-account",
9
- :first_name => 'Verena',
10
- :last_name => 'Test',
11
- :email => 'verena@test.com',
12
- :company_name => 'Recurly Ruby Gem')
13
-
14
- sub = create_subscription(account)
15
- assert_not_nil sub
16
- assert_nil sub.canceled_at
17
- assert_equal sub.state, 'active'
18
- assert_not_nil sub.current_period_started_at
19
- end
20
-
21
- def test_create_subscription_existing_account
22
- account = create_account('existing-account')
23
- sub = create_subscription(account)
24
-
25
- assert_equal sub.state, 'active'
26
- end
27
-
28
- def test_update_subscription
29
- account = create_account('update-subscription')
30
- sub = create_subscription(account)
31
-
32
- sub.change('now', :quantity => 2)
33
-
34
- sub = Recurly::Subscription.find(account.account_code)
35
- assert_equal sub.quantity, 2
36
- end
37
-
38
- def test_cancel_subscription
39
- account = create_account('cancel-subscription')
40
- subscription = create_subscription(account)
41
-
42
- subscription.cancel(account.account_code)
43
-
44
- sub = Recurly::Subscription.find(account.account_code)
45
- assert_equal sub.state, 'canceled'
46
- assert_not_nil sub.canceled_at
47
- end
48
-
49
- def test_refund_subscription
50
- account = create_account('refund-subscription')
51
- subscription = create_subscription(account)
52
-
53
- subscription.refund(:full)
54
-
55
- assert_raises ActiveResource::ResourceNotFound do
56
- get_sub = Recurly::Subscription.find(account.account_code)
57
- end
58
- end
59
-
60
- def create_subscription(account, subscription_attrs={})
61
- account.billing_info = Recurly::BillingInfo.new(
62
- :first_name => account.first_name,
63
- :last_name => account.last_name,
64
- :address1 => '123 Test St',
65
- :city => 'San Francisco',
66
- :state => 'CA',
67
- :country => 'US',
68
- :zip => '94103',
69
- :credit_card => {
70
- :number => '1',
71
- :year => Time.now.year + 1,
72
- :month => Time.now.month,
73
- :verification_value => '123'
74
- },
75
- :ip_address => '127.0.0.1'
76
- )
77
-
78
- params = {:account_code => account.account_code,
79
- :plan_code => TEST_PLAN_CODE,
80
- :quantity => 1,
81
- :account => account}.merge subscription_attrs
82
-
83
- sub = Recurly::Subscription.create(params)
84
-
85
- end
86
-
87
- end
data/test/test_helper.rb DELETED
@@ -1,44 +0,0 @@
1
- require 'test/unit'
2
- require 'rubygems'
3
-
4
- require File.dirname(__FILE__) + '/../lib/recurly'
5
-
6
- Recurly.configure do |c|
7
- c.username = ''
8
- c.password = ''
9
- c.site = ''
10
- end
11
-
12
- TEST_PLAN_CODE = 'trial'
13
-
14
- def create_account(account_code)
15
- account = Recurly::Account.create(
16
- :account_code => "#{Time.now.to_i}-#{account_code}",
17
- :first_name => 'Verena',
18
- :last_name => 'Test',
19
- :email => 'verena@test.com',
20
- :company_name => 'Recurly Ruby Gem')
21
- end
22
-
23
- def create_account_with_billing_info(account_code)
24
-
25
- account = create_account(account_code)
26
-
27
- billing_info = Recurly::BillingInfo.create(
28
- :account_code => account.account_code,
29
- :first_name => account.first_name,
30
- :last_name => account.last_name,
31
- :address1 => '123 Test St',
32
- :city => 'San Francisco',
33
- :state => 'CA',
34
- :zip => '94115',
35
- :credit_card => {
36
- :number => '1',
37
- :year => Time.now.year + 1,
38
- :month => Time.now.month,
39
- :verification_value => '123'
40
- }
41
- )
42
-
43
- account
44
- end
@@ -1,19 +0,0 @@
1
- require 'test_helper'
2
- require "test/unit"
3
-
4
- class TransactionTest < Test::Unit::TestCase
5
-
6
- def test_create_transaction
7
- account = create_account_with_billing_info('transaction')
8
-
9
- trans = Recurly::Transaction.create(
10
- :account => { :account_code => account.account_code },
11
- :amount_in_cents => 500,
12
- :description => "test transaction for $5"
13
- )
14
-
15
- assert_not_nil trans.id
16
- assert_equal trans.amount_in_cents, 500
17
- end
18
-
19
- end