quickeebooks 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +19 -16
- data/README.md +29 -23
- data/coverage/assets/0.7.1/application.css +1110 -0
- data/coverage/assets/0.7.1/application.js +626 -0
- data/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
- data/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
- data/coverage/assets/0.7.1/favicon_green.png +0 -0
- data/coverage/assets/0.7.1/favicon_red.png +0 -0
- data/coverage/assets/0.7.1/favicon_yellow.png +0 -0
- data/coverage/assets/0.7.1/loading.gif +0 -0
- data/coverage/assets/0.7.1/magnify.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +29154 -0
- data/lib/quickeebooks/common/online_line_item_model_methods.rb +43 -0
- data/lib/quickeebooks/common/service_crud.rb +56 -0
- data/lib/quickeebooks/online/model/bill.rb +26 -0
- data/lib/quickeebooks/online/model/bill_header.rb +21 -0
- data/lib/quickeebooks/online/model/bill_line_item.rb +22 -0
- data/lib/quickeebooks/online/model/bill_reimbursable.rb +11 -0
- data/lib/quickeebooks/online/model/invoice.rb +2 -31
- data/lib/quickeebooks/online/model/payment.rb +5 -33
- data/lib/quickeebooks/online/service/bill.rb +17 -0
- data/lib/quickeebooks/online/service/customer.rb +3 -47
- data/lib/quickeebooks/online/service/invoice.rb +1 -1
- data/lib/quickeebooks/online/service/payment.rb +3 -46
- data/lib/quickeebooks/online/service/service_base.rb +3 -2
- data/lib/quickeebooks/online/service/sort.rb +1 -12
- data/lib/quickeebooks/shared/service/filter.rb +19 -2
- data/lib/quickeebooks/shared/service/sort.rb +22 -0
- data/lib/quickeebooks/version.rb +1 -1
- data/lib/quickeebooks/windows/service/clazz.rb +1 -5
- data/lib/quickeebooks/windows/service/customer.rb +9 -13
- data/lib/quickeebooks/windows/service/item.rb +2 -5
- data/lib/quickeebooks/windows/service/service_base.rb +30 -15
- data/lib/quickeebooks/windows/service/sort.rb +8 -0
- data/lib/quickeebooks.rb +11 -5
- data/quickeebooks.gemspec +2 -2
- data/spec/quickeebooks/common/online_line_item_model_methods_spec.rb +41 -0
- data/spec/quickeebooks/common/service_crud_spec.rb +41 -0
- data/spec/quickeebooks/online/account_spec.rb +4 -8
- data/spec/quickeebooks/online/bill_spec.rb +17 -0
- data/spec/quickeebooks/online/company_meta_data_spec.rb +6 -9
- data/spec/quickeebooks/online/customer_spec.rb +10 -14
- data/spec/quickeebooks/online/invoice_spec.rb +3 -7
- data/spec/quickeebooks/online/payment_spec.rb +6 -10
- data/spec/quickeebooks/online/services/account_spec.rb +8 -13
- data/spec/quickeebooks/online/services/bill_spec.rb +61 -0
- data/spec/quickeebooks/online/services/company_meta_data_spec.rb +2 -7
- data/spec/quickeebooks/online/services/customer_spec.rb +15 -20
- data/spec/quickeebooks/online/services/filter_spec.rb +0 -5
- data/spec/quickeebooks/online/services/invoice_spec.rb +5 -10
- data/spec/quickeebooks/online/services/payment_spec.rb +63 -0
- data/spec/quickeebooks/online/services/service_base_spec.rb +62 -9
- data/spec/quickeebooks/shared/access_token_spec.rb +6 -11
- data/spec/quickeebooks/shared/filter_spec.rb +159 -0
- data/spec/quickeebooks/shared/sort_spec.rb +17 -0
- data/spec/quickeebooks/windows/customer_spec.rb +11 -15
- data/spec/quickeebooks/windows/services/class_spec.rb +2 -7
- data/spec/quickeebooks/windows/services/company_meta_data_spec.rb +2 -7
- data/spec/quickeebooks/windows/services/customer_spec.rb +16 -21
- data/spec/quickeebooks/windows/services/invoice_spec.rb +13 -19
- data/spec/quickeebooks/windows/services/payment_spec.rb +6 -12
- data/spec/quickeebooks/windows/services/sales_rep_spec.rb +6 -11
- data/spec/quickeebooks/windows/services/sales_taxes_spec.rb +5 -10
- data/spec/quickeebooks/windows/services/service_base_spec.rb +95 -0
- data/spec/quickeebooks/windows/services/ship_method_spec.rb +4 -9
- data/spec/quickeebooks_spec.rb +0 -3
- data/spec/spec_helper.rb +30 -1
- data/spec/support/oauth.rb +20 -0
- data/spec/xml/online/bill.xml +32 -0
- data/spec/xml/online/bill2.xml +32 -0
- data/spec/xml/online/bills.xml +33 -0
- data/spec/xml/online/payment.xml +1 -1
- data/spec/xml/online/payment2.xml +24 -0
- data/spec/xml/online/payments.xml +30 -0
- metadata +103 -40
- data/spec/quickeebooks/online/services/sort_spec.rb +0 -17
@@ -1,8 +1,3 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Online::Service::Customer" do
|
7
2
|
before(:all) do
|
8
3
|
FakeWeb.allow_net_connect = false
|
@@ -17,16 +12,16 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
17
12
|
:access_token_path => "/oauth/v1/get_access_token"
|
18
13
|
})
|
19
14
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
20
|
-
|
15
|
+
|
21
16
|
@service = Quickeebooks::Online::Service::Customer.new
|
22
17
|
@service.access_token = @oauth
|
23
18
|
@service.instance_eval {
|
24
19
|
@realm_id = "9991111222"
|
25
20
|
}
|
26
21
|
end
|
27
|
-
|
22
|
+
|
28
23
|
it "can fetch a list of customers" do
|
29
|
-
xml =
|
24
|
+
xml = onlineFixture("customers.xml")
|
30
25
|
url = @service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_collection)
|
31
26
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
32
27
|
accounts = @service.list
|
@@ -36,7 +31,7 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
36
31
|
end
|
37
32
|
|
38
33
|
it "can fetch a list of customers with filters" do
|
39
|
-
xml =
|
34
|
+
xml = onlineFixture("customers.xml")
|
40
35
|
url = @service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_collection)
|
41
36
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
42
37
|
accounts = @service.list
|
@@ -44,9 +39,9 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
44
39
|
accounts.entries.count.should == 3
|
45
40
|
accounts.entries.first.name.should == "John Doe"
|
46
41
|
end
|
47
|
-
|
42
|
+
|
48
43
|
it "can create a customer" do
|
49
|
-
xml =
|
44
|
+
xml = onlineFixture("customer.xml")
|
50
45
|
url = @service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_singular)
|
51
46
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
52
47
|
customer = Quickeebooks::Online::Model::Customer.new
|
@@ -54,7 +49,7 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
54
49
|
result = @service.create(customer)
|
55
50
|
result.id.value.to_i.should > 0
|
56
51
|
end
|
57
|
-
|
52
|
+
|
58
53
|
it "can delete a customer" do
|
59
54
|
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_singular)}/99"
|
60
55
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"])
|
@@ -74,15 +69,15 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
74
69
|
customer = Quickeebooks::Online::Model::Customer.new
|
75
70
|
lambda { @service.create(customer) }.should raise_error(InvalidModelException)
|
76
71
|
end
|
77
|
-
|
72
|
+
|
78
73
|
it "cannot update an invalid customer" do
|
79
74
|
customer = Quickeebooks::Online::Model::Customer.new
|
80
75
|
customer.name = "John Doe"
|
81
76
|
lambda { @service.update(customer) }.should raise_error(InvalidModelException)
|
82
77
|
end
|
83
|
-
|
78
|
+
|
84
79
|
it "can fetch a customer by id" do
|
85
|
-
xml =
|
80
|
+
xml = onlineFixture("customer.xml")
|
86
81
|
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_singular)}/99"
|
87
82
|
FakeWeb.register_uri(:get, url, :status => ["200", "OK"], :body => xml)
|
88
83
|
customer = @service.fetch_by_id(99)
|
@@ -90,12 +85,12 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
90
85
|
end
|
91
86
|
|
92
87
|
it "can update a customer" do
|
93
|
-
xml2 =
|
88
|
+
xml2 = onlineFixture("customer2.xml")
|
94
89
|
customer = Quickeebooks::Online::Model::Customer.new
|
95
90
|
customer.name = "John Doe"
|
96
91
|
customer.id = Quickeebooks::Online::Model::Id.new("1")
|
97
92
|
customer.sync_token = 2
|
98
|
-
|
93
|
+
|
99
94
|
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_singular)}/#{customer.id.value}"
|
100
95
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml2)
|
101
96
|
updated = @service.update(customer)
|
@@ -103,7 +98,7 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
103
98
|
end
|
104
99
|
|
105
100
|
it 'Can update a fetched customer' do
|
106
|
-
xml =
|
101
|
+
xml = onlineFixture("customer.xml")
|
107
102
|
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Customer.resource_for_singular)}/99"
|
108
103
|
FakeWeb.register_uri(:get, url, :status => ["200", "OK"], :body => xml)
|
109
104
|
customer = @service.fetch_by_id(99)
|
@@ -111,5 +106,5 @@ describe "Quickeebooks::Online::Service::Customer" do
|
|
111
106
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
112
107
|
updated = @service.update(customer)
|
113
108
|
end
|
114
|
-
|
115
|
-
end
|
109
|
+
|
110
|
+
end
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Online::Service::Invoice" do
|
7
2
|
before(:all) do
|
8
3
|
FakeWeb.allow_net_connect = false
|
@@ -23,23 +18,23 @@ describe "Quickeebooks::Online::Service::Invoice" do
|
|
23
18
|
@realm_id = "9991111222"
|
24
19
|
}
|
25
20
|
end
|
26
|
-
|
21
|
+
|
27
22
|
it "can create an invoice" do
|
28
|
-
xml =
|
29
|
-
|
23
|
+
xml = onlineFixture("invoice.xml")
|
24
|
+
|
30
25
|
url = @service.url_for_resource(Quickeebooks::Online::Model::Invoice.resource_for_singular)
|
31
26
|
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
32
27
|
invoice = Quickeebooks::Online::Model::Invoice.new
|
33
28
|
invoice.header = Quickeebooks::Online::Model::InvoiceHeader.new
|
34
29
|
invoice.header.doc_number = "123"
|
35
|
-
|
30
|
+
|
36
31
|
line_item = Quickeebooks::Online::Model::InvoiceLineItem.new
|
37
32
|
line_item.item_id = Quickeebooks::Online::Model::Id.new("123")
|
38
33
|
line_item.desc = "Pinor Noir 2005"
|
39
34
|
line_item.unit_price = 188
|
40
35
|
line_item.quantity = 2
|
41
36
|
invoice.line_items << line_item
|
42
|
-
|
37
|
+
|
43
38
|
result = @service.create(invoice)
|
44
39
|
result.id.value.to_i.should > 0
|
45
40
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
describe "Quickeebooks::Online::Service::Payment" do
|
2
|
+
before(:all) do
|
3
|
+
construct_oauth_service :payment
|
4
|
+
end
|
5
|
+
|
6
|
+
it "can fetch a list of payments" do
|
7
|
+
xml = onlineFixture("payments.xml")
|
8
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Payment.resource_for_collection)
|
9
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
10
|
+
payments = @service.list
|
11
|
+
payments.current_page.should == 1
|
12
|
+
payments.entries.count.should == 1
|
13
|
+
payments.entries.first.header.total_amount.should == 50.00
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can create a payment" do
|
17
|
+
xml = onlineFixture("payment.xml")
|
18
|
+
url = @service.url_for_resource(Quickeebooks::Online::Model::Payment.resource_for_singular)
|
19
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml)
|
20
|
+
payment = Quickeebooks::Online::Model::Payment.new
|
21
|
+
payment.header = Quickeebooks::Online::Model::PaymentHeader.new
|
22
|
+
payment.header.note = "Payment against Invoice"
|
23
|
+
payment.header.total_amount = 20.00
|
24
|
+
result = @service.create(payment)
|
25
|
+
result.id.value.to_i.should > 0
|
26
|
+
end
|
27
|
+
|
28
|
+
it "can delete a payment" do
|
29
|
+
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Payment.resource_for_singular)}/5"
|
30
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"])
|
31
|
+
payment = Quickeebooks::Online::Model::Payment.new
|
32
|
+
payment.id = Quickeebooks::Online::Model::Id.new("5")
|
33
|
+
payment.sync_token = 0
|
34
|
+
result = @service.delete(payment)
|
35
|
+
result.should == true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can fetch a payment by id" do
|
39
|
+
xml = onlineFixture("payment.xml")
|
40
|
+
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Payment.resource_for_singular)}/47"
|
41
|
+
FakeWeb.register_uri(:get, url, :status => ["200", "OK"], :body => xml)
|
42
|
+
payment = @service.fetch_by_id(47)
|
43
|
+
payment.header.total_amount.should == 20.00
|
44
|
+
end
|
45
|
+
|
46
|
+
it "can update a payment" do
|
47
|
+
xml2 = onlineFixture("payment2.xml")
|
48
|
+
payment = Quickeebooks::Online::Model::Payment.new
|
49
|
+
payment.header = Quickeebooks::Online::Model::PaymentHeader.new
|
50
|
+
payment.header.note = "Payment against Invoice"
|
51
|
+
payment.header.total_amount = 50.00
|
52
|
+
payment.id = Quickeebooks::Online::Model::Id.new("50")
|
53
|
+
payment.sync_token = 2
|
54
|
+
|
55
|
+
url = "#{@service.url_for_resource(Quickeebooks::Online::Model::Payment.resource_for_singular)}/#{payment.id.value}"
|
56
|
+
FakeWeb.register_uri(:post, url, :status => ["200", "OK"], :body => xml2)
|
57
|
+
updated = @service.update(payment)
|
58
|
+
updated.header.total_amount.should == 50.00
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks/online/service/service_base"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Online::Service::ServiceBase" do
|
7
2
|
before(:all) do
|
8
3
|
FakeWeb.allow_net_connect = false
|
@@ -18,7 +13,7 @@ describe "Quickeebooks::Online::Service::ServiceBase" do
|
|
18
13
|
})
|
19
14
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
20
15
|
|
21
|
-
xml =
|
16
|
+
xml = onlineFixture("user.xml")
|
22
17
|
user_url = Quickeebooks::Online::Service::ServiceBase::QB_BASE_URI + "/" + @realm_id
|
23
18
|
FakeWeb.register_uri(:get, user_url, :status => ["200", "OK"], :body => xml)
|
24
19
|
@service = Quickeebooks::Online::Service::ServiceBase.new
|
@@ -27,12 +22,70 @@ describe "Quickeebooks::Online::Service::ServiceBase" do
|
|
27
22
|
@realm_id = "9991111222"
|
28
23
|
}
|
29
24
|
end
|
30
|
-
|
25
|
+
|
31
26
|
it "can determine login_name" do
|
32
|
-
xml =
|
27
|
+
xml = onlineFixture("user.xml")
|
33
28
|
user_url = "https://qbo.intuit.com/qbo1/rest/user/v2/#{@realm_id}"
|
34
29
|
FakeWeb.register_uri(:get, user_url, :status => ["200", "OK"], :body => xml)
|
35
30
|
@service.login_name.should == 'foo@example.com'
|
36
31
|
end
|
37
|
-
|
32
|
+
|
33
|
+
describe "#fetch_collection" do
|
34
|
+
before do
|
35
|
+
@model = mock(Object)
|
36
|
+
@model.stub(:resource_for_collection){ "foos" }
|
37
|
+
|
38
|
+
@url = @service.url_for_resource(@model.resource_for_collection)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "uses all default values" do
|
42
|
+
@service.should_receive(:do_http_post).with(@url,
|
43
|
+
"PageNum=1&ResultsPerPage=20",
|
44
|
+
{},
|
45
|
+
{"Content-Type"=>"application/x-www-form-urlencoded"})
|
46
|
+
|
47
|
+
@service.send(:fetch_collection, @model)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "filters" do
|
51
|
+
|
52
|
+
filter = Quickeebooks::Online::Service::Filter.new(:text, :field => "Name", :value => "Smith")
|
53
|
+
|
54
|
+
@service.should_receive(:do_http_post).with(@url,
|
55
|
+
"Filter=Name+%3AEQUALS%3A+Smith&PageNum=1&ResultsPerPage=20",
|
56
|
+
{},
|
57
|
+
{"Content-Type"=>"application/x-www-form-urlencoded"})
|
58
|
+
|
59
|
+
@service.send(:fetch_collection, @model, [filter])
|
60
|
+
end
|
61
|
+
|
62
|
+
it "paginates" do
|
63
|
+
@service.should_receive(:do_http_post).with(@url,
|
64
|
+
"PageNum=2&ResultsPerPage=20",
|
65
|
+
{},
|
66
|
+
{"Content-Type"=>"application/x-www-form-urlencoded"})
|
67
|
+
|
68
|
+
@service.send(:fetch_collection, @model, nil, 2)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "changes per_page" do
|
72
|
+
@service.should_receive(:do_http_post).with(@url,
|
73
|
+
"PageNum=1&ResultsPerPage=10",
|
74
|
+
{},
|
75
|
+
{"Content-Type"=>"application/x-www-form-urlencoded"})
|
76
|
+
|
77
|
+
@service.send(:fetch_collection, @model, nil, 1, 10)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "sorts" do
|
81
|
+
sorter = Quickeebooks::Online::Service::Sort.new('FamilyName', 'AtoZ')
|
82
|
+
|
83
|
+
@service.should_receive(:do_http_post).with(@url,
|
84
|
+
"PageNum=1&ResultsPerPage=20&Sort=FamilyName+AtoZ",
|
85
|
+
{},
|
86
|
+
{"Content-Type"=>"application/x-www-form-urlencoded"})
|
87
|
+
|
88
|
+
@service.send(:fetch_collection, @model, nil, 1, 20, sorter)
|
89
|
+
end
|
90
|
+
end
|
38
91
|
end
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Shared::Service::AccessToken" do
|
7
2
|
|
8
3
|
shared_examples "access_token_operations" do
|
@@ -10,7 +5,7 @@ describe "Quickeebooks::Shared::Service::AccessToken" do
|
|
10
5
|
let(:reconnect_url){ "https://appcenter.intuit.com/api/v1/Connection/Reconnect" }
|
11
6
|
|
12
7
|
it "can successfully reconnect" do
|
13
|
-
xml =
|
8
|
+
xml = sharedFixture("reconnect_success.xml")
|
14
9
|
FakeWeb.register_uri(:get, reconnect_url, :status => ["200", "OK"], :body => xml)
|
15
10
|
|
16
11
|
response = @service.reconnect
|
@@ -21,7 +16,7 @@ describe "Quickeebooks::Shared::Service::AccessToken" do
|
|
21
16
|
end
|
22
17
|
|
23
18
|
it "can handle expired tokens" do
|
24
|
-
xml =
|
19
|
+
xml = sharedFixture("reconnect_error_expired.xml")
|
25
20
|
FakeWeb.register_uri(:get, reconnect_url, :status => ["200", "OK"], :body => xml)
|
26
21
|
|
27
22
|
response = @service.reconnect
|
@@ -32,7 +27,7 @@ describe "Quickeebooks::Shared::Service::AccessToken" do
|
|
32
27
|
end
|
33
28
|
|
34
29
|
it "can handle out-of-bounds refresh windows" do
|
35
|
-
xml =
|
30
|
+
xml = sharedFixture("reconnect_error_out_of_bounds.xml")
|
36
31
|
FakeWeb.register_uri(:get, reconnect_url, :status => ["200", "OK"], :body => xml)
|
37
32
|
|
38
33
|
response = @service.reconnect
|
@@ -44,7 +39,7 @@ describe "Quickeebooks::Shared::Service::AccessToken" do
|
|
44
39
|
|
45
40
|
|
46
41
|
it "can handle unapproved apps" do
|
47
|
-
xml =
|
42
|
+
xml = sharedFixture("reconnect_error_not_approved.xml")
|
48
43
|
FakeWeb.register_uri(:get, reconnect_url, :status => ["200", "OK"], :body => xml)
|
49
44
|
|
50
45
|
response = @service.reconnect
|
@@ -59,7 +54,7 @@ describe "Quickeebooks::Shared::Service::AccessToken" do
|
|
59
54
|
let(:disconnect_url){ "https://appcenter.intuit.com/api/v1/Connection/Disconnect" }
|
60
55
|
|
61
56
|
it "can successfully disconnect" do
|
62
|
-
xml =
|
57
|
+
xml = sharedFixture("disconnect_success.xml")
|
63
58
|
FakeWeb.register_uri(:get, disconnect_url, :status => ["200", "OK"], :body => xml)
|
64
59
|
|
65
60
|
response = @service.disconnect
|
@@ -68,7 +63,7 @@ describe "Quickeebooks::Shared::Service::AccessToken" do
|
|
68
63
|
end
|
69
64
|
|
70
65
|
it "can handle invalid tokens" do
|
71
|
-
xml =
|
66
|
+
xml = sharedFixture("disconnect_invalid.xml")
|
72
67
|
FakeWeb.register_uri(:get, disconnect_url, :status => ["200", "OK"], :body => xml)
|
73
68
|
|
74
69
|
response = @service.disconnect
|
@@ -0,0 +1,159 @@
|
|
1
|
+
describe "Quickeebooks::Shared::Service::Filter" do
|
2
|
+
ENV['TZ'] = 'UTC'
|
3
|
+
|
4
|
+
let(:filter){ Quickeebooks::Shared::Service::Filter }
|
5
|
+
|
6
|
+
context 'DateTime' do
|
7
|
+
describe '#to_s' do
|
8
|
+
it 'parses after' do
|
9
|
+
filter.new(:date,
|
10
|
+
:field => 'Foo',
|
11
|
+
:after => DateTime.parse('2020-12-31')).to_s.should == "Foo :AFTER: 2020-12-31"
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'parses before' do
|
15
|
+
filter.new(:date,
|
16
|
+
:field => 'Foo',
|
17
|
+
:before => DateTime.parse('2020-12-31')).to_s.should == "Foo :BEFORE: 2020-12-31"
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'parses after with time' do
|
21
|
+
filter.new(:date,
|
22
|
+
:field => 'Foo',
|
23
|
+
:after => DateTime.parse('2020-12-31T12:00:00')).to_s.should == "Foo :AFTER: 2020-12-31"
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'parses before with time' do
|
27
|
+
filter.new(:date,
|
28
|
+
:field => 'Foo',
|
29
|
+
:before => DateTime.parse('2020-12-31T12:00:00')).to_s.should == "Foo :BEFORE: 2020-12-31"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'Time' do
|
34
|
+
it 'parses after' do
|
35
|
+
filter.new(:datetime,
|
36
|
+
:field => 'Foo',
|
37
|
+
:after => Time.parse('2020-12-31')).to_s.should == "Foo :AFTER: 2020-12-31T00:00:00UTC"
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'parses before' do
|
41
|
+
filter.new(:datetime,
|
42
|
+
:field => 'Foo',
|
43
|
+
:before => Time.parse('2020-12-31')).to_s.should == "Foo :BEFORE: 2020-12-31T00:00:00UTC"
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'parses after with time' do
|
47
|
+
filter.new(:datetime,
|
48
|
+
:field => 'Foo',
|
49
|
+
:after => Time.parse('2020-12-31 12:00:00')).to_s.should == "Foo :AFTER: 2020-12-31T12:00:00UTC"
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'parses before with time' do
|
53
|
+
filter.new(:datetime,
|
54
|
+
:field => 'Foo',
|
55
|
+
:before => Time.parse('2020-12-31 12:00:00')).to_s.should == "Foo :BEFORE: 2020-12-31T12:00:00UTC"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'Not a date but responds to strftime' do
|
60
|
+
before do
|
61
|
+
# ActiveSupport::TimeWithZone is_a? Time but doesn't behave similarly.
|
62
|
+
# This test lets us mock out that use case and verify it works
|
63
|
+
@fake_time = mock(Object)
|
64
|
+
@fake_time.stub(:is_a?).with(Time).and_return(true)
|
65
|
+
@fake_time.stub(:is_a?).with(Date).and_return(false)
|
66
|
+
@fake_time.stub(:strftime).and_return("2020-12-31T12:00:00EST")
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'parses after' do
|
70
|
+
filter.new(:datetime,
|
71
|
+
:field => 'Foo',
|
72
|
+
:after => @fake_time).to_s.should == "Foo :AFTER: 2020-12-31T12:00:00EST"
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'parses before' do
|
76
|
+
filter.new(:datetime,
|
77
|
+
:field => 'Foo',
|
78
|
+
:before => @fake_time).to_s.should == "Foo :BEFORE: 2020-12-31T12:00:00EST"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#to_xml' do
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'text' do
|
87
|
+
describe '#to_s' do
|
88
|
+
it 'parses text' do
|
89
|
+
filter.new(:text,
|
90
|
+
:field => 'Foo',
|
91
|
+
:value => 'Bar').to_s.should == 'Foo :EQUALS: Bar'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#to_xml' do
|
96
|
+
it 'parses text' do
|
97
|
+
filter.new(:text,
|
98
|
+
:field => 'Foo',
|
99
|
+
:value => 'Bar').to_xml.should == '<Foo>Bar</Foo>'
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'CGI escapes values' do
|
103
|
+
filter.new(:text,
|
104
|
+
:field => 'Foo',
|
105
|
+
:value => "<3 Bar's ><things").to_xml.should == '<Foo><3 Bar\'s ><things</Foo>'
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'CGI escapes integers' do
|
109
|
+
filter.new(:text,
|
110
|
+
:field => 'Foo',
|
111
|
+
:value => 3).to_xml.should == '<Foo>3</Foo>'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'boolean' do
|
117
|
+
describe '#to_s' do
|
118
|
+
it 'parses boolean' do
|
119
|
+
filter.new(:boolean,
|
120
|
+
:field => 'Foo',
|
121
|
+
:value => 'Bar').to_s.should == 'Foo :EQUALS: Bar'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#to_xml' do
|
126
|
+
it 'parses boolean' do
|
127
|
+
filter.new(:boolean,
|
128
|
+
:field => 'Foo',
|
129
|
+
:value => 'Bar').to_xml.should == '<Foo>Bar</Foo>'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'number' do
|
135
|
+
describe '#to_s' do
|
136
|
+
it 'parses eq' do
|
137
|
+
filter.new(:number,
|
138
|
+
:field => 'Foo',
|
139
|
+
:eq => 42).to_s.should == 'Foo :EQUALS: 42'
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'parses lt' do
|
143
|
+
filter.new(:number,
|
144
|
+
:field => 'Foo',
|
145
|
+
:lt => 42).to_s.should == 'Foo :LessThan: 42'
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'parses gt' do
|
149
|
+
filter.new(:number,
|
150
|
+
:field => 'Foo',
|
151
|
+
:gt => 42).to_s.should == 'Foo :GreaterThan: 42'
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe '#to_xml' do
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe "Quickeebooks::Shared::Service::Filter" do
|
2
|
+
let(:sort_filter){Quickeebooks::Shared::Service::Sort}
|
3
|
+
|
4
|
+
context '#to_s' do
|
5
|
+
it "can generate a sorting parameter" do
|
6
|
+
filter = sort_filter.new("FirstName", "NewestToOldest")
|
7
|
+
filter.to_s.should == "FirstName NewestToOldest"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context '#to_xml' do
|
12
|
+
it "can generate a sorting parameter" do
|
13
|
+
filter = sort_filter.new("FirstName", "Ascending")
|
14
|
+
filter.to_xml.should == "<SortByColumn sortOrder=\"Ascending\">FirstName</SortByColumn>"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,29 +1,25 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
require "quickeebooks/windows/model/customer"
|
4
|
-
|
5
1
|
describe "Quickeebooks::Windows::Model::Customer" do
|
6
|
-
|
2
|
+
|
7
3
|
it "parse customer from XML" do
|
8
|
-
xml =
|
4
|
+
xml = windowsFixture("customer.xml")
|
9
5
|
customer = Quickeebooks::Windows::Model::Customer.from_xml(xml)
|
10
6
|
customer.sync_token.should == 1
|
11
7
|
customer.name.should == "Wine House"
|
12
|
-
|
8
|
+
|
13
9
|
customer.dba_name.should == "Wine House"
|
14
|
-
|
10
|
+
|
15
11
|
create_time = Date.civil(2012, 3, 24)
|
16
12
|
customer.meta_data.create_time.year.should == create_time.year
|
17
13
|
customer.addresses.count.should == 1
|
18
|
-
|
14
|
+
|
19
15
|
customer.addresses.first.line1.should == "Wine House"
|
20
16
|
customer.addresses.first.line2.should == "2311 Maple Ave"
|
21
|
-
|
17
|
+
|
22
18
|
customer.phones.size.should == 1
|
23
19
|
customer.phones.first.free_form_number.should == "415-555-1212"
|
24
|
-
|
20
|
+
|
25
21
|
customer.email.address.should == "no-reply@winehouse.com"
|
26
|
-
|
22
|
+
|
27
23
|
customer.notes.count.should == 1
|
28
24
|
customer.notes.first.content.should == "Likes chocolate and horses"
|
29
25
|
|
@@ -31,7 +27,7 @@ describe "Quickeebooks::Windows::Model::Customer" do
|
|
31
27
|
|
32
28
|
customer.open_balance.amount.should == 6200.0
|
33
29
|
end
|
34
|
-
|
30
|
+
|
35
31
|
it "can assign an email address" do
|
36
32
|
customer = Quickeebooks::Windows::Model::Customer.new
|
37
33
|
the_email = "foo@example.org"
|
@@ -39,11 +35,11 @@ describe "Quickeebooks::Windows::Model::Customer" do
|
|
39
35
|
customer.email.is_a?(Quickeebooks::Windows::Model::Email).should == true
|
40
36
|
customer.email.address.should == the_email
|
41
37
|
end
|
42
|
-
|
38
|
+
|
43
39
|
it "cannot update an invalid model" do
|
44
40
|
customer = Quickeebooks::Windows::Model::Customer.new
|
45
41
|
customer.valid_for_update?.should == false
|
46
42
|
customer.errors.keys.include?(:sync_token).should == true
|
47
43
|
end
|
48
|
-
|
44
|
+
|
49
45
|
end
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Windows::Service::Clazz" do
|
7
2
|
before(:all) do
|
8
3
|
FakeWeb.allow_net_connect = false
|
@@ -19,9 +14,9 @@ describe "Quickeebooks::Windows::Service::Clazz" do
|
|
19
14
|
})
|
20
15
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
21
16
|
end
|
22
|
-
|
17
|
+
|
23
18
|
it "can fetch a list of classes" do
|
24
|
-
xml =
|
19
|
+
xml = windowsFixture("classes.xml")
|
25
20
|
model = Quickeebooks::Windows::Model::Clazz
|
26
21
|
service = Quickeebooks::Windows::Service::Clazz.new
|
27
22
|
service.access_token = @oauth
|
@@ -1,8 +1,3 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
-
require "fakeweb"
|
3
|
-
require "oauth"
|
4
|
-
require "quickeebooks"
|
5
|
-
|
6
1
|
describe "Quickeebooks::Windows::Service::CompanyMetaData" do
|
7
2
|
before(:all) do
|
8
3
|
FakeWeb.allow_net_connect = false
|
@@ -19,9 +14,9 @@ describe "Quickeebooks::Windows::Service::CompanyMetaData" do
|
|
19
14
|
})
|
20
15
|
@oauth = OAuth::AccessToken.new(@oauth_consumer, "blah", "blah")
|
21
16
|
end
|
22
|
-
|
17
|
+
|
23
18
|
it "can fetch the company meta data" do
|
24
|
-
xml =
|
19
|
+
xml = windowsFixture("company_meta_data.xml")
|
25
20
|
model = Quickeebooks::Windows::Model::CompanyMetaData
|
26
21
|
service = Quickeebooks::Windows::Service::CompanyMetaData.new
|
27
22
|
service.access_token = @oauth
|