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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +37 -0
  3. data/.github/workflows/publish.yml +24 -0
  4. data/Gemfile +4 -4
  5. data/README.md +3 -3
  6. data/invoiced.gemspec +2 -2
  7. data/lib/invoiced/bank_account.rb +0 -1
  8. data/lib/invoiced/card.rb +0 -1
  9. data/lib/invoiced/custom_field.rb +10 -0
  10. data/lib/invoiced/customer_chasing_cadence.rb +10 -0
  11. data/lib/invoiced/email_template.rb +10 -0
  12. data/lib/invoiced/gl_account.rb +10 -0
  13. data/lib/invoiced/inbox.rb +7 -0
  14. data/lib/invoiced/invoice_chasing_cadence.rb +10 -0
  15. data/lib/invoiced/late_fee_schedule.rb +10 -0
  16. data/lib/invoiced/member.rb +10 -0
  17. data/lib/invoiced/merchant_account.rb +10 -0
  18. data/lib/invoiced/object.rb +5 -1
  19. data/lib/invoiced/payment_method.rb +8 -0
  20. data/lib/invoiced/pdf_template.rb +10 -0
  21. data/lib/invoiced/report.rb +7 -0
  22. data/lib/invoiced/role.rb +10 -0
  23. data/lib/invoiced/sign_up_page.rb +10 -0
  24. data/lib/invoiced/sms_template.rb +10 -0
  25. data/lib/invoiced/tax_rule.rb +10 -0
  26. data/lib/invoiced/theme.rb +10 -0
  27. data/lib/invoiced/version.rb +2 -2
  28. data/lib/invoiced/webhook.rb +10 -0
  29. data/lib/invoiced.rb +39 -2
  30. data/test/invoiced/charge_test.rb +8 -6
  31. data/test/invoiced/contact_test.rb +10 -86
  32. data/test/invoiced/coupon_test.rb +10 -83
  33. data/test/invoiced/credit_balance_adjustment_test.rb +17 -0
  34. data/test/invoiced/credit_note_test.rb +10 -83
  35. data/test/invoiced/custom_field_test.rb +17 -0
  36. data/test/invoiced/customer_chasing_cadence_test.rb +17 -0
  37. data/test/invoiced/customer_test.rb +10 -83
  38. data/test/invoiced/email_template_test.rb +17 -0
  39. data/test/invoiced/estimate_test.rb +10 -83
  40. data/test/invoiced/event_test.rb +6 -21
  41. data/test/invoiced/file_test.rb +8 -47
  42. data/test/invoiced/gl_account_test.rb +17 -0
  43. data/test/invoiced/inbox_test.rb +13 -0
  44. data/test/invoiced/invoice_chasing_cadence_test.rb +17 -0
  45. data/test/invoiced/invoice_test.rb +10 -83
  46. data/test/invoiced/item_test.rb +10 -83
  47. data/test/invoiced/late_fee_schedule_test.rb +17 -0
  48. data/test/invoiced/line_item_test.rb +10 -86
  49. data/test/invoiced/member_test.rb +17 -0
  50. data/test/invoiced/merchant_account_test.rb +17 -0
  51. data/test/invoiced/note_test.rb +10 -83
  52. data/test/invoiced/operations/create_test.rb +22 -0
  53. data/test/invoiced/operations/delete_test.rb +20 -0
  54. data/test/invoiced/operations/endpoint_test.rb +13 -0
  55. data/test/invoiced/operations/list_test.rb +26 -0
  56. data/test/invoiced/operations/operations.rb +0 -0
  57. data/test/invoiced/operations/retrieve_test.rb +22 -0
  58. data/test/invoiced/operations/update_test.rb +29 -0
  59. data/test/invoiced/payment_method_test.rb +15 -0
  60. data/test/invoiced/payment_plan_test.rb +7 -0
  61. data/test/invoiced/payment_test.rb +10 -83
  62. data/test/invoiced/pdf_template_test.rb +17 -0
  63. data/test/invoiced/plan_test.rb +10 -83
  64. data/test/invoiced/refund_test.rb +5 -3
  65. data/test/invoiced/report_test.rb +14 -0
  66. data/test/invoiced/role_test.rb +17 -0
  67. data/test/invoiced/sign_up_page_test.rb +17 -0
  68. data/test/invoiced/sms_template_test.rb +17 -0
  69. data/test/invoiced/subscription_test.rb +10 -71
  70. data/test/invoiced/task_test.rb +10 -83
  71. data/test/invoiced/tax_rate_test.rb +10 -83
  72. data/test/invoiced/tax_rule_test.rb +17 -0
  73. data/test/invoiced/theme_test.rb +17 -0
  74. data/test/invoiced/webhook_test.rb +17 -0
  75. data/test/test_helper.rb +6 -0
  76. metadata +78 -9
  77. data/.travis.yml +0 -15
  78. 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 CouponTest < Test::Unit::TestCase
