quaderno 1.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.
- data/.document +5 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +53 -0
- data/LICENSE.txt +20 -0
- data/README.md +264 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/build_install.sh +2 -0
- data/lib/quaderno-ruby/base.rb +71 -0
- data/lib/quaderno-ruby/behavior/crud.rb +83 -0
- data/lib/quaderno-ruby/behavior/deliver.rb +18 -0
- data/lib/quaderno-ruby/behavior/payment.rb +38 -0
- data/lib/quaderno-ruby/contact.rb +8 -0
- data/lib/quaderno-ruby/estimate.rb +8 -0
- data/lib/quaderno-ruby/exceptions/exceptions.rb +42 -0
- data/lib/quaderno-ruby/expense.rb +8 -0
- data/lib/quaderno-ruby/invoice.rb +9 -0
- data/lib/quaderno-ruby/item.rb +4 -0
- data/lib/quaderno-ruby/payment.rb +6 -0
- data/lib/quaderno-ruby.rb +11 -0
- data/quaderno-ruby.gemspec +114 -0
- data/test/fixtures/quaderno_cassettes/all_contacts.yml +46 -0
- data/test/fixtures/quaderno_cassettes/all_estimates.yml +44 -0
- data/test/fixtures/quaderno_cassettes/all_expenses.yml +44 -0
- data/test/fixtures/quaderno_cassettes/all_invoices.yml +44 -0
- data/test/fixtures/quaderno_cassettes/deleted_contact.yml +127 -0
- data/test/fixtures/quaderno_cassettes/deleted_estimate.yml +123 -0
- data/test/fixtures/quaderno_cassettes/deleted_expense.yml +123 -0
- data/test/fixtures/quaderno_cassettes/deleted_invoice.yml +124 -0
- data/test/fixtures/quaderno_cassettes/delivered_estimate.yml +127 -0
- data/test/fixtures/quaderno_cassettes/delivered_invoice.yml +127 -0
- data/test/fixtures/quaderno_cassettes/found_contact.yml +87 -0
- data/test/fixtures/quaderno_cassettes/found_estimate.yml +85 -0
- data/test/fixtures/quaderno_cassettes/found_expense.yml +85 -0
- data/test/fixtures/quaderno_cassettes/found_invoice.yml +85 -0
- data/test/fixtures/quaderno_cassettes/new_contact.yml +44 -0
- data/test/fixtures/quaderno_cassettes/new_estimate.yml +87 -0
- data/test/fixtures/quaderno_cassettes/new_expense.yml +128 -0
- data/test/fixtures/quaderno_cassettes/new_invoice.yml +87 -0
- data/test/fixtures/quaderno_cassettes/paid_expense.yml +85 -0
- data/test/fixtures/quaderno_cassettes/paid_invoice.yml +86 -0
- data/test/fixtures/quaderno_cassettes/rate_limit.yml +44 -0
- data/test/fixtures/quaderno_cassettes/unpay_an_expense.yml +123 -0
- data/test/fixtures/quaderno_cassettes/unpay_an_invoice.yml +123 -0
- data/test/fixtures/quaderno_cassettes/updated_contact.yml +87 -0
- data/test/fixtures/quaderno_cassettes/updated_estimate.yml +86 -0
- data/test/fixtures/quaderno_cassettes/updated_expense.yml +85 -0
- data/test/fixtures/quaderno_cassettes/updated_invoice.yml +86 -0
- data/test/helper.rb +27 -0
- data/test/test_quaderno-ruby.rb +4 -0
- data/test/unit/test_quaderno_contacts.rb +86 -0
- data/test/unit/test_quaderno_estimates.rb +99 -0
- data/test/unit/test_quaderno_expenses.rb +110 -0
- data/test/unit/test_quaderno_invoices.rb +121 -0
- metadata +232 -0
data/test/helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'ruby-debug'
|
4
|
+
require 'vcr'
|
5
|
+
|
6
|
+
VCR.configure do |c|
|
7
|
+
c.cassette_library_dir = 'test/fixtures/quaderno_cassettes'
|
8
|
+
c.ignore_localhost = false
|
9
|
+
c.hook_into :fakeweb
|
10
|
+
end
|
11
|
+
|
12
|
+
begin
|
13
|
+
Bundler.setup(:default, :development)
|
14
|
+
rescue Bundler::BundlerError => e
|
15
|
+
$stderr.puts e.message
|
16
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
17
|
+
exit e.status_code
|
18
|
+
end
|
19
|
+
require 'test/unit'
|
20
|
+
require 'shoulda'
|
21
|
+
|
22
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
23
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
24
|
+
require 'quaderno-ruby'
|
25
|
+
|
26
|
+
class Test::Unit::TestCase
|
27
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestQuadernoContact < Test::Unit::TestCase
|
4
|
+
context "A user with an authenticate token with contacts" do
|
5
|
+
|
6
|
+
setup do
|
7
|
+
Quaderno::Base.configure do |config|
|
8
|
+
config.auth_token = 'xiZvifX5hwsxAiymYPk2'
|
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 contacts') do
|
16
|
+
Quaderno::Contact.all 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
assert_raise ArgumentError do
|
20
|
+
VCR.use_cassette('found contact') do
|
21
|
+
Quaderno::Contact.find
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should "get all contacts (populated db)" do
|
27
|
+
VCR.use_cassette('all contacts') do
|
28
|
+
contacts = Quaderno::Contact.all
|
29
|
+
assert_not_nil contacts
|
30
|
+
assert_kind_of Array, contacts
|
31
|
+
contacts.each do |contact|
|
32
|
+
assert_kind_of Quaderno::Contact, contact
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
should "find a contact" do
|
38
|
+
VCR.use_cassette('found contact') do
|
39
|
+
contacts = Quaderno::Contact.all
|
40
|
+
contact = Quaderno::Contact.find contacts[2].id
|
41
|
+
assert_kind_of Quaderno::Contact, contact
|
42
|
+
assert_equal contacts[2].id, contact.id
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
should "create a contact" do
|
47
|
+
VCR.use_cassette('new contact') do
|
48
|
+
contact = Quaderno::Contact.create(kind: 'company', first_name: 'Test_Skynet', email: 'my_little@po.ny')
|
49
|
+
assert_kind_of Quaderno::Contact, contact
|
50
|
+
assert_equal 'company', contact.kind
|
51
|
+
assert_equal 'Test_Skynet', contact.full_name
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
should "update a contact" do
|
56
|
+
VCR.use_cassette('updated contact') do
|
57
|
+
contacts = Quaderno::Contact.all
|
58
|
+
contact = Quaderno::Contact.update(contacts[2].id, first_name: 'Test_OCP', email: 'dont@stop.believing')
|
59
|
+
assert_kind_of Quaderno::Contact, contact
|
60
|
+
if contact.kind == 'company'
|
61
|
+
assert_equal 'Test_OCP', contact.full_name
|
62
|
+
else
|
63
|
+
assert_equal 'Test_OCP', contact.first_name
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
should "delete a contact" do
|
69
|
+
VCR.use_cassette('deleted contact') do
|
70
|
+
contacts_before = Quaderno::Contact.all
|
71
|
+
contact_id = contacts_before[10].id
|
72
|
+
Quaderno::Contact.delete contact_id
|
73
|
+
contacts_after = Quaderno::Contact.all
|
74
|
+
assert_not_equal contacts_after[10].id, contact_id
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
should "know the rate limit" do
|
79
|
+
VCR.use_cassette('rate limit') do
|
80
|
+
rate_limit_info = Quaderno::Base.rate_limit_info
|
81
|
+
assert_equal 1000, rate_limit_info[:limit]
|
82
|
+
assert_operator rate_limit_info[:remaining], :< ,1000
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestQuadernoEstimate < Test::Unit::TestCase
|
4
|
+
context 'A user with an authenticate token with estimates' do
|
5
|
+
|
6
|
+
setup do
|
7
|
+
Quaderno::Base.configure do |config|
|
8
|
+
config.auth_token = 'xiZvifX5hwsxAiymYPk2'
|
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 estimates') do
|
16
|
+
Quaderno::Estimate.all 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
assert_raise ArgumentError do
|
20
|
+
VCR.use_cassette('found estimate') do
|
21
|
+
Quaderno::Estimate.find
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'get all estimates (populated db)' do
|
27
|
+
VCR.use_cassette('all estimates') do
|
28
|
+
estimates = Quaderno::Estimate.all
|
29
|
+
assert_not_nil estimates
|
30
|
+
assert_kind_of Array, estimates
|
31
|
+
estimates.each do |estimate|
|
32
|
+
assert_kind_of Quaderno::Estimate, estimate
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
should 'find an estimate' do
|
38
|
+
VCR.use_cassette('found estimate') do
|
39
|
+
estimates = Quaderno::Estimate.all
|
40
|
+
estimate = Quaderno::Estimate.find estimates.first.id
|
41
|
+
assert_kind_of Quaderno::Estimate, estimate
|
42
|
+
assert_equal estimates.first.id, estimate.id
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
should 'create an estimate' do
|
47
|
+
VCR.use_cassette('new estimate') do
|
48
|
+
contacts = Quaderno::Contact.all
|
49
|
+
estimate = Quaderno::Estimate.create(contact_id: contacts.first.id ,
|
50
|
+
contact_name: contacts.first.full_name,
|
51
|
+
currency: 'EUR',
|
52
|
+
items: [
|
53
|
+
{
|
54
|
+
description: 'Aircraft',
|
55
|
+
quantity: '1.0',
|
56
|
+
unit_price: '0.0'
|
57
|
+
}
|
58
|
+
],
|
59
|
+
tags: 'tnt', payment_details: '',
|
60
|
+
notes: '')
|
61
|
+
assert_kind_of Quaderno::Estimate, estimate
|
62
|
+
assert_equal contacts.first.id, estimate.contact.id
|
63
|
+
assert_equal 'Aircraft', estimate.items.first.description
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
should 'update an estimate' do
|
68
|
+
VCR.use_cassette('updated estimate') do
|
69
|
+
estimates = Quaderno::Estimate.all
|
70
|
+
estimate = Quaderno::Estimate.update(estimates.first.id, payment_details: 'Show me the moneeeeeeeyy!!!!')
|
71
|
+
assert_kind_of Quaderno::Estimate, estimate
|
72
|
+
assert_equal 'Show me the moneeeeeeeyy!!!!', estimate.payment_details
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
should 'delete an estimate' do
|
77
|
+
VCR.use_cassette('deleted estimate') do
|
78
|
+
estimates = Quaderno::Estimate.all
|
79
|
+
estimate_id = estimates.first.id
|
80
|
+
Quaderno::Estimate.delete estimate_id
|
81
|
+
estimates = Quaderno::Estimate.all
|
82
|
+
assert_not_equal estimates.first.id, estimate_id
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
should 'deliver an estimate' do
|
87
|
+
VCR.use_cassette('delivered estimate') do
|
88
|
+
estimates = Quaderno::Estimate.all
|
89
|
+
rate_limit_before = Quaderno::Base.rate_limit_info
|
90
|
+
begin
|
91
|
+
rate_limit_after = estimates.first.deliver
|
92
|
+
rescue Quaderno::Exceptions::RequiredFieldsEmpty
|
93
|
+
rate_limit_after = { remaining: (rate_limit_before[:remaining] - 1) }
|
94
|
+
end
|
95
|
+
assert_equal rate_limit_before[:remaining]-1, rate_limit_after[:remaining]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestQuadernoExpense < Test::Unit::TestCase
|
4
|
+
context 'A user with an authenticate token with expenses' do
|
5
|
+
|
6
|
+
setup do
|
7
|
+
Quaderno::Base.configure do |config|
|
8
|
+
config.auth_token = 'xiZvifX5hwsxAiymYPk2'
|
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 expenses') do
|
16
|
+
Quaderno::Expense.all 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
assert_raise ArgumentError do
|
20
|
+
VCR.use_cassette('found expense') do
|
21
|
+
Quaderno::Expense.find
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'get all expenses (populated db)' do
|
27
|
+
VCR.use_cassette('all expenses') do
|
28
|
+
expenses = Quaderno::Expense.all
|
29
|
+
assert_not_nil expenses
|
30
|
+
assert_kind_of Array, expenses
|
31
|
+
expenses.each do |expense|
|
32
|
+
assert_kind_of Quaderno::Expense, expense
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
should 'find a expense' do
|
38
|
+
VCR.use_cassette('found expense') do
|
39
|
+
expenses = Quaderno::Expense.all
|
40
|
+
expense = Quaderno::Expense.find expenses.first.id
|
41
|
+
assert_kind_of Quaderno::Expense, expense
|
42
|
+
assert_equal expenses.first.id, expense.id
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
should 'create a expense' do
|
47
|
+
VCR.use_cassette('new expense') do
|
48
|
+
expenses = Quaderno::Expense.all
|
49
|
+
contacts = Quaderno::Contact.all
|
50
|
+
expense = Quaderno::Expense.create(number: "#{ expenses.length + 1 }",
|
51
|
+
contact_id: contacts.first.id ,
|
52
|
+
contact_name: contacts.first.full_name,
|
53
|
+
currency: 'EUR',
|
54
|
+
items: [
|
55
|
+
{
|
56
|
+
description: 'Aircraft',
|
57
|
+
quantity: '1.0',
|
58
|
+
unit_price: '0.0'
|
59
|
+
}
|
60
|
+
],
|
61
|
+
tags: 'tnt', payment_details: '',
|
62
|
+
notes: '')
|
63
|
+
assert_kind_of Quaderno::Expense, expense
|
64
|
+
assert_equal contacts.first.id, expense.contact.id
|
65
|
+
assert_equal 'Aircraft', expense.items.first.description
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
should 'update an expense' do
|
70
|
+
VCR.use_cassette('updated expense') do
|
71
|
+
expenses = Quaderno::Expense.all
|
72
|
+
expense = Quaderno::Expense.update(expenses[2].id, currency: 'USD')
|
73
|
+
assert_kind_of Quaderno::Expense, expense
|
74
|
+
assert_equal 'USD', expense.currency
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
should 'delete an expense' do
|
79
|
+
VCR.use_cassette('deleted expense') do
|
80
|
+
expenses = Quaderno::Expense.all
|
81
|
+
expense_id = expenses.first.id
|
82
|
+
Quaderno::Expense.delete expense_id
|
83
|
+
expenses = Quaderno::Expense.all
|
84
|
+
assert_not_equal expenses.first.id, expense_id
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
should 'add a payment' do
|
89
|
+
VCR.use_cassette('paid expense') do
|
90
|
+
expenses = Quaderno::Expense.all
|
91
|
+
payment = expenses.first.add_payment(payment_method: "cash", number: "100000000")
|
92
|
+
assert_kind_of Quaderno::Payment, payment
|
93
|
+
assert_equal "cash", payment.payment_method
|
94
|
+
assert_equal "100,000,000.00", payment.amount[1..-1]
|
95
|
+
assert_equal expenses.first.payments.last.id, payment.id
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
should 'remove a payment' do
|
100
|
+
VCR.use_cassette('unpay an expense') do
|
101
|
+
expenses = Quaderno::Expense.all
|
102
|
+
expenses.first.add_payment(payment_method: "cash", number: "100000000")
|
103
|
+
payment = expenses.first.payments.last
|
104
|
+
array_length = expenses.first.payments.length
|
105
|
+
expenses.first.remove_payment(payment.id) unless payment.nil?
|
106
|
+
assert_equal (array_length.zero? ? array_length : array_length-1), expenses.first.payments.length
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestQuadernoInvoice < Test::Unit::TestCase
|
4
|
+
context 'A user with an authenticate token with invoices' do
|
5
|
+
|
6
|
+
setup do
|
7
|
+
Quaderno::Base.configure do |config|
|
8
|
+
config.auth_token = 'xiZvifX5hwsxAiymYPk2'
|
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 invoices') do
|
16
|
+
Quaderno::Invoice.all 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
assert_raise ArgumentError do
|
20
|
+
VCR.use_cassette('found invoice') do
|
21
|
+
Quaderno::Invoice.find
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'get all invoices (populated db)' do
|
27
|
+
VCR.use_cassette('all invoices') do
|
28
|
+
invoices = Quaderno::Invoice.all
|
29
|
+
assert_not_nil invoices
|
30
|
+
assert_kind_of Array, invoices
|
31
|
+
invoices.each do |invoice|
|
32
|
+
assert_kind_of Quaderno::Invoice, invoice
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
should 'find a invoice' do
|
38
|
+
VCR.use_cassette('found invoice') do
|
39
|
+
invoices = Quaderno::Invoice.all
|
40
|
+
invoice = Quaderno::Invoice.find invoices.first.id
|
41
|
+
assert_kind_of Quaderno::Invoice, invoice
|
42
|
+
assert_equal invoices.first.id, invoice.id
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
should 'create a invoice' do
|
47
|
+
VCR.use_cassette('new invoice') do
|
48
|
+
contacts = Quaderno::Contact.all
|
49
|
+
invoice = Quaderno::Invoice.create(contact_id: contacts[0].id ,
|
50
|
+
contact_name: contacts[0].full_name,
|
51
|
+
currency: 'EUR',
|
52
|
+
items: [
|
53
|
+
{
|
54
|
+
description: 'Aircraft',
|
55
|
+
quantity: '1.0',
|
56
|
+
unit_price: '0.0'
|
57
|
+
}
|
58
|
+
],
|
59
|
+
tags: 'tnt', payment_details: '',
|
60
|
+
notes: '')
|
61
|
+
assert_kind_of Quaderno::Invoice, invoice
|
62
|
+
assert_equal contacts[0].id, invoice.contact.id
|
63
|
+
assert_equal 'Aircraft', invoice.items[0].description
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
should 'update an invoice' do
|
68
|
+
VCR.use_cassette('updated invoice') do
|
69
|
+
invoices = Quaderno::Invoice.all
|
70
|
+
invoice = Quaderno::Invoice.update(invoices.first.id, payment_details: 'Show me the moneeeeeeeyy!!!!')
|
71
|
+
assert_kind_of Quaderno::Invoice, invoice
|
72
|
+
assert_equal 'Show me the moneeeeeeeyy!!!!', invoice.payment_details
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
should 'delete an invoice' do
|
77
|
+
VCR.use_cassette('deleted invoice') do
|
78
|
+
invoices = Quaderno::Invoice.all
|
79
|
+
invoice_id = invoices.first.id
|
80
|
+
Quaderno::Invoice.delete invoice_id
|
81
|
+
invoices = Quaderno::Invoice.all
|
82
|
+
assert_not_equal invoices.first.id, invoice_id
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
should 'deliver an invoice' do
|
87
|
+
VCR.use_cassette('delivered invoice') do
|
88
|
+
invoices = Quaderno::Invoice.all
|
89
|
+
rate_limit_before = Quaderno::Base.rate_limit_info
|
90
|
+
begin
|
91
|
+
rate_limit_after = invoices.first.deliver
|
92
|
+
rescue Quaderno::Exceptions::RequiredFieldsEmpty
|
93
|
+
rate_limit_after = { remaining: (rate_limit_before[:remaining] - 1) }
|
94
|
+
end
|
95
|
+
assert_equal rate_limit_before[:remaining]-1, rate_limit_after[:remaining]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
should 'add a payment' do
|
100
|
+
VCR.use_cassette('paid invoice') do
|
101
|
+
invoices = Quaderno::Invoice.all
|
102
|
+
payment = invoices.first.add_payment(payment_method: "cash", number: "100000000")
|
103
|
+
assert_kind_of Quaderno::Payment, payment
|
104
|
+
assert_equal "cash", payment.payment_method
|
105
|
+
assert_equal "100,000,000.00", payment.amount[1..-1]
|
106
|
+
assert_equal invoices.first.payments.last.id, payment.id
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
should 'remove a payment' do
|
111
|
+
VCR.use_cassette('unpay an invoice') do
|
112
|
+
invoices = Quaderno::Invoice.all
|
113
|
+
invoices.first.add_payment(payment_method: "cash", number: "100000000")
|
114
|
+
payment = invoices.first.payments.last
|
115
|
+
array_length = invoices.first.payments.length
|
116
|
+
invoices.first.remove_payment(payment.id) unless payment.nil?
|
117
|
+
assert_equal (array_length.zero? ? array_length : array_length-1), invoices.first.payments.length
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
metadata
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quaderno
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Recrea
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: debugger
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: httparty
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: jeweler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.4
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.8.4
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: shoulda
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rcov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 0.9.11
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.9.11
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rdoc
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.12'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '3.12'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: vcr
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description: longer description of your gem
|
143
|
+
email: carlos@recrea.es
|
144
|
+
executables: []
|
145
|
+
extensions: []
|
146
|
+
extra_rdoc_files:
|
147
|
+
- LICENSE.txt
|
148
|
+
- README.md
|
149
|
+
files:
|
150
|
+
- .document
|
151
|
+
- Gemfile
|
152
|
+
- Gemfile.lock
|
153
|
+
- LICENSE.txt
|
154
|
+
- README.md
|
155
|
+
- Rakefile
|
156
|
+
- VERSION
|
157
|
+
- build_install.sh
|
158
|
+
- lib/quaderno-ruby.rb
|
159
|
+
- lib/quaderno-ruby/base.rb
|
160
|
+
- lib/quaderno-ruby/behavior/crud.rb
|
161
|
+
- lib/quaderno-ruby/behavior/deliver.rb
|
162
|
+
- lib/quaderno-ruby/behavior/payment.rb
|
163
|
+
- lib/quaderno-ruby/contact.rb
|
164
|
+
- lib/quaderno-ruby/estimate.rb
|
165
|
+
- lib/quaderno-ruby/exceptions/exceptions.rb
|
166
|
+
- lib/quaderno-ruby/expense.rb
|
167
|
+
- lib/quaderno-ruby/invoice.rb
|
168
|
+
- lib/quaderno-ruby/item.rb
|
169
|
+
- lib/quaderno-ruby/payment.rb
|
170
|
+
- quaderno-ruby.gemspec
|
171
|
+
- test/fixtures/quaderno_cassettes/all_contacts.yml
|
172
|
+
- test/fixtures/quaderno_cassettes/all_estimates.yml
|
173
|
+
- test/fixtures/quaderno_cassettes/all_expenses.yml
|
174
|
+
- test/fixtures/quaderno_cassettes/all_invoices.yml
|
175
|
+
- test/fixtures/quaderno_cassettes/deleted_contact.yml
|
176
|
+
- test/fixtures/quaderno_cassettes/deleted_estimate.yml
|
177
|
+
- test/fixtures/quaderno_cassettes/deleted_expense.yml
|
178
|
+
- test/fixtures/quaderno_cassettes/deleted_invoice.yml
|
179
|
+
- test/fixtures/quaderno_cassettes/delivered_estimate.yml
|
180
|
+
- test/fixtures/quaderno_cassettes/delivered_invoice.yml
|
181
|
+
- test/fixtures/quaderno_cassettes/found_contact.yml
|
182
|
+
- test/fixtures/quaderno_cassettes/found_estimate.yml
|
183
|
+
- test/fixtures/quaderno_cassettes/found_expense.yml
|
184
|
+
- test/fixtures/quaderno_cassettes/found_invoice.yml
|
185
|
+
- test/fixtures/quaderno_cassettes/new_contact.yml
|
186
|
+
- test/fixtures/quaderno_cassettes/new_estimate.yml
|
187
|
+
- test/fixtures/quaderno_cassettes/new_expense.yml
|
188
|
+
- test/fixtures/quaderno_cassettes/new_invoice.yml
|
189
|
+
- test/fixtures/quaderno_cassettes/paid_expense.yml
|
190
|
+
- test/fixtures/quaderno_cassettes/paid_invoice.yml
|
191
|
+
- test/fixtures/quaderno_cassettes/rate_limit.yml
|
192
|
+
- test/fixtures/quaderno_cassettes/unpay_an_expense.yml
|
193
|
+
- test/fixtures/quaderno_cassettes/unpay_an_invoice.yml
|
194
|
+
- test/fixtures/quaderno_cassettes/updated_contact.yml
|
195
|
+
- test/fixtures/quaderno_cassettes/updated_estimate.yml
|
196
|
+
- test/fixtures/quaderno_cassettes/updated_expense.yml
|
197
|
+
- test/fixtures/quaderno_cassettes/updated_invoice.yml
|
198
|
+
- test/helper.rb
|
199
|
+
- test/test_quaderno-ruby.rb
|
200
|
+
- test/unit/test_quaderno_contacts.rb
|
201
|
+
- test/unit/test_quaderno_estimates.rb
|
202
|
+
- test/unit/test_quaderno_expenses.rb
|
203
|
+
- test/unit/test_quaderno_invoices.rb
|
204
|
+
homepage: http://github.com/recrea/quaderno-ruby
|
205
|
+
licenses:
|
206
|
+
- MIT
|
207
|
+
post_install_message:
|
208
|
+
rdoc_options: []
|
209
|
+
require_paths:
|
210
|
+
- lib
|
211
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
212
|
+
none: false
|
213
|
+
requirements:
|
214
|
+
- - ! '>='
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
segments:
|
218
|
+
- 0
|
219
|
+
hash: 2884457760108531416
|
220
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
|
+
none: false
|
222
|
+
requirements:
|
223
|
+
- - ! '>='
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0'
|
226
|
+
requirements: []
|
227
|
+
rubyforge_project:
|
228
|
+
rubygems_version: 1.8.24
|
229
|
+
signing_key:
|
230
|
+
specification_version: 3
|
231
|
+
summary: one-line summary of your gem
|
232
|
+
test_files: []
|