quaderno 1.0.0 → 1.1.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.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/build_install.sh +2 -2
- data/lib/quaderno-ruby/behavior/crud.rb +7 -3
- data/lib/quaderno-ruby/document_item.rb +4 -0
- data/lib/quaderno-ruby/item.rb +6 -2
- data/lib/quaderno-ruby.rb +1 -1
- data/quaderno-1.0.0.gem +0 -0
- data/{quaderno-ruby.gemspec → quaderno.gemspec} +14 -6
- data/test/fixtures/quaderno_cassettes/all_contacts.yml +14 -12
- data/test/fixtures/quaderno_cassettes/all_estimates.yml +14 -10
- data/test/fixtures/quaderno_cassettes/all_expenses.yml +14 -10
- data/test/fixtures/quaderno_cassettes/all_invoices.yml +25 -10
- data/test/fixtures/quaderno_cassettes/all_items.yml +42 -0
- data/test/fixtures/quaderno_cassettes/deleted_contact.yml +75 -31
- data/test/fixtures/quaderno_cassettes/deleted_estimate.yml +74 -27
- data/test/fixtures/quaderno_cassettes/deleted_expense.yml +74 -27
- data/test/fixtures/quaderno_cassettes/deleted_invoice.yml +85 -28
- data/test/fixtures/quaderno_cassettes/deleted_item.yml +119 -0
- data/test/fixtures/quaderno_cassettes/delivered_estimate.yml +30 -29
- data/test/fixtures/quaderno_cassettes/delivered_invoice.yml +41 -29
- data/test/fixtures/quaderno_cassettes/found_contact.yml +22 -22
- data/test/fixtures/quaderno_cassettes/found_estimate.yml +24 -20
- data/test/fixtures/quaderno_cassettes/found_expense.yml +22 -20
- data/test/fixtures/quaderno_cassettes/found_invoice.yml +34 -20
- data/test/fixtures/quaderno_cassettes/found_item.yml +81 -0
- data/test/fixtures/quaderno_cassettes/new_contact.yml +10 -12
- data/test/fixtures/quaderno_cassettes/new_estimate.yml +63 -25
- data/test/fixtures/quaderno_cassettes/new_expense.yml +77 -35
- data/test/fixtures/quaderno_cassettes/new_invoice.yml +63 -25
- data/test/fixtures/quaderno_cassettes/new_item.yml +42 -0
- data/test/fixtures/quaderno_cassettes/paid_expense.yml +25 -23
- data/test/fixtures/quaderno_cassettes/paid_invoice.yml +36 -24
- data/test/fixtures/quaderno_cassettes/rate_limit.yml +6 -8
- data/test/fixtures/quaderno_cassettes/unpay_an_expense.yml +32 -30
- data/test/fixtures/quaderno_cassettes/unpay_an_invoice.yml +43 -30
- data/test/fixtures/quaderno_cassettes/updated_contact.yml +22 -22
- data/test/fixtures/quaderno_cassettes/updated_estimate.yml +100 -21
- data/test/fixtures/quaderno_cassettes/updated_expense.yml +99 -20
- data/test/fixtures/quaderno_cassettes/updated_invoice.yml +100 -21
- data/test/fixtures/quaderno_cassettes/updated_item.yml +81 -0
- data/test/unit/test_quaderno_contacts.rb +5 -4
- data/test/unit/test_quaderno_estimates.rb +37 -9
- data/test/unit/test_quaderno_expenses.rb +38 -14
- data/test/unit/test_quaderno_invoices.rb +40 -12
- data/test/unit/test_quaderno_items.rb +82 -0
- metadata +12 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://n8sDLUZ5z1d6dYXKixnx@localhost:3000/recrea/api/v1/items.json
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
authorization:
|
|
11
|
+
- Basic bjhzRExVWjV6MWQ2ZFlYS2l4bng6
|
|
12
|
+
response:
|
|
13
|
+
status:
|
|
14
|
+
code: 200
|
|
15
|
+
message: OK
|
|
16
|
+
headers:
|
|
17
|
+
x-ratelimit-limit:
|
|
18
|
+
- '1000'
|
|
19
|
+
x-ratelimit-remaining:
|
|
20
|
+
- '827'
|
|
21
|
+
content-type:
|
|
22
|
+
- application/json; charset=utf-8
|
|
23
|
+
x-ua-compatible:
|
|
24
|
+
- IE=Edge
|
|
25
|
+
etag:
|
|
26
|
+
- ! '"a55a5c75cee2f6b8eeca35cec8ed8fe8"'
|
|
27
|
+
cache-control:
|
|
28
|
+
- max-age=0, private, must-revalidate
|
|
29
|
+
x-request-id:
|
|
30
|
+
- f21eb3d72a6394732bef496afba7eb00
|
|
31
|
+
x-runtime:
|
|
32
|
+
- '0.141288'
|
|
33
|
+
connection:
|
|
34
|
+
- close
|
|
35
|
+
server:
|
|
36
|
+
- thin 1.5.0 codename Knife
|
|
37
|
+
body:
|
|
38
|
+
encoding: US-ASCII
|
|
39
|
+
string: ! '[{"id":4,"code":"00001","name":"Airdrone","unit_cost":"0.0","url":"http://localhost:3000/recrea/api/v1/items/4"},{"id":6,"code":"XXXXXXXX","name":"byAPI","unit_cost":"0.0","url":"http://localhost:3000/recrea/api/v1/items/6"},{"id":1,"code":"00001","name":"Test_OCP","unit_cost":"1.0","url":"http://localhost:3000/recrea/api/v1/items/1"},{"id":3,"code":"00001","name":"Test_OCP","unit_cost":"10.0","tax_1_name":"IVA","tax_1_rate":21.0,"tax_2_name":"IRPF","tax_2_rate":-9.0,"url":"http://localhost:3000/recrea/api/v1/items/3"},{"id":5,"code":"FF","name":"Test_OCP","unit_cost":"0.0","tax_1_name":"IVA","tax_1_rate":21.0,"tax_2_name":"IRPF","tax_2_rate":-21.0,"url":"http://localhost:3000/recrea/api/v1/items/5"},{"id":7,"code":"XXXXXXXX","name":"Test_OCP","unit_cost":"0.0","url":"http://localhost:3000/recrea/api/v1/items/7"},{"id":8,"code":"XXXXXXXX","name":"Test_OCP","unit_cost":"0.0","url":"http://localhost:3000/recrea/api/v1/items/8"},{"id":9,"code":"XXXXXXXX","name":"Test_OCP","unit_cost":"0.0","url":"http://localhost:3000/recrea/api/v1/items/9"},{"id":10,"code":"XXXXXXXX","name":"Test_OCP","unit_cost":"10.0","url":"http://localhost:3000/recrea/api/v1/items/10"},{"id":11,"code":"XXXXXXXX","name":"Test_OCP","unit_cost":"10.0","url":"http://localhost:3000/recrea/api/v1/items/11"},{"id":17,"code":"000000","name":"Test_Skynet","unit_cost":"21.0","url":"http://localhost:3000/recrea/api/v1/items/17"}]'
|
|
40
|
+
http_version: '1.1'
|
|
41
|
+
recorded_at: Tue, 14 May 2013 10:49:15 GMT
|
|
42
|
+
- request:
|
|
43
|
+
method: put
|
|
44
|
+
uri: http://n8sDLUZ5z1d6dYXKixnx@localhost:3000/recrea/api/v1/items/1.json
|
|
45
|
+
body:
|
|
46
|
+
encoding: US-ASCII
|
|
47
|
+
string: name=Test_OCP
|
|
48
|
+
headers:
|
|
49
|
+
authorization:
|
|
50
|
+
- Basic bjhzRExVWjV6MWQ2ZFlYS2l4bng6
|
|
51
|
+
response:
|
|
52
|
+
status:
|
|
53
|
+
code: 200
|
|
54
|
+
message: OK
|
|
55
|
+
headers:
|
|
56
|
+
x-ratelimit-limit:
|
|
57
|
+
- '1000'
|
|
58
|
+
x-ratelimit-remaining:
|
|
59
|
+
- '826'
|
|
60
|
+
content-type:
|
|
61
|
+
- application/json; charset=utf-8
|
|
62
|
+
x-ua-compatible:
|
|
63
|
+
- IE=Edge
|
|
64
|
+
etag:
|
|
65
|
+
- ! '"6df0b7ce66846edbad36a13a946d1e24"'
|
|
66
|
+
cache-control:
|
|
67
|
+
- max-age=0, private, must-revalidate
|
|
68
|
+
x-request-id:
|
|
69
|
+
- 0a28380e54a2b40858ca85cb7516856f
|
|
70
|
+
x-runtime:
|
|
71
|
+
- '0.090845'
|
|
72
|
+
connection:
|
|
73
|
+
- close
|
|
74
|
+
server:
|
|
75
|
+
- thin 1.5.0 codename Knife
|
|
76
|
+
body:
|
|
77
|
+
encoding: US-ASCII
|
|
78
|
+
string: ! '{"id":1,"code":"00001","name":"Test_OCP","unit_cost":"1.0","url":"http://localhost:3000/recrea/api/v1/items/1"}'
|
|
79
|
+
http_version: '1.1'
|
|
80
|
+
recorded_at: Tue, 14 May 2013 10:49:15 GMT
|
|
81
|
+
recorded_with: VCR 2.3.0
|
|
@@ -5,7 +5,7 @@ class TestQuadernoContact < Test::Unit::TestCase
|
|
|
5
5
|
|
|
6
6
|
setup do
|
|
7
7
|
Quaderno::Base.configure do |config|
|
|
8
|
-
config.auth_token = '
|
|
8
|
+
config.auth_token = 'n8sDLUZ5z1d6dYXKixnx'
|
|
9
9
|
config.subdomain = 'recrea'
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -13,7 +13,7 @@ class TestQuadernoContact < Test::Unit::TestCase
|
|
|
13
13
|
should "get exception if pass wrong arguments" do
|
|
14
14
|
assert_raise ArgumentError do
|
|
15
15
|
VCR.use_cassette('all contacts') do
|
|
16
|
-
Quaderno::Contact.all 1
|
|
16
|
+
Quaderno::Contact.all 1, 2, 3
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
assert_raise ArgumentError do
|
|
@@ -67,11 +67,12 @@ class TestQuadernoContact < Test::Unit::TestCase
|
|
|
67
67
|
|
|
68
68
|
should "delete a contact" do
|
|
69
69
|
VCR.use_cassette('deleted contact') do
|
|
70
|
+
new_contact = Quaderno::Contact.create(kind: 'company', first_name: 'Z, Mazinger Z', email: 'koji@kabuto.ftw')
|
|
70
71
|
contacts_before = Quaderno::Contact.all
|
|
71
|
-
contact_id = contacts_before
|
|
72
|
+
contact_id = contacts_before.last.id
|
|
72
73
|
Quaderno::Contact.delete contact_id
|
|
73
74
|
contacts_after = Quaderno::Contact.all
|
|
74
|
-
assert_not_equal contacts_after
|
|
75
|
+
assert_not_equal contacts_after.last.id, contact_id
|
|
75
76
|
end
|
|
76
77
|
end
|
|
77
78
|
|
|
@@ -5,7 +5,7 @@ class TestQuadernoEstimate < Test::Unit::TestCase
|
|
|
5
5
|
|
|
6
6
|
setup do
|
|
7
7
|
Quaderno::Base.configure do |config|
|
|
8
|
-
config.auth_token = '
|
|
8
|
+
config.auth_token = 'n8sDLUZ5z1d6dYXKixnx'
|
|
9
9
|
config.subdomain = 'recrea'
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -13,7 +13,7 @@ class TestQuadernoEstimate < Test::Unit::TestCase
|
|
|
13
13
|
should 'get exception if pass wrong arguments' do
|
|
14
14
|
assert_raise ArgumentError do
|
|
15
15
|
VCR.use_cassette('all estimates') do
|
|
16
|
-
Quaderno::Estimate.all 1
|
|
16
|
+
Quaderno::Estimate.all 1, 2, 3
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
assert_raise ArgumentError do
|
|
@@ -47,9 +47,10 @@ class TestQuadernoEstimate < Test::Unit::TestCase
|
|
|
47
47
|
VCR.use_cassette('new estimate') do
|
|
48
48
|
contacts = Quaderno::Contact.all
|
|
49
49
|
estimate = Quaderno::Estimate.create(contact_id: contacts.first.id ,
|
|
50
|
+
number: 'test number 42',
|
|
50
51
|
contact_name: contacts.first.full_name,
|
|
51
52
|
currency: 'EUR',
|
|
52
|
-
|
|
53
|
+
items_attributes: [
|
|
53
54
|
{
|
|
54
55
|
description: 'Aircraft',
|
|
55
56
|
quantity: '1.0',
|
|
@@ -61,25 +62,52 @@ class TestQuadernoEstimate < Test::Unit::TestCase
|
|
|
61
62
|
assert_kind_of Quaderno::Estimate, estimate
|
|
62
63
|
assert_equal contacts.first.id, estimate.contact.id
|
|
63
64
|
assert_equal 'Aircraft', estimate.items.first.description
|
|
65
|
+
Quaderno::Estimate.delete(estimate.id)
|
|
64
66
|
end
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
should 'update an estimate' do
|
|
68
70
|
VCR.use_cassette('updated estimate') do
|
|
69
|
-
|
|
70
|
-
estimate = Quaderno::Estimate.
|
|
71
|
+
contacts = Quaderno::Contact.all
|
|
72
|
+
estimate = Quaderno::Estimate.create(contact_id: contacts.first.id,
|
|
73
|
+
number: 'test number 4400',
|
|
74
|
+
contact_name: contacts.first.full_name,
|
|
75
|
+
currency: 'EUR',
|
|
76
|
+
items_attributes: [
|
|
77
|
+
{
|
|
78
|
+
description: 'Aircraft',
|
|
79
|
+
quantity: '1.0',
|
|
80
|
+
unit_price: '0.0'
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
tags: 'tnt', payment_details: '',
|
|
84
|
+
notes: '')
|
|
85
|
+
estimate = Quaderno::Estimate.update(estimate.id, payment_details: 'Show me the moneeeeeeeyy!!!!')
|
|
71
86
|
assert_kind_of Quaderno::Estimate, estimate
|
|
72
87
|
assert_equal 'Show me the moneeeeeeeyy!!!!', estimate.payment_details
|
|
88
|
+
Quaderno::Estimate.delete(estimate.id)
|
|
73
89
|
end
|
|
74
90
|
end
|
|
75
91
|
|
|
76
92
|
should 'delete an estimate' do
|
|
77
93
|
VCR.use_cassette('deleted estimate') do
|
|
94
|
+
contacts = Quaderno::Contact.all
|
|
95
|
+
estimate = Quaderno::Estimate.create(contact_id: contacts.first.id,
|
|
96
|
+
number: 'test number 4400',
|
|
97
|
+
contact_name: contacts.first.full_name,
|
|
98
|
+
currency: 'EUR',
|
|
99
|
+
items_attributes: [
|
|
100
|
+
{
|
|
101
|
+
description: 'Aircraft',
|
|
102
|
+
quantity: '1.0',
|
|
103
|
+
unit_price: '0.0'
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
tags: 'tnt', payment_details: '',
|
|
107
|
+
notes: '')
|
|
108
|
+
Quaderno::Estimate.delete estimate.id
|
|
78
109
|
estimates = Quaderno::Estimate.all
|
|
79
|
-
|
|
80
|
-
Quaderno::Estimate.delete estimate_id
|
|
81
|
-
estimates = Quaderno::Estimate.all
|
|
82
|
-
assert_not_equal estimates.first.id, estimate_id
|
|
110
|
+
assert_not_equal estimates.first.id, estimate.id
|
|
83
111
|
end
|
|
84
112
|
end
|
|
85
113
|
|
|
@@ -5,7 +5,7 @@ class TestQuadernoExpense < Test::Unit::TestCase
|
|
|
5
5
|
|
|
6
6
|
setup do
|
|
7
7
|
Quaderno::Base.configure do |config|
|
|
8
|
-
config.auth_token = '
|
|
8
|
+
config.auth_token = 'n8sDLUZ5z1d6dYXKixnx'
|
|
9
9
|
config.subdomain = 'recrea'
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -13,7 +13,7 @@ class TestQuadernoExpense < Test::Unit::TestCase
|
|
|
13
13
|
should 'get exception if pass wrong arguments' do
|
|
14
14
|
assert_raise ArgumentError do
|
|
15
15
|
VCR.use_cassette('all expenses') do
|
|
16
|
-
Quaderno::Expense.all 1
|
|
16
|
+
Quaderno::Expense.all 1, 2, 3
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
assert_raise ArgumentError do
|
|
@@ -47,11 +47,10 @@ class TestQuadernoExpense < Test::Unit::TestCase
|
|
|
47
47
|
VCR.use_cassette('new expense') do
|
|
48
48
|
expenses = Quaderno::Expense.all
|
|
49
49
|
contacts = Quaderno::Contact.all
|
|
50
|
-
expense = Quaderno::Expense.create(
|
|
51
|
-
contact_id: contacts.first.id ,
|
|
50
|
+
expense = Quaderno::Expense.create(contact_id: contacts.first.id ,
|
|
52
51
|
contact_name: contacts.first.full_name,
|
|
53
52
|
currency: 'EUR',
|
|
54
|
-
|
|
53
|
+
items_attributes: [
|
|
55
54
|
{
|
|
56
55
|
description: 'Aircraft',
|
|
57
56
|
quantity: '1.0',
|
|
@@ -63,35 +62,60 @@ class TestQuadernoExpense < Test::Unit::TestCase
|
|
|
63
62
|
assert_kind_of Quaderno::Expense, expense
|
|
64
63
|
assert_equal contacts.first.id, expense.contact.id
|
|
65
64
|
assert_equal 'Aircraft', expense.items.first.description
|
|
65
|
+
Quaderno::Expense.delete(expense.id)
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
should 'update an expense' do
|
|
70
70
|
VCR.use_cassette('updated expense') do
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
contacts = Quaderno::Contact.all
|
|
72
|
+
expense = Quaderno::Expense.create(contact_id: contacts.first.id ,
|
|
73
|
+
contact_name: contacts.first.full_name,
|
|
74
|
+
currency: 'EUR',
|
|
75
|
+
items_attributes: [
|
|
76
|
+
{
|
|
77
|
+
description: 'Aircraft',
|
|
78
|
+
quantity: '1.0',
|
|
79
|
+
unit_price: '0.0'
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
tags: 'tnt', payment_details: '',
|
|
83
|
+
notes: '')
|
|
84
|
+
expense = Quaderno::Expense.update(expense.id, currency: 'USD')
|
|
73
85
|
assert_kind_of Quaderno::Expense, expense
|
|
74
86
|
assert_equal 'USD', expense.currency
|
|
87
|
+
Quaderno::Expense.delete(expense.id)
|
|
75
88
|
end
|
|
76
89
|
end
|
|
77
90
|
|
|
78
91
|
should 'delete an expense' do
|
|
79
92
|
VCR.use_cassette('deleted expense') do
|
|
93
|
+
contacts = Quaderno::Contact.all
|
|
94
|
+
expense = Quaderno::Expense.create(contact_id: contacts.first.id ,
|
|
95
|
+
contact_name: contacts.first.full_name,
|
|
96
|
+
currency: 'EUR',
|
|
97
|
+
items_attributes: [
|
|
98
|
+
{
|
|
99
|
+
description: 'Aircraft',
|
|
100
|
+
quantity: '1.0',
|
|
101
|
+
unit_price: '0.0'
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
tags: 'tnt', payment_details: '',
|
|
105
|
+
notes: '')
|
|
106
|
+
Quaderno::Expense.delete expense.id
|
|
80
107
|
expenses = Quaderno::Expense.all
|
|
81
|
-
|
|
82
|
-
Quaderno::Expense.delete expense_id
|
|
83
|
-
expenses = Quaderno::Expense.all
|
|
84
|
-
assert_not_equal expenses.first.id, expense_id
|
|
108
|
+
assert_not_equal expenses.first.id, expense.id
|
|
85
109
|
end
|
|
86
110
|
end
|
|
87
111
|
|
|
88
112
|
should 'add a payment' do
|
|
89
113
|
VCR.use_cassette('paid expense') do
|
|
90
114
|
expenses = Quaderno::Expense.all
|
|
91
|
-
payment = expenses.first.add_payment(payment_method: "cash",
|
|
115
|
+
payment = expenses.first.add_payment(payment_method: "cash", amount: "10000")
|
|
92
116
|
assert_kind_of Quaderno::Payment, payment
|
|
93
117
|
assert_equal "cash", payment.payment_method
|
|
94
|
-
assert_equal "
|
|
118
|
+
assert_equal "10,000.00", payment.amount[1..-1]
|
|
95
119
|
assert_equal expenses.first.payments.last.id, payment.id
|
|
96
120
|
end
|
|
97
121
|
end
|
|
@@ -99,7 +123,7 @@ class TestQuadernoExpense < Test::Unit::TestCase
|
|
|
99
123
|
should 'remove a payment' do
|
|
100
124
|
VCR.use_cassette('unpay an expense') do
|
|
101
125
|
expenses = Quaderno::Expense.all
|
|
102
|
-
expenses.first.add_payment(payment_method: "cash",
|
|
126
|
+
expenses.first.add_payment(payment_method: "cash", amount: "10000")
|
|
103
127
|
payment = expenses.first.payments.last
|
|
104
128
|
array_length = expenses.first.payments.length
|
|
105
129
|
expenses.first.remove_payment(payment.id) unless payment.nil?
|
|
@@ -5,7 +5,7 @@ class TestQuadernoInvoice < Test::Unit::TestCase
|
|
|
5
5
|
|
|
6
6
|
setup do
|
|
7
7
|
Quaderno::Base.configure do |config|
|
|
8
|
-
config.auth_token = '
|
|
8
|
+
config.auth_token = 'n8sDLUZ5z1d6dYXKixnx'
|
|
9
9
|
config.subdomain = 'recrea'
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -13,7 +13,7 @@ class TestQuadernoInvoice < Test::Unit::TestCase
|
|
|
13
13
|
should 'get exception if pass wrong arguments' do
|
|
14
14
|
assert_raise ArgumentError do
|
|
15
15
|
VCR.use_cassette('all invoices') do
|
|
16
|
-
Quaderno::Invoice.all 1
|
|
16
|
+
Quaderno::Invoice.all 1, 2, 3
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
assert_raise ArgumentError do
|
|
@@ -49,37 +49,65 @@ class TestQuadernoInvoice < Test::Unit::TestCase
|
|
|
49
49
|
invoice = Quaderno::Invoice.create(contact_id: contacts[0].id ,
|
|
50
50
|
contact_name: contacts[0].full_name,
|
|
51
51
|
currency: 'EUR',
|
|
52
|
-
|
|
52
|
+
items_attributes: [
|
|
53
53
|
{
|
|
54
54
|
description: 'Aircraft',
|
|
55
55
|
quantity: '1.0',
|
|
56
56
|
unit_price: '0.0'
|
|
57
57
|
}
|
|
58
58
|
],
|
|
59
|
-
tags: 'tnt',
|
|
59
|
+
tags: 'tnt',
|
|
60
|
+
payment_details: '',
|
|
60
61
|
notes: '')
|
|
61
62
|
assert_kind_of Quaderno::Invoice, invoice
|
|
62
63
|
assert_equal contacts[0].id, invoice.contact.id
|
|
63
64
|
assert_equal 'Aircraft', invoice.items[0].description
|
|
65
|
+
Quaderno::Invoice.delete(invoice.id)
|
|
64
66
|
end
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
should 'update an invoice' do
|
|
68
70
|
VCR.use_cassette('updated invoice') do
|
|
69
|
-
|
|
70
|
-
invoice = Quaderno::Invoice.
|
|
71
|
+
contacts = Quaderno::Contact.all
|
|
72
|
+
invoice = Quaderno::Invoice.create(contact_id: contacts[0].id ,
|
|
73
|
+
contact_name: contacts[0].full_name,
|
|
74
|
+
currency: 'EUR',
|
|
75
|
+
items_attributes: [
|
|
76
|
+
{
|
|
77
|
+
description: 'Aircraft',
|
|
78
|
+
quantity: '1.0',
|
|
79
|
+
unit_price: '0.0'
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
tags: 'tnt',
|
|
83
|
+
payment_details: '',
|
|
84
|
+
notes: '')
|
|
85
|
+
invoice = Quaderno::Invoice.update(invoice.id, payment_details: 'Show me the moneeeeeeeyy!!!!')
|
|
71
86
|
assert_kind_of Quaderno::Invoice, invoice
|
|
72
87
|
assert_equal 'Show me the moneeeeeeeyy!!!!', invoice.payment_details
|
|
88
|
+
Quaderno::Invoice.delete(invoice.id)
|
|
73
89
|
end
|
|
74
90
|
end
|
|
75
91
|
|
|
76
92
|
should 'delete an invoice' do
|
|
77
93
|
VCR.use_cassette('deleted invoice') do
|
|
94
|
+
contacts = Quaderno::Contact.all
|
|
95
|
+
invoice = Quaderno::Invoice.create(contact_id: contacts[0].id ,
|
|
96
|
+
contact_name: contacts[0].full_name,
|
|
97
|
+
currency: 'EUR',
|
|
98
|
+
items_attributes: [
|
|
99
|
+
{
|
|
100
|
+
description: 'Aircraft',
|
|
101
|
+
quantity: '1.0',
|
|
102
|
+
unit_price: '0.0'
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
tags: 'tnt',
|
|
106
|
+
payment_details: '',
|
|
107
|
+
notes: '')
|
|
108
|
+
Quaderno::Invoice.delete invoice.id
|
|
78
109
|
invoices = Quaderno::Invoice.all
|
|
79
|
-
|
|
80
|
-
Quaderno::Invoice.delete invoice_id
|
|
81
|
-
invoices = Quaderno::Invoice.all
|
|
82
|
-
assert_not_equal invoices.first.id, invoice_id
|
|
110
|
+
assert_not_equal invoices.first.id, invoice.id
|
|
83
111
|
end
|
|
84
112
|
end
|
|
85
113
|
|
|
@@ -99,7 +127,7 @@ class TestQuadernoInvoice < Test::Unit::TestCase
|
|
|
99
127
|
should 'add a payment' do
|
|
100
128
|
VCR.use_cassette('paid invoice') do
|
|
101
129
|
invoices = Quaderno::Invoice.all
|
|
102
|
-
payment = invoices.first.add_payment(payment_method: "cash",
|
|
130
|
+
payment = invoices.first.add_payment(payment_method: "cash", amount: "100000000")
|
|
103
131
|
assert_kind_of Quaderno::Payment, payment
|
|
104
132
|
assert_equal "cash", payment.payment_method
|
|
105
133
|
assert_equal "100,000,000.00", payment.amount[1..-1]
|
|
@@ -110,7 +138,7 @@ class TestQuadernoInvoice < Test::Unit::TestCase
|
|
|
110
138
|
should 'remove a payment' do
|
|
111
139
|
VCR.use_cassette('unpay an invoice') do
|
|
112
140
|
invoices = Quaderno::Invoice.all
|
|
113
|
-
invoices.first.add_payment(payment_method: "cash",
|
|
141
|
+
invoices.first.add_payment(payment_method: "cash", amount: "100000000")
|
|
114
142
|
payment = invoices.first.payments.last
|
|
115
143
|
array_length = invoices.first.payments.length
|
|
116
144
|
invoices.first.remove_payment(payment.id) unless payment.nil?
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestQuadernoItem < Test::Unit::TestCase
|
|
4
|
+
context "A user with an authenticate token with items" do
|
|
5
|
+
|
|
6
|
+
setup do
|
|
7
|
+
Quaderno::Base.configure do |config|
|
|
8
|
+
config.auth_token = 'n8sDLUZ5z1d6dYXKixnx'
|
|
9
|
+
config.subdomain = 'recrea'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
should "get exception if pass wrong arguments" do
|
|
14
|
+
assert_raise ArgumentError do
|
|
15
|
+
VCR.use_cassette('all items') do
|
|
16
|
+
Quaderno::Item.all 1, 2, 3
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
assert_raise ArgumentError do
|
|
20
|
+
VCR.use_cassette('found item') do
|
|
21
|
+
Quaderno::Item.find
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
should "get all items (populated db)" do
|
|
27
|
+
VCR.use_cassette('all items') do
|
|
28
|
+
items = Quaderno::Item.all
|
|
29
|
+
assert_not_nil items
|
|
30
|
+
assert_kind_of Array, items
|
|
31
|
+
items.each do |item|
|
|
32
|
+
assert_kind_of Quaderno::Item, item
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
should "find an item" do
|
|
38
|
+
VCR.use_cassette('found item') do
|
|
39
|
+
items = Quaderno::Item.all
|
|
40
|
+
item = Quaderno::Item.find items[2].id
|
|
41
|
+
assert_kind_of Quaderno::Item, item
|
|
42
|
+
assert_equal items[2].id, item.id
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
should "create an item" do
|
|
47
|
+
VCR.use_cassette('new item') do
|
|
48
|
+
item = Quaderno::Item.create(code: '000000', name: 'Test_Skynet', unit_cost: 21.00)
|
|
49
|
+
assert_kind_of Quaderno::Item, item
|
|
50
|
+
assert_equal '000000', item.code
|
|
51
|
+
assert_equal 'Test_Skynet', item.name
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
should "update an item" do
|
|
56
|
+
VCR.use_cassette('updated item') do
|
|
57
|
+
items = Quaderno::Item.all
|
|
58
|
+
item = Quaderno::Item.update(items[2].id, name: 'Test_OCP')
|
|
59
|
+
assert_kind_of Quaderno::Item, item
|
|
60
|
+
assert_equal 'Test_OCP', item.name
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
should "delete a item" do
|
|
65
|
+
VCR.use_cassette('deleted item') do
|
|
66
|
+
items_before = Quaderno::Item.all
|
|
67
|
+
item_id = items_before.last.id
|
|
68
|
+
Quaderno::Item.delete item_id
|
|
69
|
+
items_after = Quaderno::Item.all
|
|
70
|
+
assert_not_equal items_after.last.id, item_id
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
should "know the rate limit" do
|
|
75
|
+
VCR.use_cassette('rate limit') do
|
|
76
|
+
rate_limit_info = Quaderno::Base.rate_limit_info
|
|
77
|
+
assert_equal 1000, rate_limit_info[:limit]
|
|
78
|
+
assert_operator rate_limit_info[:remaining], :< ,1000
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: quaderno
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-05-
|
|
12
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -161,31 +161,37 @@ files:
|
|
|
161
161
|
- lib/quaderno-ruby/behavior/deliver.rb
|
|
162
162
|
- lib/quaderno-ruby/behavior/payment.rb
|
|
163
163
|
- lib/quaderno-ruby/contact.rb
|
|
164
|
+
- lib/quaderno-ruby/document_item.rb
|
|
164
165
|
- lib/quaderno-ruby/estimate.rb
|
|
165
166
|
- lib/quaderno-ruby/exceptions/exceptions.rb
|
|
166
167
|
- lib/quaderno-ruby/expense.rb
|
|
167
168
|
- lib/quaderno-ruby/invoice.rb
|
|
168
169
|
- lib/quaderno-ruby/item.rb
|
|
169
170
|
- lib/quaderno-ruby/payment.rb
|
|
170
|
-
- quaderno-
|
|
171
|
+
- quaderno-1.0.0.gem
|
|
172
|
+
- quaderno.gemspec
|
|
171
173
|
- test/fixtures/quaderno_cassettes/all_contacts.yml
|
|
172
174
|
- test/fixtures/quaderno_cassettes/all_estimates.yml
|
|
173
175
|
- test/fixtures/quaderno_cassettes/all_expenses.yml
|
|
174
176
|
- test/fixtures/quaderno_cassettes/all_invoices.yml
|
|
177
|
+
- test/fixtures/quaderno_cassettes/all_items.yml
|
|
175
178
|
- test/fixtures/quaderno_cassettes/deleted_contact.yml
|
|
176
179
|
- test/fixtures/quaderno_cassettes/deleted_estimate.yml
|
|
177
180
|
- test/fixtures/quaderno_cassettes/deleted_expense.yml
|
|
178
181
|
- test/fixtures/quaderno_cassettes/deleted_invoice.yml
|
|
182
|
+
- test/fixtures/quaderno_cassettes/deleted_item.yml
|
|
179
183
|
- test/fixtures/quaderno_cassettes/delivered_estimate.yml
|
|
180
184
|
- test/fixtures/quaderno_cassettes/delivered_invoice.yml
|
|
181
185
|
- test/fixtures/quaderno_cassettes/found_contact.yml
|
|
182
186
|
- test/fixtures/quaderno_cassettes/found_estimate.yml
|
|
183
187
|
- test/fixtures/quaderno_cassettes/found_expense.yml
|
|
184
188
|
- test/fixtures/quaderno_cassettes/found_invoice.yml
|
|
189
|
+
- test/fixtures/quaderno_cassettes/found_item.yml
|
|
185
190
|
- test/fixtures/quaderno_cassettes/new_contact.yml
|
|
186
191
|
- test/fixtures/quaderno_cassettes/new_estimate.yml
|
|
187
192
|
- test/fixtures/quaderno_cassettes/new_expense.yml
|
|
188
193
|
- test/fixtures/quaderno_cassettes/new_invoice.yml
|
|
194
|
+
- test/fixtures/quaderno_cassettes/new_item.yml
|
|
189
195
|
- test/fixtures/quaderno_cassettes/paid_expense.yml
|
|
190
196
|
- test/fixtures/quaderno_cassettes/paid_invoice.yml
|
|
191
197
|
- test/fixtures/quaderno_cassettes/rate_limit.yml
|
|
@@ -195,12 +201,14 @@ files:
|
|
|
195
201
|
- test/fixtures/quaderno_cassettes/updated_estimate.yml
|
|
196
202
|
- test/fixtures/quaderno_cassettes/updated_expense.yml
|
|
197
203
|
- test/fixtures/quaderno_cassettes/updated_invoice.yml
|
|
204
|
+
- test/fixtures/quaderno_cassettes/updated_item.yml
|
|
198
205
|
- test/helper.rb
|
|
199
206
|
- test/test_quaderno-ruby.rb
|
|
200
207
|
- test/unit/test_quaderno_contacts.rb
|
|
201
208
|
- test/unit/test_quaderno_estimates.rb
|
|
202
209
|
- test/unit/test_quaderno_expenses.rb
|
|
203
210
|
- test/unit/test_quaderno_invoices.rb
|
|
211
|
+
- test/unit/test_quaderno_items.rb
|
|
204
212
|
homepage: http://github.com/recrea/quaderno-ruby
|
|
205
213
|
licenses:
|
|
206
214
|
- MIT
|
|
@@ -216,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
216
224
|
version: '0'
|
|
217
225
|
segments:
|
|
218
226
|
- 0
|
|
219
|
-
hash:
|
|
227
|
+
hash: 1399084077957568219
|
|
220
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
229
|
none: false
|
|
222
230
|
requirements:
|