5
- should "return the api endpoint" do
6
- coupon = Coupon.new(@client, "test")
7
- assert_equal('/coupons/test', coupon.endpoint())
8
- end
9
-
10
- should "create a coupon" do
11
- mockResponse = mock('RestClient::Response')
12
- mockResponse.stubs(:code).returns(201)
13
- mockResponse.stubs(:body).returns('{"id":"test","name":"Test Coupon"}')
14
- mockResponse.stubs(:headers).returns({})
15
-
16
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
17
-
18
- coupon = @client.Coupon.create({:name => "Test Coupon"})
19
-
20
- assert_instance_of(Invoiced::Coupon, coupon)
21
- assert_equal("test", coupon.id)
22
- assert_equal('Test Coupon', coupon.name)
23
- end
24
-
25
- should "retrieve a coupon" do
26
- mockResponse = mock('RestClient::Response')
27
- mockResponse.stubs(:code).returns(200)
28
- mockResponse.stubs(:body).returns('{"id":"test","name":"Test Coupon"}')
29
- mockResponse.stubs(:headers).returns({})
30
-
31
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
32
-
33
- coupon = @client.Coupon.retrieve("test")
34
-
35
- assert_instance_of(Invoiced::Coupon, coupon)
36
- assert_equal("test", coupon.id)
37
- assert_equal('Test Coupon', coupon.name)
38
- end
39
-
40
- should "not update a coupon when no params" do
41
- coupon = Coupon.new(@client, "test")
42
- assert_false(coupon.save)
43
- end
44
-
45
- should "update a coupon" do
46
- mockResponse = mock('RestClient::Response')
47
- mockResponse.stubs(:code).returns(200)
48
- mockResponse.stubs(:body).returns('{"id":"test","name":"Testing Coupon"}')
49
- mockResponse.stubs(:headers).returns({})
50
-
51
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
52
-
53
- coupon = Coupon.new(@client, "test")
54
- coupon.name = "Testing Coupon"
55
- assert_true(coupon.save)
56
-
57
- assert_equal(coupon.name, "Testing Coupon")
58
- end
59
-
60
- should "list all coupons" do
61
- mockResponse = mock('RestClient::Response')
62
- mockResponse.stubs(:code).returns(200)
63
- mockResponse.stubs(:body).returns('[{"id":"test","name":"Test Coupon"}]')
64
- mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/catalog_items?per_page=25&page=1>; rel="self", <https://api.invoiced.com/catalog_items?per_page=25&page=1>; rel="first", <https://api.invoiced.com/catalog_items?per_page=25&page=1>; rel="last"')
65
-
66
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
67
-
68
- coupons, metadata = @client.Coupon.list
69
-
70
- assert_instance_of(Array, coupons)
71
- assert_equal(1, coupons.length)
72
- assert_equal("test", coupons[0].id)
73
-
74
- assert_instance_of(Invoiced::List, metadata)
75
- assert_equal(15, metadata.total_count)
76
- end
77
-
78
- should "delete a coupon" 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
- coupon = Coupon.new(@client, "test")
87
- assert_true(coupon.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 = Coupon
14
+ @endpoint = '/coupons'
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 CreditBalanceAdjustmentTest < 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 = CreditBalanceAdjustment
14
+ @endpoint = '/credit_balance_adjustments'
15
+ end
16
+ end
17
+ end
@@ -2,89 +2,16 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  module Invoiced
4
4
  class CreditNoteTest < Test::Unit::TestCase
5
- should "return the api endpoint" do
6
- creditNote = CreditNote.new(@client, 123)
7
- assert_equal('/credit_notes/123', creditNote.endpoint())
8
- end
9
-
10
- should "create a credit note" do
11
- mockResponse = mock('RestClient::Response')
12
- mockResponse.stubs(:code).returns(201)
13
- mockResponse.stubs(:body).returns('{"id":123,"number":"CN-0001"}')
14
- mockResponse.stubs(:headers).returns({})
15
-
16
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
17
-
18
- creditNote = @client.CreditNote.create({:number => "CN-0001"})
19
-
20
- assert_instance_of(Invoiced::CreditNote, creditNote)
21
- assert_equal(123, creditNote.id)
22
- assert_equal('CN-0001', creditNote.number)
23
- end
24
-
25
- should "retrieve a credit note" do
26
- mockResponse = mock('RestClient::Response')
27
- mockResponse.stubs(:code).returns(200)
28
- mockResponse.stubs(:body).returns('{"id":123,"number":"CN-0001"}')
29
- mockResponse.stubs(:headers).returns({})
30
-
31
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
32
-
33
- creditNote = @client.CreditNote.retrieve(123)
34
-
35
- assert_instance_of(Invoiced::CreditNote, creditNote)
36
- assert_equal(123, creditNote.id)
37
- assert_equal('CN-0001', creditNote.number)
38
- end
39
-
40
- should "not update a credit note when no params" do
41
- creditNote = CreditNote.new(@client, 123)
42
- assert_false(creditNote.save)
43
- end
44
-
45
- should "update a credit note" do
46
- mockResponse = mock('RestClient::Response')
47
- mockResponse.stubs(:code).returns(200)
48
- mockResponse.stubs(:body).returns('{"id":123,"closed":true}')
49
- mockResponse.stubs(:headers).returns({})
50
-
51
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
52
-
53
- creditNote = CreditNote.new(@client, 123)
54
- creditNote.closed = true
55
- assert_true(creditNote.save)
56
-
57
- assert_true(creditNote.closed)
58
- end
59
-
60
- should "list all credit notes" do
61
- mockResponse = mock('RestClient::Response')
62
- mockResponse.stubs(:code).returns(200)
63
- mockResponse.stubs(:body).returns('[{"id":123,"number":"CN-0001"}]')
64
- mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/credit_notes?per_page=25&page=1>; rel="self", <https://api.invoiced.com/credit_notes?per_page=25&page=1>; rel="first", <https://api.invoiced.com/credit_notes?per_page=25&page=1>; rel="last"')
65
-
66
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
67
-
68
- creditNotes, metadata = @client.CreditNote.list
69
-
70
- assert_instance_of(Array, creditNotes)
71
- assert_equal(1, creditNotes.length)
72
- assert_equal(123, creditNotes[0].id)
73
-
74
- assert_instance_of(Invoiced::List, metadata)
75
- assert_equal(15, metadata.total_count)
76
- end
77
-
78
- should "delete a credit note" 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
- creditNote = CreditNote.new(@client, 123)
87
- assert_true(creditNote.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 = CreditNote
14
+ @endpoint = '/credit_notes'
88
15
  end
89
16
 
90
17
  should "send a credit note" do
@@ -0,0 +1,17 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class CustomFieldTest < 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 = CustomField
14
+ @endpoint = '/custom_fields'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class CustomerChasingCadenceTest < 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 = CustomerChasingCadence
14
+ @endpoint = '/customer_chasing_cadences'
15
+ end
16
+ end
17
+ end
@@ -2,89 +2,16 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  module Invoiced
4
4
  class CustomerTest < Test::Unit::TestCase
5
- should "return the api endpoint" do
6
- customer = Customer.new(@client, 123)
7
- assert_equal('/customers/123', customer.endpoint())
8
- end
9
-
10
- should "create a customer" do
11
- mockResponse = mock('RestClient::Response')
12
- mockResponse.stubs(:code).returns(201)
13
- mockResponse.stubs(:body).returns('{"id":123,"name":"Pied Piper"}')
14
- mockResponse.stubs(:headers).returns({})
15
-
16
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
17
-
18
- customer = @client.Customer.create({:name => "Pied Piper"})
19
-
20
- assert_instance_of(Invoiced::Customer, customer)
21
- assert_equal(123, customer.id)
22
- assert_equal('Pied Piper', customer.name)
23
- end
24
-
25
- should "retrieve a customer" do
26
- mockResponse = mock('RestClient::Response')
27
- mockResponse.stubs(:code).returns(200)
28
- mockResponse.stubs(:body).returns('{"id":123,"name":"Pied Piper"}')
29
- mockResponse.stubs(:headers).returns({})
30
-
31
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
32
-
33
- customer = @client.Customer.retrieve(123)
34
-
35
- assert_instance_of(Invoiced::Customer, customer)
36
- assert_equal(123, customer.id)
37
- assert_equal('Pied Piper', customer.name)
38
- end
39
-
40
- should "not update a customer when no params" do
41
- customer = Customer.new(@client, 123)
42
- assert_false(customer.save)
43
- end
44
-
45
- should "update a customer" do
46
- mockResponse = mock('RestClient::Response')
47
- mockResponse.stubs(:code).returns(200)
48
- mockResponse.stubs(:body).returns('{"id":123,"name":"Pied Piper","notes":"Terrible customer"}')
49
- mockResponse.stubs(:headers).returns({})
50
-
51
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
52
-
53
- customer = Customer.new(@client, 123)
54
- customer.notes = 'Terrible customer'
55
- assert_true(customer.save)
56
-
57
- assert_equal("Terrible customer", customer.notes)
58
- end
59
-
60
- should "list all customers" do
61
- mockResponse = mock('RestClient::Response')
62
- mockResponse.stubs(:code).returns(200)
63
- mockResponse.stubs(:body).returns('[{"id":123,"name":"Pied Piper"}]')
64
- mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/customers?per_page=25&page=1>; rel="self", <https://api.invoiced.com/customers?per_page=25&page=1>; rel="first", <https://api.invoiced.com/customers?per_page=25&page=1>; rel="last"')
65
-
66
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
67
-
68
- customers, metadata = @client.Customer.list
69
-
70
- assert_instance_of(Array, customers)
71
- assert_equal(1, customers.length)
72
- assert_equal(123, customers[0].id)
73
-
74
- assert_instance_of(Invoiced::List, metadata)
75
- assert_equal(15, metadata.total_count)
76
- end
77
-
78
- should "delete a customer" 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
- customer = Customer.new(@client, 123)
87
- assert_true(customer.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 = Customer
14
+ @endpoint = '/customers'
88
15
  end
89
16
 
90
17
  should "send an account statement by email" do
@@ -0,0 +1,17 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class EmailTemplateTest < 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 = EmailTemplate
14
+ @endpoint = '/email_templates'
15
+ end
16
+ end
17
+ end
@@ -2,89 +2,16 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  module Invoiced
4
4
  class EstimateTest < Test::Unit::TestCase
5
- should "return the api endpoint" do
6
- estimate = Estimate.new(@client, 123)
7
- assert_equal('/estimates/123', estimate.endpoint())
8
- end
9
-
10
- should "create an estimate" do
11
- mockResponse = mock('RestClient::Response')
12
- mockResponse.stubs(:code).returns(201)
13
- mockResponse.stubs(:body).returns('{"id":123,"number":"EST-0001"}')
14
- mockResponse.stubs(:headers).returns({})
15
-
16
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
17
-
18
- estimate = @client.Estimate.create({:number => "EST-0001"})
19
-
20
- assert_instance_of(Invoiced::Estimate, estimate)
21
- assert_equal(123, estimate.id)
22
- assert_equal('EST-0001', estimate.number)
23
- end
24
-
25
- should "retrieve an estimate" do
26
- mockResponse = mock('RestClient::Response')
27
- mockResponse.stubs(:code).returns(200)
28
- mockResponse.stubs(:body).returns('{"id":123,"number":"EST-0001"}')
29
- mockResponse.stubs(:headers).returns({})
30
-
31
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
32
-
33
- estimate = @client.Estimate.retrieve(123)
34
-
35
- assert_instance_of(Invoiced::Estimate, estimate)
36
- assert_equal(123, estimate.id)
37
- assert_equal('EST-0001', estimate.number)
38
- end
39
-
40
- should "not update an estimate when no params" do
41
- estimate = Estimate.new(@client, 123)
42
- assert_false(estimate.save)
43
- end
44
-
45
- should "update an estimate" do
46
- mockResponse = mock('RestClient::Response')
47
- mockResponse.stubs(:code).returns(200)
48
- mockResponse.stubs(:body).returns('{"id":123,"closed":true}')
49
- mockResponse.stubs(:headers).returns({})
50
-
51
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
52
-
53
- estimate = Estimate.new(@client, 123)
54
- estimate.closed = true
55
- assert_true(estimate.save)
56
-
57
- assert_true(estimate.closed)
58
- end
59
-
60
- should "list all estimates" do
61
- mockResponse = mock('RestClient::Response')
62
- mockResponse.stubs(:code).returns(200)
63
- mockResponse.stubs(:body).returns('[{"id":123,"number":"EST-0001"}]')
64
- mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/estimates?per_page=25&page=1>; rel="self", <https://api.invoiced.com/estimates?per_page=25&page=1>; rel="first", <https://api.invoiced.com/estimates?per_page=25&page=1>; rel="last"')
65
-
66
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
67
-
68
- estimates, metadata = @client.Estimate.list
69
-
70
- assert_instance_of(Array, estimates)
71
- assert_equal(1, estimates.length)
72
- assert_equal(123, estimates[0].id)
73
-
74
- assert_instance_of(Invoiced::List, metadata)
75
- assert_equal(15, metadata.total_count)
76
- end
77
-
78
- should "delete an estimate" 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
- estimate = Estimate.new(@client, 123)
87
- assert_true(estimate.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 = Estimate
14
+ @endpoint = '/estimates'
88
15
  end
89
16
 
90
17
  should "send an estimate" do
@@ -2,28 +2,13 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  module Invoiced
4
4
  class EventTest < Test::Unit::TestCase
5
- should "return the api endpoint" do
6
- event = Event.new(@client, 123)
7
- assert_equal('/events/123', event.endpoint())
8
- end
9
-
10
- should "list all events" do
11
- mockResponse = mock('RestClient::Response')
12
- mockResponse.stubs(:code).returns(200)
13
- mockResponse.stubs(:body).returns('[{"id":123,"type":"customer.created"}]')
14
- mockResponse.stubs(:headers).returns(:x_total_count => 15, :link => '<https://api.invoiced.com/events?per_page=25&page=1>; rel="self", <https://api.invoiced.com/events?per_page=25&page=1>; rel="first", <https://api.invoiced.com/events?per_page=25&page=1>; rel="last"')
15
-
16
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
17
-
18
- events, metadata = @client.Event.list
19
-
20
- assert_instance_of(Array, events)
21
- assert_equal(1, events.length)
22
- assert_instance_of(Invoiced::Event, events[0])
23
- assert_equal(123, events[0].id)
5
+ include Invoiced::Operations::EndpointTest
6
+ include Invoiced::Operations::RetrieveTest
7
+ include Invoiced::Operations::ListTest
24
8
 
25
- assert_instance_of(Invoiced::List, metadata)
26
- assert_equal(15, metadata.total_count)
9
+ setup do
10
+ @objectClass = Event
11
+ @endpoint = '/events'
27
12
  end
28
13
  end
29
14
  end
@@ -2,53 +2,14 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  module Invoiced
4
4
  class FileTest < Test::Unit::TestCase
5
- should "return the api endpoint" do
6
- file = File.new(@client, 123)
7
- assert_equal('/files/123', file.endpoint())
8
- end
9
-
10
- should "create a file" do
11
- mockResponse = mock('RestClient::Response')
12
- mockResponse.stubs(:code).returns(201)
13
- mockResponse.stubs(:body).returns('{"id":123,"name":"Filename"}')
14
- mockResponse.stubs(:headers).returns({})
15
-
16
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
17
-
18
- file = File.new(@client)
19
- file = file.create({:name => "Filename"})
20
-
21
- assert_instance_of(Invoiced::File, file)
22
- assert_equal(123, file.id)
23
- assert_equal("Filename", file.name)
24
- end
25
-
26
- should "retrieve a file" do
27
- mockResponse = mock('RestClient::Response')
28
- mockResponse.stubs(:code).returns(200)
29
- mockResponse.stubs(:body).returns('{"id":123,"name":"Filename"}')
30
- mockResponse.stubs(:headers).returns({})
31
-
32
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
33
-
34
- file = File.new(@client)
35
- file = file.retrieve(123)
36
-
37
- assert_instance_of(Invoiced::File, file)
38
- assert_equal(123, file.id)
39
- assert_equal("Filename", file.name)
40
- end
41
-
42
- should "delete a file" do
43
- mockResponse = mock('RestClient::Response')
44
- mockResponse.stubs(:code).returns(204)
45
- mockResponse.stubs(:body).returns('')
46
- mockResponse.stubs(:headers).returns({})
47
-
48
- RestClient::Request.any_instance.expects(:execute).returns(mockResponse)
49
-
50
- file = File.new(@client, 123)
51
- assert_true(file.delete)
5
+ include Invoiced::Operations::EndpointTest
6
+ include Invoiced::Operations::CreateTest
7
+ include Invoiced::Operations::RetrieveTest
8
+ include Invoiced::Operations::DeleteTest
9
+
10
+ setup do
11
+ @objectClass = File
12
+ @endpoint = '/files'
52
13
  end
53
14
  end
54
15
  end
@@ -0,0 +1,17 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class GlAccountTest < 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 = GlAccount
14
+ @endpoint = '/gl_accounts'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class InboxTest < Test::Unit::TestCase
5
+ include Invoiced::Operations::EndpointTest
6
+ include Invoiced::Operations::ListTest
7
+
8
+ setup do
9
+ @objectClass = Inbox
10
+ @endpoint = '/inboxes'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Invoiced
4
+ class InvoiceChasingCadenceTest < 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 = InvoiceChasingCadence
14
+ @endpoint = '/invoice_chasing_cadences'
15
+ end
16
+ end
17
+ end