qbfc 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +85 -0
- data/Rakefile +84 -0
- data/VERSION +1 -0
- data/lib/qbfc.rb +41 -0
- data/lib/qbfc/base.rb +82 -0
- data/lib/qbfc/element.rb +243 -0
- data/lib/qbfc/entities/generated.rb +8 -0
- data/lib/qbfc/entity.rb +11 -0
- data/lib/qbfc/info.rb +42 -0
- data/lib/qbfc/infos/generated.rb +9 -0
- data/lib/qbfc/item.rb +29 -0
- data/lib/qbfc/items/generated.rb +11 -0
- data/lib/qbfc/list.rb +84 -0
- data/lib/qbfc/lists/account.rb +24 -0
- data/lib/qbfc/lists/generated.rb +15 -0
- data/lib/qbfc/lists/qb_class.rb +25 -0
- data/lib/qbfc/modifiable.rb +31 -0
- data/lib/qbfc/ole_wrapper.rb +201 -0
- data/lib/qbfc/qb_collection.rb +26 -0
- data/lib/qbfc/qb_types.rb +18 -0
- data/lib/qbfc/qbfc_const.rb +14 -0
- data/lib/qbfc/report.rb +95 -0
- data/lib/qbfc/reports/aging.rb +13 -0
- data/lib/qbfc/reports/budget_summary.rb +13 -0
- data/lib/qbfc/reports/custom_detail.rb +9 -0
- data/lib/qbfc/reports/custom_summary.rb +9 -0
- data/lib/qbfc/reports/general_detail.rb +44 -0
- data/lib/qbfc/reports/general_summary.rb +33 -0
- data/lib/qbfc/reports/job.rb +14 -0
- data/lib/qbfc/reports/payroll_detail.rb +13 -0
- data/lib/qbfc/reports/payroll_summary.rb +13 -0
- data/lib/qbfc/reports/rows.rb +51 -0
- data/lib/qbfc/reports/time.rb +12 -0
- data/lib/qbfc/request.rb +295 -0
- data/lib/qbfc/session.rb +147 -0
- data/lib/qbfc/terms.rb +10 -0
- data/lib/qbfc/terms/generated.rb +10 -0
- data/lib/qbfc/transaction.rb +110 -0
- data/lib/qbfc/transactions/generated.rb +25 -0
- data/lib/qbfc/voidable.rb +11 -0
- data/qbfc.gemspec +166 -0
- data/spec/fixtures/test.lgb +0 -0
- data/spec/fixtures/test.qbw +0 -0
- data/spec/fixtures/test.qbw.TLG +0 -0
- data/spec/integration/add_spec.rb +31 -0
- data/spec/integration/base_spec.rb +18 -0
- data/spec/integration/belongs_to_spec.rb +64 -0
- data/spec/integration/company_spec.rb +30 -0
- data/spec/integration/conditions_spec.rb +59 -0
- data/spec/integration/customer_spec.rb +46 -0
- data/spec/integration/element_finders_spec.rb +20 -0
- data/spec/integration/quick_test.rb +31 -0
- data/spec/integration/request_options_spec.rb +68 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +62 -0
- data/spec/unit/base_spec.rb +138 -0
- data/spec/unit/element_finder_spec.rb +185 -0
- data/spec/unit/element_spec.rb +108 -0
- data/spec/unit/entities/generated_spec.rb +18 -0
- data/spec/unit/entity_spec.rb +18 -0
- data/spec/unit/info/generated_spec.rb +12 -0
- data/spec/unit/info_spec.rb +48 -0
- data/spec/unit/item_spec.rb +33 -0
- data/spec/unit/items/generated_spec.rb +16 -0
- data/spec/unit/list_finders_spec.rb +129 -0
- data/spec/unit/list_spec.rb +86 -0
- data/spec/unit/lists/account_spec.rb +20 -0
- data/spec/unit/lists/generated_spec.rb +15 -0
- data/spec/unit/lists/qb_class_spec.rb +9 -0
- data/spec/unit/modifiable_spec.rb +84 -0
- data/spec/unit/ole_wrapper_spec.rb +337 -0
- data/spec/unit/qb_collection_spec.rb +13 -0
- data/spec/unit/qbfc_const_spec.rb +10 -0
- data/spec/unit/qbfc_spec.rb +10 -0
- data/spec/unit/report_spec.rb +12 -0
- data/spec/unit/request_query_survey.txt +48 -0
- data/spec/unit/request_spec.rb +486 -0
- data/spec/unit/session_spec.rb +144 -0
- data/spec/unit/terms/generated_spec.rb +14 -0
- data/spec/unit/terms_spec.rb +18 -0
- data/spec/unit/transaction_finders_spec.rb +125 -0
- data/spec/unit/transaction_spec.rb +94 -0
- data/spec/unit/transactions/generated_spec.rb +20 -0
- data/spec/unit/voidable_spec.rb +32 -0
- data/tasks/qbfc_tasks.rake +4 -0
- metadata +182 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QBFC::Entity do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@sess = mock(QBFC::Session)
|
7
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "is a base class" do
|
11
|
+
QBFC::Entity.is_base_class?.should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".find" do
|
15
|
+
it "should return subclass objects"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "QBFC::Info generated.rb" do
|
4
|
+
|
5
|
+
it "should generate classes" do
|
6
|
+
QBFC::Company.superclass.should be(QBFC::Info)
|
7
|
+
QBFC::CompanyActivity.superclass.should be(QBFC::Info)
|
8
|
+
QBFC::Host.superclass.should be(QBFC::Info)
|
9
|
+
QBFC::Preferences.superclass.should be(QBFC::Info)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module QBFC::Test
|
4
|
+
class Info < QBFC::Info
|
5
|
+
def self.qb_name
|
6
|
+
"Company"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe QBFC::Info do
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
@sess = mock(QBFC::Session)
|
15
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
16
|
+
@info = mock(QBFC::Test::Info)
|
17
|
+
|
18
|
+
# Request related mocks
|
19
|
+
@request = mock("QBFC::Request")
|
20
|
+
@response = mock("QBFC::Request#response")
|
21
|
+
|
22
|
+
QBFC::Request.stub!(:new).with(@sess, 'CompanyQuery').and_return(@request)
|
23
|
+
@request.stub!(:response).and_return(@response)
|
24
|
+
QBFC::Test::Info.stub!(:new).with(@sess, @response).and_return(@info)
|
25
|
+
@request.stub!(:apply_options)
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".get" do
|
29
|
+
it "should create Request and get response" do
|
30
|
+
QBFC::Request.should_receive(:new).with(@sess, 'CompanyQuery').and_return(@request)
|
31
|
+
@request.should_receive(:response).and_return(@response)
|
32
|
+
QBFC::Test::Info.should_receive(:new).with(@sess, @response).and_return(@info)
|
33
|
+
QBFC::Test::Info::get(@sess)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "applies options to Request" do
|
37
|
+
@request.should_receive(:apply_options).with({:owner_id => 0})
|
38
|
+
QBFC::Test::Info::get(@sess, :owner_id => 0)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ".find" do
|
43
|
+
it "should forward request, without 'what' argument, to get" do
|
44
|
+
QBFC::Test::Info.should_receive(:get).with(@sess, {})
|
45
|
+
QBFC::Test::Info::find(@sess, :first, {})
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QBFC::Item do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@sess = mock(QBFC::Session)
|
7
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "is a base class" do
|
11
|
+
QBFC::Item.is_base_class?.should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".find" do
|
15
|
+
it "should return subclass objects"
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".add_special" do
|
19
|
+
before(:each) do
|
20
|
+
@request = mock("QBFC::Request")
|
21
|
+
@response = mock("QBFC::Request#response")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should add a Special Account" do
|
25
|
+
QBFC::Request.should_receive(:new).with(@sess, "SpecialItemAdd").and_return(@request)
|
26
|
+
@request.should_receive(:special_item_type=).with(QBFC_CONST::SitFinanceCharge)
|
27
|
+
@request.should_receive(:response).and_return(@response)
|
28
|
+
|
29
|
+
QBFC::Item.add_special(@sess, QBFC_CONST::SitFinanceCharge)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "QBFC::Item generated.rb" do
|
4
|
+
|
5
|
+
it "should generate classes" do
|
6
|
+
QBFC::ItemGroup.superclass.should be(QBFC::Item)
|
7
|
+
QBFC::ItemDiscount.superclass.should be(QBFC::Item)
|
8
|
+
QBFC::ItemPayment.superclass.should be(QBFC::Item)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should include Modifiable in all classes" do
|
12
|
+
QBFC::ItemGroup.included_modules.should include(QBFC::Modifiable)
|
13
|
+
QBFC::ItemDiscount.included_modules.should include(QBFC::Modifiable)
|
14
|
+
QBFC::ItemPayment.included_modules.should include(QBFC::Modifiable)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module QBFC::Test
|
4
|
+
class ListFind < QBFC::List
|
5
|
+
def self.qb_name
|
6
|
+
"Account"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe QBFC::List do
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
@sess = mock(QBFC::Session)
|
15
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
16
|
+
@list = QBFC::Test::List.new(@sess, @ole_wrapper)
|
17
|
+
|
18
|
+
# Request related mocks
|
19
|
+
@request = mock("QBFC::Request")
|
20
|
+
@request.stub!(:dup).and_return(@request)
|
21
|
+
@list_query = mock("QBFC::OLEWrapper#list_query")
|
22
|
+
@response = mock("QBFC::Request#response")
|
23
|
+
|
24
|
+
# Filter mock
|
25
|
+
@filter = mock("QBFC::OLEWrapper#Filter")
|
26
|
+
@request.stub!(:filter).and_return(@filter)
|
27
|
+
@request.stub!(:add_limit)
|
28
|
+
@request.stub!(:filter_available?).and_return(true)
|
29
|
+
@request.stub!(:apply_options)
|
30
|
+
end
|
31
|
+
|
32
|
+
def setup_request
|
33
|
+
QBFC::Request.should_receive(:new).with(@sess, 'AccountQuery').and_return(@request)
|
34
|
+
@request.should_receive(:kind_of?).with(QBFC::Request).and_return(true)
|
35
|
+
@request.stub!(:response).and_return(@response)
|
36
|
+
@response.stub!(:GetAt).with(0).and_return(@ole_wrapper)
|
37
|
+
@response.stub!(:ole_methods).and_return(["GetAt"])
|
38
|
+
end
|
39
|
+
|
40
|
+
describe ".find_by_name" do
|
41
|
+
before(:each) do
|
42
|
+
@full_name_list = mock("QBFC::OLEWrapper#full_name_list")
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup_request
|
46
|
+
super
|
47
|
+
@request.should_receive(:query).and_return(@list_query)
|
48
|
+
@list_query.should_receive(:FullNameList).and_return(@full_name_list)
|
49
|
+
@full_name_list.should_receive(:Add).with("Bob Customer")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should set up Request, specifying FullNameList" do
|
53
|
+
setup_request
|
54
|
+
QBFC::Test::ListFind.find_by_name(@sess, "Bob Customer")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return a List object" do
|
58
|
+
setup_request
|
59
|
+
list = QBFC::Test::ListFind.find_by_name(@sess, "Bob Customer")
|
60
|
+
list.should be_kind_of(QBFC::Test::ListFind)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should return nil if none found" do
|
64
|
+
setup_request
|
65
|
+
@request.should_receive(:response).and_return(nil)
|
66
|
+
QBFC::Test::ListFind.find_by_name(@sess, "Bob Customer").should be_nil
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should alias as find_by_full_name" do
|
70
|
+
setup_request
|
71
|
+
QBFC::Test::ListFind.find_by_full_name(@sess, "Bob Customer")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe ".find_by_id" do
|
76
|
+
before(:each) do
|
77
|
+
@list_id_list = mock("QBFC::OLEWrapper#list_id_list")
|
78
|
+
end
|
79
|
+
|
80
|
+
def setup_request
|
81
|
+
super
|
82
|
+
@request.should_receive(:query).and_return(@list_query)
|
83
|
+
@list_query.should_receive(:ListIDList).and_return(@list_id_list)
|
84
|
+
@list_id_list.should_receive(:Add).with("123-456")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should set up Request, specifying ListIDList" do
|
88
|
+
setup_request
|
89
|
+
QBFC::Test::ListFind.find_by_id(@sess, "123-456")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should return a List object" do
|
93
|
+
setup_request
|
94
|
+
list = QBFC::Test::ListFind.find_by_id(@sess, "123-456")
|
95
|
+
list.should be_kind_of(QBFC::Test::ListFind)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should return nil if none found" do
|
99
|
+
setup_request
|
100
|
+
@request.should_receive(:response).and_return(nil)
|
101
|
+
QBFC::Test::ListFind.find_by_id(@sess, "123-456").should be_nil
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe ".find_by_name_or_id" do
|
106
|
+
it "should try to find_by_id" do
|
107
|
+
QBFC::Test::ListFind.should_receive(:find_by_id).with(@sess, "123-456").and_return("List By ID")
|
108
|
+
QBFC::Test::ListFind.find_by_name_or_id(@sess, "123-456").should == "List By ID"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should try to find_by_name if id fails" do
|
112
|
+
QBFC::Test::ListFind.should_receive(:find_by_id).with(@sess, "123-456").and_return(nil)
|
113
|
+
QBFC::Test::ListFind.should_receive(:find_by_name).with(@sess, "123-456").and_return("List By Name")
|
114
|
+
QBFC::Test::ListFind.find_by_name_or_id(@sess, "123-456").should == "List By Name"
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should return nil if both name and id return nil" do
|
118
|
+
QBFC::Test::ListFind.should_receive(:find_by_id).with(@sess, "123-456").and_return(nil)
|
119
|
+
QBFC::Test::ListFind.should_receive(:find_by_name).with(@sess, "123-456").and_return(nil)
|
120
|
+
QBFC::Test::ListFind.find_by_name_or_id(@sess, "123-456").should be_nil
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should be aliased as .find_by_unique_id" do
|
124
|
+
QBFC::Test::ListFind.should_receive(:find_by_id).with(@sess, "123-456").and_return(nil)
|
125
|
+
QBFC::Test::ListFind.should_receive(:find_by_name).with(@sess, "123-456").and_return(nil)
|
126
|
+
QBFC::Test::ListFind.find_by_unique_id(@sess, "123-456").should be_nil
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module QBFC::Test
|
4
|
+
class List < QBFC::List
|
5
|
+
def self.qb_name
|
6
|
+
"Account"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe QBFC::List do
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
@sess = mock(QBFC::Session)
|
15
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
16
|
+
@list = QBFC::Test::List.new(@sess, @ole_wrapper)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should specify if it is a superclass_list (such as Entity)"
|
20
|
+
|
21
|
+
describe "::ID_NAME" do
|
22
|
+
it "should be 'ListID'" do
|
23
|
+
QBFC::Test::List::ID_NAME.should == "ListID"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#id" do
|
28
|
+
it "is an alias of list_id" do
|
29
|
+
@ole_wrapper.should_receive(:list_id).and_return('L123')
|
30
|
+
@list.id.should == 'L123'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#full_name" do
|
35
|
+
before(:each) do
|
36
|
+
@ole_wrapper.stub!(:full_name).and_return("Full Name")
|
37
|
+
@ole_wrapper.stub!(:name).and_return("Short Name")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "aliases name if not defined by OLE object" do
|
41
|
+
@ole_wrapper.should_receive(:respond_to_ole?).with("FullName").and_return(false)
|
42
|
+
@list.full_name.should == "Short Name"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "calls OLE object's FullName method if defined" do
|
46
|
+
@ole_wrapper.should_receive(:respond_to_ole?).with("FullName").and_return(true)
|
47
|
+
@list.full_name.should == "Full Name"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#delete" do
|
52
|
+
it "should setup a ListDelRq with List Type and ID" do
|
53
|
+
@del_rq = mock(QBFC::Request)
|
54
|
+
@ole_wrapper.should_receive(:list_id).and_return('{123-456}')
|
55
|
+
QBFC::Request.should_receive(:new).with(@sess, "ListDel").and_return(@del_rq)
|
56
|
+
@del_rq.should_receive(:list_del_type=).with(QBFC_CONST::const_get("LdtAccount"))
|
57
|
+
@del_rq.should_receive(:list_id=).with("{123-456}")
|
58
|
+
@del_rq.should_receive(:submit)
|
59
|
+
@list.delete.should be_true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#display" do
|
64
|
+
before(:each) do
|
65
|
+
@display_rq = mock(QBFC::Request)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should call ListDisplayAdd for new records" do
|
69
|
+
QBFC::Request.should_receive(:new).with(@sess, "ListDisplayAdd").and_return(@display_rq)
|
70
|
+
@display_rq.should_receive(:list_display_add_type=).with(QBFC_CONST::LdatAccount)
|
71
|
+
@display_rq.should_receive(:submit)
|
72
|
+
@list.instance_variable_set(:@new_record, true)
|
73
|
+
@list.display
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should call ListDisplayMod for existing records" do
|
77
|
+
@ole_wrapper.should_receive(:list_id).and_return('123-456')
|
78
|
+
|
79
|
+
QBFC::Request.should_receive(:new).with(@sess, "ListDisplayMod").and_return(@display_rq)
|
80
|
+
@display_rq.should_receive(:list_display_mod_type=).with(QBFC_CONST::LdatAccount)
|
81
|
+
@display_rq.should_receive(:list_id=).with('123-456')
|
82
|
+
@display_rq.should_receive(:submit)
|
83
|
+
@list.display
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe QBFC::Account do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@sess = mock(QBFC::Session)
|
7
|
+
@request = mock("QBFC::Request")
|
8
|
+
@response = mock("QBFC::Request#response")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should add a Special Account" do
|
12
|
+
QBFC::Request.should_receive(:new).with(@sess, "SpecialAccountAdd").and_return(@request)
|
13
|
+
@request.should_receive(:special_account_type=).with(QBFC_CONST::SatAccountsReceivable)
|
14
|
+
@request.should_receive(:response).and_return(@response)
|
15
|
+
QBFC::Account.should_receive(:new).with(@sess, @response)
|
16
|
+
|
17
|
+
QBFC::Account.add_special(@sess, QBFC_CONST::SatAccountsReceivable)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "QBFC::List generated.rb" do
|
4
|
+
|
5
|
+
it "should generate classes" do
|
6
|
+
QBFC::Customer.ancestors.should include(QBFC::List)
|
7
|
+
QBFC::Account.ancestors.should include(QBFC::List)
|
8
|
+
QBFC::Account.superclass.should be(QBFC::List)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should include Modifiable in modifiable classes" do
|
12
|
+
QBFC::Customer.included_modules.should include(QBFC::Modifiable)
|
13
|
+
QBFC::CustomerMsg.included_modules.should_not include(QBFC::Modifiable)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module QBFC::Test
|
4
|
+
class ListMod < QBFC::List
|
5
|
+
include QBFC::Modifiable
|
6
|
+
|
7
|
+
def self.qb_name
|
8
|
+
"Account"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class TxnMod < QBFC::Transaction
|
13
|
+
include QBFC::Modifiable
|
14
|
+
|
15
|
+
def self.qb_name
|
16
|
+
"Check"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'QBFC::Modifiable' do
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
@sess = mock(QBFC::Session)
|
25
|
+
@ole_wrapper = mock(QBFC::OLEWrapper)
|
26
|
+
@ole_wrapper.stub!(:list_id).and_return "{list-id}"
|
27
|
+
@ole_wrapper.stub!(:txn_id).and_return "{txn-id}"
|
28
|
+
@ole_wrapper.stub!(:edit_sequence).and_return "123"
|
29
|
+
@ole_wrapper.stub!(:setter=)
|
30
|
+
|
31
|
+
@mod_rq = mock(QBFC::Request)
|
32
|
+
@mod_ole = mock(WIN32OLE)
|
33
|
+
@mod_rq.should_receive(:ole_object).and_return(@mod_ole)
|
34
|
+
@mod_rq.stub!(:list_id=)
|
35
|
+
@mod_rq.stub!(:txn_id=)
|
36
|
+
@mod_rq.stub!(:edit_sequence=)
|
37
|
+
QBFC::Request.stub!(:new).and_return(@mod_rq)
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#initialize" do
|
41
|
+
it "should setup Mod Request for existing records" do
|
42
|
+
QBFC::Request.should_receive(:new).with(@sess, "AccountMod").and_return(@mod_rq)
|
43
|
+
QBFC::Test::ListMod.new(@sess, @ole_wrapper)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should not set Mod Request for new records" do
|
47
|
+
QBFC::Request.should_not_receive(:new).with(@sess, "AccountMod")
|
48
|
+
QBFC::Test::ListMod.new(@sess)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#setup_mod_request" do
|
53
|
+
|
54
|
+
it "should create a Mod Request object" do
|
55
|
+
QBFC::Request.should_receive(:new).with(@sess, "AccountMod").and_return(@mod_rq)
|
56
|
+
QBFC::Test::ListMod.new(@sess, @ole_wrapper)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should set the Mod's id (for Lists) to the ole_object's id" do
|
60
|
+
@mod_rq.should_receive(:list_id=).with("{list-id}")
|
61
|
+
QBFC::Test::ListMod.new(@sess, @ole_wrapper)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should set the Mod's txn_id (for Transaction) to the ole_object's id" do
|
65
|
+
@mod_rq.should_receive(:txn_id=).with("{txn-id}")
|
66
|
+
QBFC::Test::TxnMod.new(@sess, @ole_wrapper)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should set the Mod's edit_sequence" do
|
70
|
+
@mod_rq.should_receive(:edit_sequence=).with("123")
|
71
|
+
QBFC::Test::TxnMod.new(@sess, @ole_wrapper)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should add the Mod request's ole_object as the @ole.setter" do
|
75
|
+
@ole_wrapper.should_receive(:setter=).with(@mod_ole)
|
76
|
+
QBFC::Test::TxnMod.new(@sess, @ole_wrapper)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should assign the Mod request as the @setter" do
|
80
|
+
txn = QBFC::Test::TxnMod.new(@sess, @ole_wrapper)
|
81
|
+
txn.instance_variable_get(:@setter).should be(@mod_rq)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|