move-to-go 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/move-to-go +210 -0
- data/lib/move-to-go/can_become_immutable.rb +29 -0
- data/lib/move-to-go/csv_helper.rb +47 -0
- data/lib/move-to-go/email_helper.rb +14 -0
- data/lib/move-to-go/errors.rb +31 -0
- data/lib/move-to-go/excel_helper.rb +10 -0
- data/lib/move-to-go/global_phone.json +6571 -0
- data/lib/move-to-go/model/address.rb +63 -0
- data/lib/move-to-go/model/class_settings.rb +50 -0
- data/lib/move-to-go/model/clientvisit.rb +10 -0
- data/lib/move-to-go/model/comment.rb +10 -0
- data/lib/move-to-go/model/coworker.rb +82 -0
- data/lib/move-to-go/model/coworker_reference.rb +33 -0
- data/lib/move-to-go/model/customfield.rb +87 -0
- data/lib/move-to-go/model/deal.rb +216 -0
- data/lib/move-to-go/model/deal_class_settings.rb +97 -0
- data/lib/move-to-go/model/deal_state.rb +15 -0
- data/lib/move-to-go/model/deal_status.rb +23 -0
- data/lib/move-to-go/model/deal_status_reference.rb +47 -0
- data/lib/move-to-go/model/deal_status_setting.rb +49 -0
- data/lib/move-to-go/model/documents.rb +76 -0
- data/lib/move-to-go/model/file.rb +193 -0
- data/lib/move-to-go/model/history.rb +148 -0
- data/lib/move-to-go/model/history_classification.rb +26 -0
- data/lib/move-to-go/model/link.rb +82 -0
- data/lib/move-to-go/model/organization.rb +250 -0
- data/lib/move-to-go/model/person.rb +164 -0
- data/lib/move-to-go/model/referencetosource.rb +58 -0
- data/lib/move-to-go/model/relation.rb +23 -0
- data/lib/move-to-go/model/rootmodel.rb +663 -0
- data/lib/move-to-go/model/salescall.rb +10 -0
- data/lib/move-to-go/model/settings.rb +61 -0
- data/lib/move-to-go/model/tag.rb +35 -0
- data/lib/move-to-go/model/talkedto.rb +10 -0
- data/lib/move-to-go/model/triedtoreach.rb +10 -0
- data/lib/move-to-go/model_helpers.rb +97 -0
- data/lib/move-to-go/phone_helper.rb +75 -0
- data/lib/move-to-go/roo_helper.rb +82 -0
- data/lib/move-to-go/serialize_helper.rb +199 -0
- data/lib/move-to-go/shard_helper.rb +96 -0
- data/lib/move-to-go/source.rb +108 -0
- data/lib/move-to-go/templating.rb +52 -0
- data/lib/move-to-go.rb +20 -0
- data/sources/VISMA/.gitignore +14 -0
- data/sources/VISMA/.move-to-go/readme.txt +1 -0
- data/sources/VISMA/.move-to-go/runner.rb +89 -0
- data/sources/VISMA/Database/KONTAKT.DBF +0 -0
- data/sources/VISMA/Database/KUND.DBF +0 -0
- data/sources/VISMA/Gemfile +5 -0
- data/sources/VISMA/converter.rb +120 -0
- data/sources/base-crm/.move-to-go/runner.rb +235 -0
- data/sources/base-crm/Gemfile +5 -0
- data/sources/base-crm/README.md +9 -0
- data/sources/base-crm/converter.rb +56 -0
- data/sources/base-crm/data/contacts.csv +13 -0
- data/sources/base-crm/data/coworkers.csv +3 -0
- data/sources/base-crm/data/deals.csv +5 -0
- data/sources/base-crm/data/histories.csv +6 -0
- data/sources/base-crm/data/leads.csv +4 -0
- data/sources/base-crm/data/tasks.csv +5 -0
- data/sources/csv/.gitignore +14 -0
- data/sources/csv/.move-to-go/readme.txt +1 -0
- data/sources/csv/.move-to-go/runner.rb +65 -0
- data/sources/csv/Gemfile +5 -0
- data/sources/csv/converter.rb +218 -0
- data/sources/csv/data/coworkers.csv +2 -0
- data/sources/csv/data/deals.csv +2 -0
- data/sources/csv/data/organizations.csv +2 -0
- data/sources/csv/data/persons.csv +2 -0
- data/sources/custom/.gitignore +14 -0
- data/sources/custom/.move-to-go/readme.txt +1 -0
- data/sources/custom/.move-to-go/runner.rb +30 -0
- data/sources/custom/Gemfile +4 -0
- data/sources/custom/converter.rb +45 -0
- data/sources/excel/.gitignore +14 -0
- data/sources/excel/.move-to-go/readme.txt +3 -0
- data/sources/excel/.move-to-go/runner.rb +140 -0
- data/sources/excel/Gemfile +7 -0
- data/sources/excel/converter.rb +188 -0
- data/sources/excel/files/avtal.docx +0 -0
- data/sources/excel/files/more/avtal.docx +0 -0
- data/sources/excel/files/more/offert-2.pdf +0 -0
- data/sources/excel/files/offert-2.docx +0 -0
- data/sources/excel/files/offert.docx +0 -0
- data/sources/excel/sample-data.xlsx +0 -0
- data/sources/excel-basic/.gitignore +14 -0
- data/sources/excel-basic/.move-to-go/readme.txt +3 -0
- data/sources/excel-basic/.move-to-go/runner.rb +139 -0
- data/sources/excel-basic/Exempelfil.xlsx +0 -0
- data/sources/excel-basic/Gemfile +6 -0
- data/sources/excel-basic/converter.rb +175 -0
- data/sources/excel-basic/files/avtal.docx +0 -0
- data/sources/excel-basic/files/more/avtal.docx +0 -0
- data/sources/excel-basic/files/more/offert-2.pdf +0 -0
- data/sources/excel-basic/files/offert-2.docx +0 -0
- data/sources/excel-basic/files/offert.docx +0 -0
- data/sources/lime-crm-basic/.gitignore +14 -0
- data/sources/lime-crm-basic/.move-to-go/readme.txt +1 -0
- data/sources/lime-crm-basic/.move-to-go/runner.rb +524 -0
- data/sources/lime-crm-basic/Gemfile +6 -0
- data/sources/lime-crm-basic/converter.rb +396 -0
- data/sources/lime-easy/.gitignore +14 -0
- data/sources/lime-easy/.move-to-go/readme.txt +1 -0
- data/sources/lime-easy/.move-to-go/runner.rb +348 -0
- data/sources/lime-easy/Export/readme.txt +6 -0
- data/sources/lime-easy/Gemfile +5 -0
- data/sources/lime-easy/converter.rb +362 -0
- data/sources/salesforce/.gitignore +14 -0
- data/sources/salesforce/.move-to-go/readme.txt +1 -0
- data/sources/salesforce/.move-to-go/runner.rb +404 -0
- data/sources/salesforce/Gemfile +6 -0
- data/sources/salesforce/Gemfile.lock +48 -0
- data/sources/salesforce/converter.rb +113 -0
- data/sources/salesforce/export/readme.txt +3 -0
- data/spec/address_spec.rb +49 -0
- data/spec/class_settings_spec.rb +37 -0
- data/spec/coworker_spec.rb +94 -0
- data/spec/custom_field_spec.rb +22 -0
- data/spec/deal_class_settings_spec.rb +116 -0
- data/spec/deal_spec.rb +232 -0
- data/spec/deal_status_reference_spec.rb +17 -0
- data/spec/documents_spec.rb +64 -0
- data/spec/file_spec.rb +178 -0
- data/spec/helpers/csv_helper_spec.rb +45 -0
- data/spec/helpers/email_helper_spec.rb +37 -0
- data/spec/helpers/phone_helper_spec.rb +119 -0
- data/spec/helpers/roo_helper_spec.rb +10 -0
- data/spec/helpers/serialize_helper_spec.rb +253 -0
- data/spec/helpers/shard_helper_spec.rb +141 -0
- data/spec/helpers/xsd_validate_spec.rb +57 -0
- data/spec/history_spec.rb +150 -0
- data/spec/link_spec.rb +107 -0
- data/spec/organization_spec.rb +221 -0
- data/spec/person_spec.rb +129 -0
- data/spec/rootmodel_spec.rb +993 -0
- data/spec/spec_helper.rb +30 -0
- metadata +362 -0
@@ -0,0 +1,993 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'move-to-go'
|
3
|
+
|
4
|
+
describe "RootModel" do
|
5
|
+
let(:rootmodel) {
|
6
|
+
MoveToGo::RootModel.new
|
7
|
+
}
|
8
|
+
|
9
|
+
it "will contain migration coworker by default" do
|
10
|
+
rootmodel.find_coworker_by_integration_id("migrator").first_name.should eq "Migrator"
|
11
|
+
rootmodel.coworkers.length.should eq 1
|
12
|
+
end
|
13
|
+
|
14
|
+
it "can add a coworker from a new coworker" do
|
15
|
+
# given
|
16
|
+
coworker = MoveToGo::Coworker.new
|
17
|
+
coworker.integration_id = "123key"
|
18
|
+
coworker.first_name="Kalle"
|
19
|
+
coworker.last_name="Anka"
|
20
|
+
coworker.email = "kalle.anka@vonanka.com"
|
21
|
+
|
22
|
+
# when
|
23
|
+
rootmodel.add_coworker(coworker)
|
24
|
+
|
25
|
+
# end
|
26
|
+
rootmodel.find_coworker_by_integration_id("123key").first_name.should eq "Kalle"
|
27
|
+
rootmodel.coworkers.length.should eq 2
|
28
|
+
end
|
29
|
+
|
30
|
+
it "will make coworkers immutable after it has been added" do
|
31
|
+
# given
|
32
|
+
coworker = MoveToGo::Coworker.new
|
33
|
+
coworker.integration_id = "123key"
|
34
|
+
coworker.first_name = "vincent"
|
35
|
+
|
36
|
+
# when
|
37
|
+
rootmodel.add_coworker(coworker)
|
38
|
+
|
39
|
+
# then
|
40
|
+
coworker.is_immutable.should eq true
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
it "will only add coworkers" do
|
45
|
+
# given
|
46
|
+
not_a_coworker = { :integration_id => "123", :first_name => "Vincent" }
|
47
|
+
|
48
|
+
# when, then
|
49
|
+
expect {
|
50
|
+
rootmodel.add_coworker(not_a_coworker)
|
51
|
+
}.to raise_error(ArgumentError)
|
52
|
+
rootmodel.coworkers.length.should eq 1
|
53
|
+
end
|
54
|
+
|
55
|
+
it "will not add a new coworker when the coworker is already added (same integration id)" do
|
56
|
+
# when
|
57
|
+
coworker1 = MoveToGo::Coworker.new({
|
58
|
+
:integration_id => "123key",
|
59
|
+
:first_name => "Kalle",
|
60
|
+
:last_name => "Anka",
|
61
|
+
:email => "kalle.anka@vonanka.com"
|
62
|
+
})
|
63
|
+
rootmodel.add_coworker(coworker1)
|
64
|
+
rootmodel.coworkers.length.should eq 2
|
65
|
+
|
66
|
+
# when
|
67
|
+
coworker2 = MoveToGo::Coworker.new({
|
68
|
+
|
69
|
+
:integration_id => "123key",
|
70
|
+
:first_name => "Knatte",
|
71
|
+
:last_name => "Anka",
|
72
|
+
:email => "knatte.anka@vonanka.com"
|
73
|
+
})
|
74
|
+
expect {
|
75
|
+
rootmodel.add_coworker(coworker2)
|
76
|
+
}.to raise_error(MoveToGo::AlreadyAddedError)
|
77
|
+
rootmodel.find_coworker_by_integration_id("123key").first_name.should eq "Kalle"
|
78
|
+
rootmodel.coworkers.length.should eq 2
|
79
|
+
end
|
80
|
+
|
81
|
+
it "can add an organization from a new organization" do
|
82
|
+
# given
|
83
|
+
organization = MoveToGo::Organization.new
|
84
|
+
organization.integration_id = "123key"
|
85
|
+
organization.name = "Beagle Boys"
|
86
|
+
|
87
|
+
# when
|
88
|
+
rootmodel.add_organization(organization)
|
89
|
+
|
90
|
+
# then
|
91
|
+
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
92
|
+
rootmodel.organizations.length.should eq 1
|
93
|
+
end
|
94
|
+
|
95
|
+
it "will make organizations immutable after it has been added" do
|
96
|
+
# given
|
97
|
+
organization = MoveToGo::Organization.new
|
98
|
+
organization.integration_id = "123key"
|
99
|
+
organization.name = "Beagle Boys"
|
100
|
+
|
101
|
+
# when
|
102
|
+
rootmodel.add_organization(organization)
|
103
|
+
|
104
|
+
# then
|
105
|
+
organization.is_immutable.should eq true
|
106
|
+
end
|
107
|
+
|
108
|
+
it "will only add organizations" do
|
109
|
+
# given
|
110
|
+
not_an_organization = { :integration_id => "123", :name => "This is not a history"}
|
111
|
+
|
112
|
+
# when, then
|
113
|
+
expect {
|
114
|
+
rootmodel.add_organization(not_an_organization)
|
115
|
+
}.to raise_error(ArgumentError)
|
116
|
+
rootmodel.organizations.length.should eq 0
|
117
|
+
end
|
118
|
+
|
119
|
+
it "will not add a new organization when the organization is already added (same integration id)" do
|
120
|
+
# given
|
121
|
+
org = MoveToGo::Organization.new({
|
122
|
+
:integration_id => "123key",
|
123
|
+
:name => "Beagle Boys"
|
124
|
+
})
|
125
|
+
rootmodel.add_organization(org)
|
126
|
+
rootmodel.organizations.length.should eq 1
|
127
|
+
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
128
|
+
|
129
|
+
# when, then
|
130
|
+
org2 = MoveToGo::Organization.new({
|
131
|
+
:integration_id => "123key",
|
132
|
+
:name => "Beagle Boys 2"
|
133
|
+
})
|
134
|
+
expect {
|
135
|
+
rootmodel.add_organization(org2)
|
136
|
+
}.to raise_error(MoveToGo::AlreadyAddedError)
|
137
|
+
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
138
|
+
rootmodel.organizations.length.should eq 1
|
139
|
+
end
|
140
|
+
|
141
|
+
it "will not add a organization when integration_id is nil" do
|
142
|
+
# given
|
143
|
+
org1 = MoveToGo::Organization.new
|
144
|
+
org1.name = "Beagle Boys"
|
145
|
+
org1.integration_id = nil
|
146
|
+
|
147
|
+
# when, then
|
148
|
+
expect {
|
149
|
+
rootmodel.add_organization(org1)
|
150
|
+
}.to raise_error(MoveToGo::IntegrationIdIsRequiredError)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "will not add a organization when integration_id is empty" do
|
154
|
+
# given
|
155
|
+
org1 = MoveToGo::Organization.new
|
156
|
+
org1.name = "Beagle Boys"
|
157
|
+
org1.integration_id = ""
|
158
|
+
|
159
|
+
# when, then
|
160
|
+
expect {
|
161
|
+
rootmodel.add_organization(org1)
|
162
|
+
}.to raise_error(MoveToGo::IntegrationIdIsRequiredError)
|
163
|
+
end
|
164
|
+
|
165
|
+
it "can add a deal from a new deal" do
|
166
|
+
# given
|
167
|
+
deal = MoveToGo::Deal.new
|
168
|
+
deal.integration_id = "123key"
|
169
|
+
deal.name = "Big deal"
|
170
|
+
|
171
|
+
# when
|
172
|
+
rootmodel.add_deal(deal)
|
173
|
+
|
174
|
+
# then
|
175
|
+
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
176
|
+
rootmodel.deals.length.should eq 1
|
177
|
+
end
|
178
|
+
|
179
|
+
it "will make deal immutable after it has been added" do
|
180
|
+
# given
|
181
|
+
deal = MoveToGo::Deal.new
|
182
|
+
deal.integration_id = "123key"
|
183
|
+
deal.name = "Big deal"
|
184
|
+
|
185
|
+
# when
|
186
|
+
rootmodel.add_deal(deal)
|
187
|
+
|
188
|
+
# then
|
189
|
+
deal.is_immutable.should eq true
|
190
|
+
end
|
191
|
+
|
192
|
+
it "will only add deals" do
|
193
|
+
# given
|
194
|
+
not_a_deal = { :integration_id => "123", :name => "This is not a deal" }
|
195
|
+
|
196
|
+
# when, then
|
197
|
+
expect {
|
198
|
+
rootmodel.add_deal(not_a_deal)
|
199
|
+
}.to raise_error(ArgumentError)
|
200
|
+
rootmodel.deals.length.should eq 0
|
201
|
+
end
|
202
|
+
|
203
|
+
it "will set reponsible coworker to migrator_coworker if none specifed" do
|
204
|
+
# given
|
205
|
+
deal = MoveToGo::Deal.new
|
206
|
+
deal.integration_id = "123key"
|
207
|
+
deal.name = "Big deal"
|
208
|
+
|
209
|
+
# when
|
210
|
+
rootmodel.add_deal(deal)
|
211
|
+
|
212
|
+
# then
|
213
|
+
deal.responsible_coworker.integration_id.should eq rootmodel.migrator_coworker.integration_id
|
214
|
+
end
|
215
|
+
|
216
|
+
it "will not set reponsible coworker to migrator_coworker if specifed" do
|
217
|
+
# given
|
218
|
+
deal = MoveToGo::Deal.new
|
219
|
+
deal.integration_id = "123key"
|
220
|
+
deal.name = "Big deal"
|
221
|
+
coworker = MoveToGo::Coworker.new
|
222
|
+
coworker.integration_id = "123"
|
223
|
+
deal.responsible_coworker = coworker
|
224
|
+
|
225
|
+
# when
|
226
|
+
rootmodel.add_deal(deal)
|
227
|
+
|
228
|
+
# then
|
229
|
+
deal.responsible_coworker.integration_id.should eq coworker.integration_id
|
230
|
+
end
|
231
|
+
|
232
|
+
it "will not set responsible coworker to migrator_coworker if allowed" do
|
233
|
+
# given
|
234
|
+
deal = MoveToGo::Deal.new
|
235
|
+
deal.integration_id = "123key"
|
236
|
+
deal.name = "Big Deal"
|
237
|
+
|
238
|
+
rootmodel.configuration[:allow_deals_without_responsible] = true
|
239
|
+
|
240
|
+
# when
|
241
|
+
rootmodel.add_deal(deal)
|
242
|
+
|
243
|
+
# then
|
244
|
+
deal.responsible_coworker.should eq nil
|
245
|
+
end
|
246
|
+
|
247
|
+
it "will set responsible coworker to migrator_coworker if configured" do
|
248
|
+
# given
|
249
|
+
deal = MoveToGo::Deal.new
|
250
|
+
deal.integration_id = "123key"
|
251
|
+
deal.name = "Big Deal"
|
252
|
+
|
253
|
+
rootmodel.configuration[:allow_deals_without_responsible] = false
|
254
|
+
|
255
|
+
# when
|
256
|
+
rootmodel.add_deal(deal)
|
257
|
+
|
258
|
+
# then
|
259
|
+
deal.responsible_coworker.integration_id.should eq rootmodel.migrator_coworker.integration_id
|
260
|
+
end
|
261
|
+
|
262
|
+
it "will not add a new deal when the deal is already added (same integration id)" do
|
263
|
+
# given
|
264
|
+
deal1 = MoveToGo::Deal.new({
|
265
|
+
:integration_id => "123key",
|
266
|
+
:name => "Big deal"
|
267
|
+
})
|
268
|
+
rootmodel.add_deal(deal1)
|
269
|
+
rootmodel.deals.length.should eq 1
|
270
|
+
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
271
|
+
|
272
|
+
# when, then
|
273
|
+
deal2 = MoveToGo::Deal.new({
|
274
|
+
:integration_id => "123key",
|
275
|
+
:name => "Bigger deal"
|
276
|
+
})
|
277
|
+
expect {
|
278
|
+
rootmodel.add_deal(deal2)
|
279
|
+
}.to raise_error(MoveToGo::AlreadyAddedError)
|
280
|
+
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
281
|
+
rootmodel.deals.length.should eq 1
|
282
|
+
end
|
283
|
+
|
284
|
+
it "will not add a deal when integration_id is nil" do
|
285
|
+
# given
|
286
|
+
deal = MoveToGo::Deal.new
|
287
|
+
deal.name = "The new deal"
|
288
|
+
deal.integration_id = nil
|
289
|
+
|
290
|
+
# when, then
|
291
|
+
expect {
|
292
|
+
rootmodel.add_deal(deal)
|
293
|
+
}.to raise_error(MoveToGo::IntegrationIdIsRequiredError)
|
294
|
+
end
|
295
|
+
|
296
|
+
it "will not add a deal when integration_id is empty" do
|
297
|
+
# given
|
298
|
+
deal = MoveToGo::Deal.new
|
299
|
+
deal.name = "The new deal"
|
300
|
+
deal.integration_id = ""
|
301
|
+
|
302
|
+
# when, then
|
303
|
+
expect {
|
304
|
+
rootmodel.add_deal(deal)
|
305
|
+
}.to raise_error(MoveToGo::IntegrationIdIsRequiredError)
|
306
|
+
end
|
307
|
+
|
308
|
+
it "will add comment" do
|
309
|
+
# given
|
310
|
+
comment = MoveToGo::Comment.new
|
311
|
+
comment.text = "this is a comment"
|
312
|
+
|
313
|
+
# when
|
314
|
+
rootmodel.add_comment(comment)
|
315
|
+
|
316
|
+
# then
|
317
|
+
rootmodel.histories.length.should eq 1
|
318
|
+
rootmodel.histories["0"].is_a?(MoveToGo::Comment).should eq true
|
319
|
+
end
|
320
|
+
|
321
|
+
it "will add sales call" do
|
322
|
+
# given
|
323
|
+
salesCall = MoveToGo::SalesCall.new
|
324
|
+
salesCall.text = "this is a sales call"
|
325
|
+
|
326
|
+
# when
|
327
|
+
rootmodel.add_sales_call(salesCall)
|
328
|
+
|
329
|
+
# then
|
330
|
+
rootmodel.histories.length.should eq 1
|
331
|
+
rootmodel.histories["0"].is_a?(MoveToGo::SalesCall).should eq true
|
332
|
+
end
|
333
|
+
|
334
|
+
it "will add talked to" do
|
335
|
+
# given
|
336
|
+
talkedTo = MoveToGo::TalkedTo.new
|
337
|
+
talkedTo.text = "this is a sales call"
|
338
|
+
|
339
|
+
# when
|
340
|
+
rootmodel.add_talked_to(talkedTo)
|
341
|
+
|
342
|
+
# then
|
343
|
+
rootmodel.histories.length.should eq 1
|
344
|
+
rootmodel.histories["0"].is_a?(MoveToGo::TalkedTo).should eq true
|
345
|
+
end
|
346
|
+
|
347
|
+
it "will add tried to reach" do
|
348
|
+
# given
|
349
|
+
triedToReach = MoveToGo::TriedToReach.new
|
350
|
+
triedToReach.text = "this is a sales call"
|
351
|
+
|
352
|
+
# when
|
353
|
+
rootmodel.add_tried_to_reach(triedToReach)
|
354
|
+
|
355
|
+
# then
|
356
|
+
rootmodel.histories.length.should eq 1
|
357
|
+
rootmodel.histories["0"].is_a?(MoveToGo::TriedToReach).should eq true
|
358
|
+
end
|
359
|
+
|
360
|
+
it "will add client visit" do
|
361
|
+
# given
|
362
|
+
clientVisit = MoveToGo::ClientVisit.new
|
363
|
+
clientVisit.text = "this is a client visit"
|
364
|
+
|
365
|
+
# when
|
366
|
+
rootmodel.add_client_visit(clientVisit)
|
367
|
+
|
368
|
+
# then
|
369
|
+
rootmodel.histories.length.should eq 1
|
370
|
+
rootmodel.histories["0"].is_a?(MoveToGo::ClientVisit).should eq true
|
371
|
+
end
|
372
|
+
|
373
|
+
it "will only add comment" do
|
374
|
+
# given
|
375
|
+
not_a_comment = { :integration_id => "123", :text => "This is not a comment"}
|
376
|
+
|
377
|
+
# when, then
|
378
|
+
expect {
|
379
|
+
rootmodel.add_comment(not_a_comment)
|
380
|
+
}.to raise_error(ArgumentError)
|
381
|
+
rootmodel.histories.length.should eq 0
|
382
|
+
end
|
383
|
+
|
384
|
+
it "will make comment immutable after it has been added" do
|
385
|
+
# given
|
386
|
+
comment = MoveToGo::Comment.new
|
387
|
+
comment.text = "this is a comment"
|
388
|
+
|
389
|
+
# when
|
390
|
+
rootmodel.add_comment(comment)
|
391
|
+
|
392
|
+
# then
|
393
|
+
comment.is_immutable.should eq true
|
394
|
+
end
|
395
|
+
|
396
|
+
it "can add a comment from a new comment" do
|
397
|
+
# given
|
398
|
+
comment = MoveToGo::Comment.new
|
399
|
+
comment.integration_id = "123key"
|
400
|
+
comment.text = "This is a comment"
|
401
|
+
|
402
|
+
# when
|
403
|
+
rootmodel.add_comment(comment)
|
404
|
+
|
405
|
+
# then
|
406
|
+
rootmodel.find_history_by_integration_id("123key").text.should eq "This is a comment"
|
407
|
+
rootmodel.histories.length.should eq 1
|
408
|
+
end
|
409
|
+
|
410
|
+
it "will generate an integration id if the new comment dont have one" do
|
411
|
+
# given
|
412
|
+
comment = MoveToGo::Comment.new
|
413
|
+
comment.text = "This is a comment"
|
414
|
+
|
415
|
+
# when
|
416
|
+
rootmodel.add_comment(comment)
|
417
|
+
|
418
|
+
# then
|
419
|
+
comment.integration_id.length.should be > 0
|
420
|
+
end
|
421
|
+
|
422
|
+
it "will generate unique integration ids for each history" do
|
423
|
+
# given
|
424
|
+
comment1 = MoveToGo::Comment.new
|
425
|
+
comment1.text = "This is a history"
|
426
|
+
|
427
|
+
comment2 = MoveToGo::Comment.new
|
428
|
+
comment2.text = "This is a different history"
|
429
|
+
|
430
|
+
# when
|
431
|
+
rootmodel.add_comment(comment1)
|
432
|
+
rootmodel.add_comment(comment2)
|
433
|
+
|
434
|
+
# then
|
435
|
+
comment1.integration_id.should be != comment2.integration_id
|
436
|
+
end
|
437
|
+
|
438
|
+
it "will not add a nil history" do
|
439
|
+
# given, when
|
440
|
+
rootmodel.add_comment(nil)
|
441
|
+
|
442
|
+
# then
|
443
|
+
rootmodel.histories.length.should eq 0
|
444
|
+
end
|
445
|
+
|
446
|
+
it "will not add a nil organization" do
|
447
|
+
# given, when
|
448
|
+
rootmodel.add_organization(nil)
|
449
|
+
|
450
|
+
# then
|
451
|
+
rootmodel.organizations.length.should eq 0
|
452
|
+
end
|
453
|
+
|
454
|
+
it "will not add a nil deal" do
|
455
|
+
# given, when
|
456
|
+
rootmodel.add_deal(nil)
|
457
|
+
|
458
|
+
# then
|
459
|
+
rootmodel.deals.length.should eq 0
|
460
|
+
end
|
461
|
+
|
462
|
+
it "will not add a nil coworker" do
|
463
|
+
# given, when
|
464
|
+
rootmodel.add_coworker(nil)
|
465
|
+
|
466
|
+
# then
|
467
|
+
# 1 since we always have the migrator coworker
|
468
|
+
rootmodel.coworkers.length.should eq 1
|
469
|
+
end
|
470
|
+
|
471
|
+
it "will add a new link" do
|
472
|
+
# given
|
473
|
+
link = MoveToGo::Link.new
|
474
|
+
link.integration_id = "123key"
|
475
|
+
link.url = "http://dropbox.com/files/readme.txt"
|
476
|
+
|
477
|
+
# when
|
478
|
+
rootmodel.add_link link
|
479
|
+
|
480
|
+
# then
|
481
|
+
rootmodel.documents.find_link_by_integration_id("123key").url.should eq "http://dropbox.com/files/readme.txt"
|
482
|
+
rootmodel.documents.links.length.should eq 1
|
483
|
+
end
|
484
|
+
|
485
|
+
it "will add a new file" do
|
486
|
+
# given
|
487
|
+
file = MoveToGo::File.new
|
488
|
+
file.integration_id = "123key"
|
489
|
+
file.path = "k:\kontakt\databas\dokument"
|
490
|
+
|
491
|
+
# when
|
492
|
+
rootmodel.add_file file
|
493
|
+
|
494
|
+
# then
|
495
|
+
rootmodel.documents.find_file_by_integration_id("123key").path.should eq "k:\kontakt\databas\dokument"
|
496
|
+
rootmodel.documents.files.length.should eq 1
|
497
|
+
end
|
498
|
+
|
499
|
+
it "will not add a new comment when the comment is already added (same integration id)" do
|
500
|
+
# given
|
501
|
+
comment = MoveToGo::Comment.new({
|
502
|
+
:integration_id => "123key",
|
503
|
+
:text => "This is a comment"
|
504
|
+
})
|
505
|
+
rootmodel.add_comment(comment)
|
506
|
+
rootmodel.histories.length.should eq 1
|
507
|
+
|
508
|
+
# when, then
|
509
|
+
comment2 = MoveToGo::Comment.new({
|
510
|
+
:integration_id => "123key",
|
511
|
+
:text => "This is another comment"
|
512
|
+
})
|
513
|
+
expect {
|
514
|
+
rootmodel.add_comment(comment2)
|
515
|
+
}.to raise_error(MoveToGo::AlreadyAddedError)
|
516
|
+
rootmodel.histories.length.should eq 1
|
517
|
+
rootmodel.find_history_by_integration_id("123key").text.should eq "This is a comment"
|
518
|
+
end
|
519
|
+
|
520
|
+
it "Will find a person by integration id" do
|
521
|
+
# given
|
522
|
+
organization = MoveToGo::Organization.new
|
523
|
+
organization.name = "Hubba Bubba"
|
524
|
+
organization.integration_id = "321"
|
525
|
+
organization.add_employee({
|
526
|
+
:integration_id => "123",
|
527
|
+
:first_name => "Billy",
|
528
|
+
:last_name => "Bob"
|
529
|
+
})
|
530
|
+
|
531
|
+
rootmodel.add_organization(organization)
|
532
|
+
|
533
|
+
# when
|
534
|
+
found_person = rootmodel.find_person_by_integration_id("123")
|
535
|
+
|
536
|
+
# then
|
537
|
+
found_person.integration_id.should eq "123"
|
538
|
+
found_person.first_name.should eq "Billy"
|
539
|
+
found_person.last_name.should eq "Bob"
|
540
|
+
end
|
541
|
+
|
542
|
+
it "Will will not find a person by wrong integration id" do
|
543
|
+
# given
|
544
|
+
organization = MoveToGo::Organization.new
|
545
|
+
organization.name = "Hubba Bubba"
|
546
|
+
organization.integration_id = "321"
|
547
|
+
organization.add_employee({
|
548
|
+
:integration_id => "123",
|
549
|
+
:first_name => "Billy",
|
550
|
+
:last_name => "Bob"
|
551
|
+
})
|
552
|
+
|
553
|
+
rootmodel.add_organization(organization)
|
554
|
+
|
555
|
+
# when
|
556
|
+
found_person = rootmodel.find_person_by_integration_id("321")
|
557
|
+
|
558
|
+
# then
|
559
|
+
found_person.should eq nil
|
560
|
+
|
561
|
+
end
|
562
|
+
|
563
|
+
it "Will find a person by integration id from an organization with many employees" do
|
564
|
+
# given
|
565
|
+
organization = MoveToGo::Organization.new
|
566
|
+
organization.name = "Hubba Bubba"
|
567
|
+
organization.integration_id = "321"
|
568
|
+
organization.add_employee({
|
569
|
+
:integration_id => "123",
|
570
|
+
:first_name => "Billy",
|
571
|
+
:last_name => "Bob"
|
572
|
+
})
|
573
|
+
organization.add_employee({
|
574
|
+
:integration_id => "456",
|
575
|
+
:first_name => "Vincent",
|
576
|
+
:last_name => "Vega"
|
577
|
+
})
|
578
|
+
|
579
|
+
rootmodel.add_organization(organization)
|
580
|
+
|
581
|
+
# when
|
582
|
+
found_person = rootmodel.find_person_by_integration_id("123")
|
583
|
+
|
584
|
+
# then
|
585
|
+
found_person.integration_id.should eq "123"
|
586
|
+
found_person.first_name.should eq "Billy"
|
587
|
+
found_person.last_name.should eq "Bob"
|
588
|
+
end
|
589
|
+
|
590
|
+
it "will have correct count on number of persons" do
|
591
|
+
# given
|
592
|
+
organization = MoveToGo::Organization.new
|
593
|
+
organization.name = "Hubba Bubba"
|
594
|
+
organization.integration_id = "321"
|
595
|
+
organization.add_employee({
|
596
|
+
:integration_id => "123",
|
597
|
+
:first_name => "Billy",
|
598
|
+
:last_name => "Bob"
|
599
|
+
})
|
600
|
+
organization.add_employee({
|
601
|
+
:integration_id => "456",
|
602
|
+
:first_name => "Vincent",
|
603
|
+
:last_name => "Vega"
|
604
|
+
})
|
605
|
+
|
606
|
+
rootmodel.add_organization(organization)
|
607
|
+
|
608
|
+
# when
|
609
|
+
persons = rootmodel.persons
|
610
|
+
|
611
|
+
# then
|
612
|
+
persons.length.should eq 2
|
613
|
+
|
614
|
+
end
|
615
|
+
|
616
|
+
it "will report when two links has the same integration id during sanity check" do
|
617
|
+
# given
|
618
|
+
link1 = MoveToGo::Link.new
|
619
|
+
link1.integration_id = "1"
|
620
|
+
|
621
|
+
link2 = MoveToGo::Link.new
|
622
|
+
link2.integration_id = "2"
|
623
|
+
|
624
|
+
rootmodel.add_link link1
|
625
|
+
rootmodel.add_link link2
|
626
|
+
|
627
|
+
# when
|
628
|
+
link2.integration_id = "1"
|
629
|
+
|
630
|
+
# then
|
631
|
+
rootmodel.sanity_check.should eq "Duplicate link integration_id: 1."
|
632
|
+
end
|
633
|
+
|
634
|
+
it "will find an organization based on a property" do
|
635
|
+
# given
|
636
|
+
organization = MoveToGo::Organization.new
|
637
|
+
organization.name = "Hubba Bubba"
|
638
|
+
organization.integration_id = "321"
|
639
|
+
rootmodel.add_organization(organization)
|
640
|
+
|
641
|
+
organization2 = MoveToGo::Organization.new
|
642
|
+
organization2.name = "Bongo bong"
|
643
|
+
organization2.integration_id = "123"
|
644
|
+
rootmodel.add_organization(organization2)
|
645
|
+
|
646
|
+
# when
|
647
|
+
result = rootmodel.find_organization{|org| org.name == "Hubba Bubba"}
|
648
|
+
|
649
|
+
# then
|
650
|
+
result.should eq organization
|
651
|
+
end
|
652
|
+
|
653
|
+
it "will return nil if it doesn't find an organization on a property" do
|
654
|
+
# given
|
655
|
+
organization = MoveToGo::Organization.new
|
656
|
+
organization.name = "Hubba Bubba"
|
657
|
+
organization.integration_id = "321"
|
658
|
+
rootmodel.add_organization(organization)
|
659
|
+
|
660
|
+
organization2 = MoveToGo::Organization.new
|
661
|
+
organization2.name = "Bongo bong"
|
662
|
+
organization2.integration_id = "123"
|
663
|
+
rootmodel.add_organization(organization2)
|
664
|
+
|
665
|
+
# when
|
666
|
+
result = rootmodel.find_organization{|org| org.name == "Nope"}
|
667
|
+
|
668
|
+
# then
|
669
|
+
result.should eq nil
|
670
|
+
end
|
671
|
+
|
672
|
+
it "will find an person based on a property" do
|
673
|
+
# given
|
674
|
+
organization = MoveToGo::Organization.new
|
675
|
+
organization.name = "Hubba Bubba"
|
676
|
+
organization.integration_id = "321"
|
677
|
+
rootmodel.add_organization(organization)
|
678
|
+
|
679
|
+
person = MoveToGo::Person.new
|
680
|
+
person.first_name = "Kalle"
|
681
|
+
person.email = "kalle@kula.se"
|
682
|
+
|
683
|
+
organization.add_employee(person)
|
684
|
+
|
685
|
+
# when
|
686
|
+
result = rootmodel.find_person{|per| per.email == "kalle@kula.se"}
|
687
|
+
|
688
|
+
# then
|
689
|
+
result.should eq person
|
690
|
+
end
|
691
|
+
|
692
|
+
it "will return nil if it doesn't find a person on a property" do
|
693
|
+
# given
|
694
|
+
organization = MoveToGo::Organization.new
|
695
|
+
organization.name = "Hubba Bubba"
|
696
|
+
organization.integration_id = "321"
|
697
|
+
rootmodel.add_organization(organization)
|
698
|
+
|
699
|
+
person = MoveToGo::Person.new
|
700
|
+
person.first_name = "Kalle"
|
701
|
+
person.email = "kalle@kula.se"
|
702
|
+
|
703
|
+
organization.add_employee(person)
|
704
|
+
|
705
|
+
# when
|
706
|
+
result = rootmodel.find_person{|per| per.email == "john@appleseed.com"}
|
707
|
+
|
708
|
+
# then
|
709
|
+
result.should eq nil
|
710
|
+
end
|
711
|
+
|
712
|
+
it "will find an deal based on a property" do
|
713
|
+
# given
|
714
|
+
deal = MoveToGo::Deal.new
|
715
|
+
deal.name = "Big Deal"
|
716
|
+
deal.integration_id = "321"
|
717
|
+
deal.value = 23456789
|
718
|
+
rootmodel.add_deal(deal)
|
719
|
+
|
720
|
+
# when
|
721
|
+
result = rootmodel.find_deal{|d| d.name == "Big Deal"}
|
722
|
+
|
723
|
+
# then
|
724
|
+
result.should eq deal
|
725
|
+
end
|
726
|
+
|
727
|
+
it "will return nil if it doesn't find a deal on a property" do
|
728
|
+
# given
|
729
|
+
deal = MoveToGo::Deal.new
|
730
|
+
deal.name = "Big Deal"
|
731
|
+
deal.integration_id = "321"
|
732
|
+
deal.value = 23456789
|
733
|
+
rootmodel.add_deal(deal)
|
734
|
+
|
735
|
+
# when
|
736
|
+
result = rootmodel.find_deal{|d| d.value == 0}
|
737
|
+
|
738
|
+
# then
|
739
|
+
result.should eq nil
|
740
|
+
end
|
741
|
+
|
742
|
+
it "will find an comment based on a property" do
|
743
|
+
# given
|
744
|
+
organization = MoveToGo::Organization.new
|
745
|
+
organization.name = "Hubba Bubba"
|
746
|
+
organization.integration_id = "321"
|
747
|
+
rootmodel.add_organization(organization)
|
748
|
+
|
749
|
+
comment = MoveToGo::Comment.new
|
750
|
+
comment.text = "Hello!"
|
751
|
+
comment.organization = organization
|
752
|
+
|
753
|
+
rootmodel.add_comment(comment)
|
754
|
+
# when
|
755
|
+
result = rootmodel.find_history{|n| n.text == "Hello!"}
|
756
|
+
|
757
|
+
# then
|
758
|
+
result.should eq comment
|
759
|
+
end
|
760
|
+
|
761
|
+
it "will return nil if it doesn't find a history on a property" do
|
762
|
+
# given
|
763
|
+
organization = MoveToGo::Organization.new
|
764
|
+
organization.name = "Hubba Bubba"
|
765
|
+
organization.integration_id = "321"
|
766
|
+
rootmodel.add_organization(organization)
|
767
|
+
|
768
|
+
comment = MoveToGo::Comment.new
|
769
|
+
comment.text = "Hello!"
|
770
|
+
comment.organization = organization
|
771
|
+
|
772
|
+
rootmodel.add_comment(comment)
|
773
|
+
# when
|
774
|
+
result = rootmodel.find_history{|n| n.text == "Goodbye!"}
|
775
|
+
|
776
|
+
# then
|
777
|
+
result.should eq nil
|
778
|
+
end
|
779
|
+
|
780
|
+
it "will find an document based on a property" do
|
781
|
+
# given
|
782
|
+
organization = MoveToGo::Organization.new
|
783
|
+
organization.name = "Hubba Bubba"
|
784
|
+
organization.integration_id = "321"
|
785
|
+
rootmodel.add_organization(organization)
|
786
|
+
|
787
|
+
link = MoveToGo::Link.new
|
788
|
+
link.name = "Tender"
|
789
|
+
link.integration_id = "123"
|
790
|
+
link.url = "https://go.lime-go.com"
|
791
|
+
link.organization = organization
|
792
|
+
|
793
|
+
rootmodel.documents.add_link(link)
|
794
|
+
# when
|
795
|
+
result = rootmodel.find_document(:link){|l| l.url == "https://go.lime-go.com"}
|
796
|
+
|
797
|
+
# then
|
798
|
+
result.should eq link
|
799
|
+
end
|
800
|
+
|
801
|
+
it "will return nil if it doesn't find a document on a property" do
|
802
|
+
# given
|
803
|
+
organization = MoveToGo::Organization.new
|
804
|
+
organization.name = "Hubba Bubba"
|
805
|
+
organization.integration_id = "321"
|
806
|
+
rootmodel.add_organization(organization)
|
807
|
+
|
808
|
+
link = MoveToGo::Link.new
|
809
|
+
link.name = "Tender"
|
810
|
+
link.integration_id = "123"
|
811
|
+
link.url = "https://go.lime-go.com"
|
812
|
+
link.organization = organization
|
813
|
+
|
814
|
+
rootmodel.documents.add_link(link)
|
815
|
+
# when
|
816
|
+
result = rootmodel.find_document(:link){|l| l.name == "Contract"}
|
817
|
+
|
818
|
+
# then
|
819
|
+
result.should eq nil
|
820
|
+
end
|
821
|
+
|
822
|
+
it "will find companies based on their property" do
|
823
|
+
# given
|
824
|
+
organization = MoveToGo::Organization.new
|
825
|
+
organization.name = "Hubba Bubba"
|
826
|
+
organization.integration_id = "321"
|
827
|
+
rootmodel.add_organization(organization)
|
828
|
+
|
829
|
+
organization = MoveToGo::Organization.new
|
830
|
+
organization.name = "Hubba Bubba"
|
831
|
+
organization.integration_id = "123"
|
832
|
+
rootmodel.add_organization(organization)
|
833
|
+
# when
|
834
|
+
result = rootmodel.select_organizations{|org| org.name == "Hubba Bubba"}
|
835
|
+
|
836
|
+
# then
|
837
|
+
result.length.should eq 2
|
838
|
+
end
|
839
|
+
|
840
|
+
it "will return empty array if it doesn't find any organization on a property" do
|
841
|
+
# given
|
842
|
+
organization = MoveToGo::Organization.new
|
843
|
+
organization.name = "Hubba Bubba"
|
844
|
+
organization.integration_id = "321"
|
845
|
+
rootmodel.add_organization(organization)
|
846
|
+
|
847
|
+
organization = MoveToGo::Organization.new
|
848
|
+
organization.name = "Hubba Bubba"
|
849
|
+
organization.integration_id = "123"
|
850
|
+
rootmodel.add_organization(organization)
|
851
|
+
# when
|
852
|
+
result = rootmodel.select_organizations{|org| org.name == "Hubba"}
|
853
|
+
|
854
|
+
# then
|
855
|
+
result.should eq []
|
856
|
+
end
|
857
|
+
|
858
|
+
it "will find persons based on their property" do
|
859
|
+
# given
|
860
|
+
organization = MoveToGo::Organization.new
|
861
|
+
organization.name = "Hubba Bubba"
|
862
|
+
organization.integration_id = "321"
|
863
|
+
rootmodel.add_organization(organization)
|
864
|
+
person = MoveToGo::Person.new
|
865
|
+
person.first_name = "Kalle"
|
866
|
+
person.email = "kalle@kula.se"
|
867
|
+
person.position = "Chief"
|
868
|
+
organization.add_employee(person)
|
869
|
+
|
870
|
+
organization = MoveToGo::Organization.new
|
871
|
+
organization.name = "Bongo Bong"
|
872
|
+
organization.integration_id = "123"
|
873
|
+
rootmodel.add_organization(organization)
|
874
|
+
person = MoveToGo::Person.new
|
875
|
+
person.first_name = "Nisse"
|
876
|
+
person.email = "nisse@elf.com"
|
877
|
+
person.position = "Chief"
|
878
|
+
organization.add_employee(person)
|
879
|
+
|
880
|
+
# when
|
881
|
+
result = rootmodel.select_persons{|per| per.position == "Chief"}
|
882
|
+
# then
|
883
|
+
result.length.should eq 2
|
884
|
+
end
|
885
|
+
|
886
|
+
it "will return empty array if it doesn't find any persons on their property" do
|
887
|
+
# given
|
888
|
+
organization = MoveToGo::Organization.new
|
889
|
+
organization.name = "Hubba Bubba"
|
890
|
+
organization.integration_id = "321"
|
891
|
+
rootmodel.add_organization(organization)
|
892
|
+
person = MoveToGo::Person.new
|
893
|
+
person.first_name = "Kalle"
|
894
|
+
person.email = "kalle@kula.se"
|
895
|
+
person.position = "Chief"
|
896
|
+
organization.add_employee(person)
|
897
|
+
|
898
|
+
organization = MoveToGo::Organization.new
|
899
|
+
organization.name = "Bongo Bong"
|
900
|
+
organization.integration_id = "123"
|
901
|
+
rootmodel.add_organization(organization)
|
902
|
+
person = MoveToGo::Person.new
|
903
|
+
person.first_name = "Nisse"
|
904
|
+
person.email = "nisse@elf.com"
|
905
|
+
person.position = "Chief"
|
906
|
+
organization.add_employee(person)
|
907
|
+
|
908
|
+
# when
|
909
|
+
result = rootmodel.select_persons{|per| per.position == "Slave"}
|
910
|
+
|
911
|
+
# then
|
912
|
+
result.should eq []
|
913
|
+
end
|
914
|
+
|
915
|
+
it "will find coworker based on their property" do
|
916
|
+
# when
|
917
|
+
coworker1 = MoveToGo::Coworker.new({
|
918
|
+
:integration_id => "111key",
|
919
|
+
:first_name => "Kalle",
|
920
|
+
:last_name => "Anka",
|
921
|
+
:email => "kalle.anka@vonanka.com"
|
922
|
+
})
|
923
|
+
coworker2 = MoveToGo::Coworker.new({
|
924
|
+
|
925
|
+
:integration_id => "222key",
|
926
|
+
:first_name => "Knatte",
|
927
|
+
:last_name => "Anka",
|
928
|
+
:email => "knatte.anka@vonanka.com"
|
929
|
+
})
|
930
|
+
rootmodel.add_coworker(coworker1)
|
931
|
+
rootmodel.add_coworker(coworker2)
|
932
|
+
|
933
|
+
# then
|
934
|
+
result = rootmodel.find_coworker{|coworker| coworker.email == "knatte.anka@vonanka.com"}
|
935
|
+
result.should eq coworker2
|
936
|
+
end
|
937
|
+
|
938
|
+
it "will return nil if it doesn't find an coworker on a property" do
|
939
|
+
# when
|
940
|
+
coworker1 = MoveToGo::Coworker.new({
|
941
|
+
:integration_id => "111key",
|
942
|
+
:first_name => "Kalle",
|
943
|
+
:last_name => "Anka",
|
944
|
+
:email => "kalle.anka@vonanka.com"
|
945
|
+
})
|
946
|
+
rootmodel.add_coworker(coworker1)
|
947
|
+
|
948
|
+
# then
|
949
|
+
result = rootmodel.find_coworker{|coworker| coworker.email == "Kall"}
|
950
|
+
result.should eq nil
|
951
|
+
end
|
952
|
+
|
953
|
+
it "will find deals based on their property" do
|
954
|
+
# given
|
955
|
+
deal = MoveToGo::Deal.new
|
956
|
+
deal.name = "Big Deal"
|
957
|
+
deal.value = 1234
|
958
|
+
deal.integration_id = "1"
|
959
|
+
rootmodel.add_deal deal
|
960
|
+
|
961
|
+
deal = MoveToGo::Deal.new
|
962
|
+
deal.name = "Bigger Deal"
|
963
|
+
deal.value = 1234
|
964
|
+
deal.integration_id = "2"
|
965
|
+
rootmodel.add_deal deal
|
966
|
+
|
967
|
+
# when
|
968
|
+
result = rootmodel.select_deals{|d| d.value == "1234"}
|
969
|
+
# then
|
970
|
+
result.length.should eq 2
|
971
|
+
end
|
972
|
+
|
973
|
+
it "will return empty array if it doesn't find any persons on their property" do
|
974
|
+
# given
|
975
|
+
deal = MoveToGo::Deal.new
|
976
|
+
deal.name = "Big Deal"
|
977
|
+
deal.value = 1234
|
978
|
+
deal.integration_id = "1"
|
979
|
+
rootmodel.add_deal deal
|
980
|
+
|
981
|
+
deal = MoveToGo::Deal.new
|
982
|
+
deal.name = "Bigger Deal"
|
983
|
+
deal.value = 1234
|
984
|
+
deal.integration_id = "2"
|
985
|
+
rootmodel.add_deal deal
|
986
|
+
|
987
|
+
# when
|
988
|
+
result = rootmodel.select_deals{|d| d.name == "Small deal"}
|
989
|
+
|
990
|
+
# then
|
991
|
+
result.should eq []
|
992
|
+
end
|
993
|
+
end
|