invoiced 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +37 -0
- data/.github/workflows/publish.yml +24 -0
- data/Gemfile +4 -4
- data/README.md +3 -3
- data/invoiced.gemspec +2 -2
- data/lib/invoiced/bank_account.rb +0 -1
- data/lib/invoiced/card.rb +0 -1
- data/lib/invoiced/custom_field.rb +10 -0
- data/lib/invoiced/customer_chasing_cadence.rb +10 -0
- data/lib/invoiced/email_template.rb +10 -0
- data/lib/invoiced/gl_account.rb +10 -0
- data/lib/invoiced/inbox.rb +7 -0
- data/lib/invoiced/invoice_chasing_cadence.rb +10 -0
- data/lib/invoiced/late_fee_schedule.rb +10 -0
- data/lib/invoiced/member.rb +10 -0
- data/lib/invoiced/merchant_account.rb +10 -0
- data/lib/invoiced/object.rb +5 -1
- data/lib/invoiced/payment_method.rb +8 -0
- data/lib/invoiced/pdf_template.rb +10 -0
- data/lib/invoiced/report.rb +7 -0
- data/lib/invoiced/role.rb +10 -0
- data/lib/invoiced/sign_up_page.rb +10 -0
- data/lib/invoiced/sms_template.rb +10 -0
- data/lib/invoiced/tax_rule.rb +10 -0
- data/lib/invoiced/theme.rb +10 -0
- data/lib/invoiced/version.rb +2 -2
- data/lib/invoiced/webhook.rb +10 -0
- data/lib/invoiced.rb +39 -2
- data/test/invoiced/charge_test.rb +8 -6
- data/test/invoiced/contact_test.rb +10 -86
- data/test/invoiced/coupon_test.rb +10 -83
- data/test/invoiced/credit_balance_adjustment_test.rb +17 -0
- data/test/invoiced/credit_note_test.rb +10 -83
- data/test/invoiced/custom_field_test.rb +17 -0
- data/test/invoiced/customer_chasing_cadence_test.rb +17 -0
- data/test/invoiced/customer_test.rb +10 -83
- data/test/invoiced/email_template_test.rb +17 -0
- data/test/invoiced/estimate_test.rb +10 -83
- data/test/invoiced/event_test.rb +6 -21
- data/test/invoiced/file_test.rb +8 -47
- data/test/invoiced/gl_account_test.rb +17 -0
- data/test/invoiced/inbox_test.rb +13 -0
- data/test/invoiced/invoice_chasing_cadence_test.rb +17 -0
- data/test/invoiced/invoice_test.rb +10 -83
- data/test/invoiced/item_test.rb +10 -83
- data/test/invoiced/late_fee_schedule_test.rb +17 -0
- data/test/invoiced/line_item_test.rb +10 -86
- data/test/invoiced/member_test.rb +17 -0
- data/test/invoiced/merchant_account_test.rb +17 -0
- data/test/invoiced/note_test.rb +10 -83
- data/test/invoiced/operations/create_test.rb +22 -0
- data/test/invoiced/operations/delete_test.rb +20 -0
- data/test/invoiced/operations/endpoint_test.rb +13 -0
- data/test/invoiced/operations/list_test.rb +26 -0
- data/test/invoiced/operations/operations.rb +0 -0
- data/test/invoiced/operations/retrieve_test.rb +22 -0
- data/test/invoiced/operations/update_test.rb +29 -0
- data/test/invoiced/payment_method_test.rb +15 -0
- data/test/invoiced/payment_plan_test.rb +7 -0
- data/test/invoiced/payment_test.rb +10 -83
- data/test/invoiced/pdf_template_test.rb +17 -0
- data/test/invoiced/plan_test.rb +10 -83
- data/test/invoiced/refund_test.rb +5 -3
- data/test/invoiced/report_test.rb +14 -0
- data/test/invoiced/role_test.rb +17 -0
- data/test/invoiced/sign_up_page_test.rb +17 -0
- data/test/invoiced/sms_template_test.rb +17 -0
- data/test/invoiced/subscription_test.rb +10 -71
- data/test/invoiced/task_test.rb +10 -83
- data/test/invoiced/tax_rate_test.rb +10 -83
- data/test/invoiced/tax_rule_test.rb +17 -0
- data/test/invoiced/theme_test.rb +17 -0
- data/test/invoiced/webhook_test.rb +17 -0
- data/test/test_helper.rb +6 -0
- metadata +78 -9
- data/.travis.yml +0 -15
- data/test/invoiced/credit_balance_adjustment.rb +0 -90
@@ -2,89 +2,16 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Invoiced
|
4
4
|
class PaymentTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
|
-
|
18
|
-
payment = @client.Payment.create({:amount => 800})
|
19
|
-
|
20
|
-
assert_instance_of(Invoiced::Payment, payment)
|
21
|
-
assert_equal(123, payment.id)
|
22
|
-
assert_equal(100, payment.amount)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "retrieve a payment" do
|
26
|
-
mockResponse = mock('RestClient::Response')
|
27
|
-
mockResponse.stubs(:code).returns(200)
|
28
|
-
mockResponse.stubs(:body).returns('{"id":123,"amount":100}')
|
29
|
-
mockResponse.stubs(:headers).returns({})
|
30
|
-
|
31
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
32
|
-
|
33
|
-
payment = @client.Payment.retrieve(123)
|
34
|
-
|
35
|
-
assert_instance_of(Invoiced::Payment, payment)
|
36
|
-
assert_equal(123, payment.id)
|
37
|
-
assert_equal(100, payment.amount)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "not update a payment when no params" do
|
41
|
-
payment = Payment.new(@client, 123)
|
42
|
-
assert_false(payment.save)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "update a payment" do
|
46
|
-
mockResponse = mock('RestClient::Response')
|
47
|
-
mockResponse.stubs(:code).returns(200)
|
48
|
-
mockResponse.stubs(:body).returns('{"id":123,"sent":true}')
|
49
|
-
mockResponse.stubs(:headers).returns({})
|
50
|
-
|
51
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
52
|
-
|
53
|
-
payment = Payment.new(@client, 123)
|
54
|
-
payment.sent = true
|
55
|
-
assert_true(payment.save)
|
56
|
-
|
57
|
-
assert_true(payment.sent)
|
58
|
-
end
|
59
|
-
|
60
|
-
should "list all payments" do
|
61
|
-
mockResponse = mock('RestClient::Response')
|
62
|
-
mockResponse.stubs(:code).returns(200)
|
63
|
-
mockResponse.stubs(:body).returns('[{"id":123,"amount":100}]')
|
64
|
-
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/payments?per_page=25&page=1>; rel="self", <https://api.invoiced.com/payments?per_page=25&page=1>; rel="first", <https://api.invoiced.com/payments?per_page=25&page=1>; rel="last"')
|
65
|
-
|
66
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
67
|
-
|
68
|
-
payments, metadata = @client.Payment.list
|
69
|
-
|
70
|
-
assert_instance_of(Array, payments)
|
71
|
-
assert_equal(1, payments.length)
|
72
|
-
assert_equal(123, payments[0].id)
|
73
|
-
|
74
|
-
assert_instance_of(Invoiced::List, metadata)
|
75
|
-
assert_equal(15, metadata.total_count)
|
76
|
-
end
|
77
|
-
|
78
|
-
should "delete a payment" do
|
79
|
-
mockResponse = mock('RestClient::Response')
|
80
|
-
mockResponse.stubs(:code).returns(204)
|
81
|
-
mockResponse.stubs(:body).returns('')
|
82
|
-
mockResponse.stubs(:headers).returns({})
|
83
|
-
|
84
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
85
|
-
|
86
|
-
payment = Payment.new(@client, 123)
|
87
|
-
assert_true(payment.delete)
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = Payment
|
14
|
+
@endpoint = '/payments'
|
88
15
|
end
|
89
16
|
|
90
17
|
should "send a payment receipt" do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class PdfTemplateTest < Test::Unit::TestCase
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = PdfTemplate
|
14
|
+
@endpoint = '/pdf_templates'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/test/invoiced/plan_test.rb
CHANGED
@@ -2,89 +2,16 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Invoiced
|
4
4
|
class PlanTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
|
-
|
18
|
-
plan = @client.Plan.create({:name => "Test Plan"})
|
19
|
-
|
20
|
-
assert_instance_of(Invoiced::Plan, plan)
|
21
|
-
assert_equal("test", plan.id)
|
22
|
-
assert_equal('Test Plan', plan.name)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "retrieve a plan" do
|
26
|
-
mockResponse = mock('RestClient::Response')
|
27
|
-
mockResponse.stubs(:code).returns(200)
|
28
|
-
mockResponse.stubs(:body).returns('{"id":"test","name":"Test Plan"}')
|
29
|
-
mockResponse.stubs(:headers).returns({})
|
30
|
-
|
31
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
32
|
-
|
33
|
-
plan = @client.Plan.retrieve("test")
|
34
|
-
|
35
|
-
assert_instance_of(Invoiced::Plan, plan)
|
36
|
-
assert_equal("test", plan.id)
|
37
|
-
assert_equal('Test Plan', plan.name)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "not update a plan when no params" do
|
41
|
-
plan = Plan.new(@client, "test")
|
42
|
-
assert_false(plan.save)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "update a plan" do
|
46
|
-
mockResponse = mock('RestClient::Response')
|
47
|
-
mockResponse.stubs(:code).returns(200)
|
48
|
-
mockResponse.stubs(:body).returns('{"id":"test","closed":true}')
|
49
|
-
mockResponse.stubs(:headers).returns({})
|
50
|
-
|
51
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
52
|
-
|
53
|
-
plan = Plan.new(@client, "test")
|
54
|
-
plan.closed = true
|
55
|
-
assert_true(plan.save)
|
56
|
-
|
57
|
-
assert_true(plan.closed)
|
58
|
-
end
|
59
|
-
|
60
|
-
should "list all plans" do
|
61
|
-
mockResponse = mock('RestClient::Response')
|
62
|
-
mockResponse.stubs(:code).returns(200)
|
63
|
-
mockResponse.stubs(:body).returns('[{"id":"test","name":"Test Plan"}]')
|
64
|
-
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/plans?per_page=25&page=1>; rel="self", <https://api.invoiced.com/plans?per_page=25&page=1>; rel="first", <https://api.invoiced.com/plans?per_page=25&page=1>; rel="last"')
|
65
|
-
|
66
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
67
|
-
|
68
|
-
plans, metadata = @client.Plan.list
|
69
|
-
|
70
|
-
assert_instance_of(Array, plans)
|
71
|
-
assert_equal(1, plans.length)
|
72
|
-
assert_equal("test", plans[0].id)
|
73
|
-
|
74
|
-
assert_instance_of(Invoiced::List, metadata)
|
75
|
-
assert_equal(15, metadata.total_count)
|
76
|
-
end
|
77
|
-
|
78
|
-
should "delete a plan" do
|
79
|
-
mockResponse = mock('RestClient::Response')
|
80
|
-
mockResponse.stubs(:code).returns(204)
|
81
|
-
mockResponse.stubs(:body).returns('')
|
82
|
-
mockResponse.stubs(:headers).returns({})
|
83
|
-
|
84
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
85
|
-
|
86
|
-
plan = Plan.new(@client, "test")
|
87
|
-
assert_true(plan.delete)
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = Plan
|
14
|
+
@endpoint = '/plans'
|
88
15
|
end
|
89
16
|
end
|
90
17
|
end
|
@@ -2,9 +2,11 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Invoiced
|
4
4
|
class RefundTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@objectClass = Refund
|
9
|
+
@endpoint = '/refunds'
|
8
10
|
end
|
9
11
|
|
10
12
|
should "create a refund" do
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class ReportTest < Test::Unit::TestCase
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
|
9
|
+
setup do
|
10
|
+
@objectClass = Report
|
11
|
+
@endpoint = '/reports'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class RoleTest < Test::Unit::TestCase
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = Role
|
14
|
+
@endpoint = '/roles'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class SignUpPageTest < Test::Unit::TestCase
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = SignUpPage
|
14
|
+
@endpoint = '/sign_up_pages'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class SmsTemplateTest < Test::Unit::TestCase
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = SmsTemplate
|
14
|
+
@endpoint = '/sms_templates'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -2,77 +2,16 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Invoiced
|
4
4
|
class SubscriptionTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
|
-
|
18
|
-
subscription = @client.Subscription.create({:customer => 456})
|
19
|
-
|
20
|
-
assert_instance_of(Invoiced::Subscription, subscription)
|
21
|
-
assert_equal(123, subscription.id)
|
22
|
-
assert_equal("starter", subscription.plan)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "retrieve a subscription" do
|
26
|
-
mockResponse = mock('RestClient::Response')
|
27
|
-
mockResponse.stubs(:code).returns(200)
|
28
|
-
mockResponse.stubs(:body).returns('{"id":123,"plan":"starter"}')
|
29
|
-
mockResponse.stubs(:headers).returns({})
|
30
|
-
|
31
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
32
|
-
|
33
|
-
subscription = @client.Subscription.retrieve(123)
|
34
|
-
|
35
|
-
assert_instance_of(Invoiced::Subscription, subscription)
|
36
|
-
assert_equal(123, subscription.id)
|
37
|
-
assert_equal("starter", subscription.plan)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "not update a subscription when no params" do
|
41
|
-
subscription = Subscription.new(@client, 123)
|
42
|
-
assert_false(subscription.save)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "update a subscription" do
|
46
|
-
mockResponse = mock('RestClient::Response')
|
47
|
-
mockResponse.stubs(:code).returns(200)
|
48
|
-
mockResponse.stubs(:body).returns('{"id":123,"plan":"pro"}')
|
49
|
-
mockResponse.stubs(:headers).returns({})
|
50
|
-
|
51
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
52
|
-
|
53
|
-
subscription = Subscription.new(@client, 123)
|
54
|
-
subscription.plan = "pro"
|
55
|
-
assert_true(subscription.save)
|
56
|
-
|
57
|
-
assert_equal("pro", subscription.plan)
|
58
|
-
end
|
59
|
-
|
60
|
-
should "list all subscriptions" do
|
61
|
-
mockResponse = mock('RestClient::Response')
|
62
|
-
mockResponse.stubs(:code).returns(200)
|
63
|
-
mockResponse.stubs(:body).returns('[{"id":123,"plan":"pro"}]')
|
64
|
-
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/subscriptions?per_page=25&page=1>; rel="self", <https://api.invoiced.com/subscriptions?per_page=25&page=1>; rel="first", <https://api.invoiced.com/subscriptions?per_page=25&page=1>; rel="last"')
|
65
|
-
|
66
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
67
|
-
|
68
|
-
subscriptions, metadata = @client.Subscription.list
|
69
|
-
|
70
|
-
assert_instance_of(Array, subscriptions)
|
71
|
-
assert_equal(1, subscriptions.length)
|
72
|
-
assert_equal(123, subscriptions[0].id)
|
73
|
-
|
74
|
-
assert_instance_of(Invoiced::List, metadata)
|
75
|
-
assert_equal(15, metadata.total_count)
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = Subscription
|
14
|
+
@endpoint = '/subscriptions'
|
76
15
|
end
|
77
16
|
|
78
17
|
should "cancel a subscription" do
|
data/test/invoiced/task_test.rb
CHANGED
@@ -2,89 +2,16 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Invoiced
|
4
4
|
class TaskTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
|
-
|
18
|
-
task = @client.Task.create({:name => "Test Task"})
|
19
|
-
|
20
|
-
assert_instance_of(Invoiced::Task, task)
|
21
|
-
assert_equal("test", task.id)
|
22
|
-
assert_equal('Test Task', task.name)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "retrieve a task" do
|
26
|
-
mockResponse = mock('RestClient::Response')
|
27
|
-
mockResponse.stubs(:code).returns(200)
|
28
|
-
mockResponse.stubs(:body).returns('{"id":"test","name":"Test Task"}')
|
29
|
-
mockResponse.stubs(:headers).returns({})
|
30
|
-
|
31
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
32
|
-
|
33
|
-
task = @client.Task.retrieve("test")
|
34
|
-
|
35
|
-
assert_instance_of(Invoiced::Task, task)
|
36
|
-
assert_equal("test", task.id)
|
37
|
-
assert_equal('Test Task', task.name)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "not update a task when no params" do
|
41
|
-
task = Task.new(@client, "test")
|
42
|
-
assert_false(task.save)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "update a task" do
|
46
|
-
mockResponse = mock('RestClient::Response')
|
47
|
-
mockResponse.stubs(:code).returns(200)
|
48
|
-
mockResponse.stubs(:body).returns('{"id":"test","name":"new contents"}')
|
49
|
-
mockResponse.stubs(:headers).returns({})
|
50
|
-
|
51
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
52
|
-
|
53
|
-
task = Task.new(@client, "test")
|
54
|
-
task.name = "new contents"
|
55
|
-
assert_true(task.save)
|
56
|
-
|
57
|
-
assert_equal(task.name, 'new contents')
|
58
|
-
end
|
59
|
-
|
60
|
-
should "list all tasks" do
|
61
|
-
mockResponse = mock('RestClient::Response')
|
62
|
-
mockResponse.stubs(:code).returns(200)
|
63
|
-
mockResponse.stubs(:body).returns('[{"id":"test","name":"Test Task"}]')
|
64
|
-
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/tasks?per_page=25&page=1>; rel="self", <https://api.invoiced.com/tasks?per_page=25&page=1>; rel="first", <https://api.invoiced.com/tasks?per_page=25&page=1>; rel="last"')
|
65
|
-
|
66
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
67
|
-
|
68
|
-
tasks, metadata = @client.Task.list
|
69
|
-
|
70
|
-
assert_instance_of(Array, tasks)
|
71
|
-
assert_equal(1, tasks.length)
|
72
|
-
assert_equal("test", tasks[0].id)
|
73
|
-
|
74
|
-
assert_instance_of(Invoiced::List, metadata)
|
75
|
-
assert_equal(15, metadata.total_count)
|
76
|
-
end
|
77
|
-
|
78
|
-
should "delete a task" do
|
79
|
-
mockResponse = mock('RestClient::Response')
|
80
|
-
mockResponse.stubs(:code).returns(204)
|
81
|
-
mockResponse.stubs(:body).returns('')
|
82
|
-
mockResponse.stubs(:headers).returns({})
|
83
|
-
|
84
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
85
|
-
|
86
|
-
task = Task.new(@client, "test")
|
87
|
-
assert_true(task.delete)
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = Task
|
14
|
+
@endpoint = '/tasks'
|
88
15
|
end
|
89
16
|
end
|
90
17
|
end
|
@@ -2,89 +2,16 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Invoiced
|
4
4
|
class TaxRateTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
17
|
-
|
18
|
-
tax_rate = @client.TaxRate.create({:name => "Test TaxRate"})
|
19
|
-
|
20
|
-
assert_instance_of(Invoiced::TaxRate, tax_rate)
|
21
|
-
assert_equal("test", tax_rate.id)
|
22
|
-
assert_equal('Test TaxRate', tax_rate.name)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "retrieve a tax rate" do
|
26
|
-
mockResponse = mock('RestClient::Response')
|
27
|
-
mockResponse.stubs(:code).returns(200)
|
28
|
-
mockResponse.stubs(:body).returns('{"id":"test","name":"Test TaxRate"}')
|
29
|
-
mockResponse.stubs(:headers).returns({})
|
30
|
-
|
31
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
32
|
-
|
33
|
-
tax_rate = @client.TaxRate.retrieve("test")
|
34
|
-
|
35
|
-
assert_instance_of(Invoiced::TaxRate, tax_rate)
|
36
|
-
assert_equal("test", tax_rate.id)
|
37
|
-
assert_equal('Test TaxRate', tax_rate.name)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "not update a tax rate when no params" do
|
41
|
-
tax_rate = TaxRate.new(@client, "test")
|
42
|
-
assert_false(tax_rate.save)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "update a tax rate" do
|
46
|
-
mockResponse = mock('RestClient::Response')
|
47
|
-
mockResponse.stubs(:code).returns(200)
|
48
|
-
mockResponse.stubs(:body).returns('{"id":"test","name":"new contents"}')
|
49
|
-
mockResponse.stubs(:headers).returns({})
|
50
|
-
|
51
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
52
|
-
|
53
|
-
tax_rate = TaxRate.new(@client, "test")
|
54
|
-
tax_rate.name = "new contents"
|
55
|
-
assert_true(tax_rate.save)
|
56
|
-
|
57
|
-
assert_equal(tax_rate.name, 'new contents')
|
58
|
-
end
|
59
|
-
|
60
|
-
should "list all tax rates" do
|
61
|
-
mockResponse = mock('RestClient::Response')
|
62
|
-
mockResponse.stubs(:code).returns(200)
|
63
|
-
mockResponse.stubs(:body).returns('[{"id":"test","name":"Test TaxRate"}]')
|
64
|
-
mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/tax_rates?per_page=25&page=1>; rel="self", <https://api.invoiced.com/tax_rates?per_page=25&page=1>; rel="first", <https://api.invoiced.com/tax_rates?per_page=25&page=1>; rel="last"')
|
65
|
-
|
66
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
67
|
-
|
68
|
-
tax_rates, metadata = @client.TaxRate.list
|
69
|
-
|
70
|
-
assert_instance_of(Array, tax_rates)
|
71
|
-
assert_equal(1, tax_rates.length)
|
72
|
-
assert_equal("test", tax_rates[0].id)
|
73
|
-
|
74
|
-
assert_instance_of(Invoiced::List, metadata)
|
75
|
-
assert_equal(15, metadata.total_count)
|
76
|
-
end
|
77
|
-
|
78
|
-
should "delete a tax rate" do
|
79
|
-
mockResponse = mock('RestClient::Response')
|
80
|
-
mockResponse.stubs(:code).returns(204)
|
81
|
-
mockResponse.stubs(:body).returns('')
|
82
|
-
mockResponse.stubs(:headers).returns({})
|
83
|
-
|
84
|
-
RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
|
85
|
-
|
86
|
-
tax_rate = TaxRate.new(@client, "test")
|
87
|
-
assert_true(tax_rate.delete)
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = TaxRate
|
14
|
+
@endpoint = '/tax_rates'
|
88
15
|
end
|
89
16
|
end
|
90
17
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class TaxRuleTest < Test::Unit::TestCase
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = TaxRule
|
14
|
+
@endpoint = '/tax_rules'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class ThemeTest < Test::Unit::TestCase
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = Theme
|
14
|
+
@endpoint = '/themes'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Invoiced
|
4
|
+
class WebhookTest < Test::Unit::TestCase
|
5
|
+
include Invoiced::Operations::EndpointTest
|
6
|
+
include Invoiced::Operations::CreateTest
|
7
|
+
include Invoiced::Operations::RetrieveTest
|
8
|
+
include Invoiced::Operations::UpdateTest
|
9
|
+
include Invoiced::Operations::DeleteTest
|
10
|
+
include Invoiced::Operations::ListTest
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@objectClass = Webhook
|
14
|
+
@endpoint = '/webhooks'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -14,6 +14,12 @@ require 'invoiced'
|
|
14
14
|
require 'test/unit'
|
15
15
|
require 'mocha/setup'
|
16
16
|
require 'shoulda'
|
17
|
+
require 'invoiced/operations/list_test'
|
18
|
+
require 'invoiced/operations/create_test'
|
19
|
+
require 'invoiced/operations/endpoint_test'
|
20
|
+
require 'invoiced/operations/update_test'
|
21
|
+
require 'invoiced/operations/delete_test'
|
22
|
+
require 'invoiced/operations/retrieve_test'
|
17
23
|
|
18
24
|
class Test::Unit::TestCase
|
19
25
|
include Mocha
|