move-to-go 5.0.8 → 5.0.9
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.
- checksums.yaml +4 -4
- data/bin/move-to-go +1 -1
- data/lib/move-to-go/model/organization.rb +5 -0
- data/lib/move-to-go/model/organizations.rb +1 -1
- data/lib/move-to-go/model/rootmodel.rb +7 -1
- data/sources/excel-basic/.move-to-go/runner.rb +1 -1
- data/sources/excel/.move-to-go/runner.rb +1 -1
- data/spec/organization_spec.rb +67 -1
- data/spec/organizations_spec.rb +110 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9e05bc5cacd47a93cfcab58ba59379935ab673
|
4
|
+
data.tar.gz: 0f96da4e936571891779922478eb2963259ea1f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc42acb7eedf6a8c9495a8cdd03d22f24bc78d0777b254b13bf2dc85b6b573aaa1e309a3011d7e49bbeeb110dcd9dbfb5895f35a87276dd59ab763a72c31d589
|
7
|
+
data.tar.gz: 5ead308750e781c528ba4392e79743935b06fff7d8c3fb2219693388a4195a6bc884a0cc011a2751dd3b3a779e1eb6de13a90666864508402e9d70b5a05c8e80
|
data/bin/move-to-go
CHANGED
@@ -138,7 +138,7 @@ class MoveToGoCommandLine < Thor
|
|
138
138
|
puts "Checking for duplicate organizations..."
|
139
139
|
possible_duplicates = model.organizations.find_duplicates_by(:name, :organization_number)
|
140
140
|
puts "Found #{possible_duplicates.length} organization duplicate sets in rootmodel, based on name and organization number"
|
141
|
-
|
141
|
+
|
142
142
|
puts "Starting sharding of model..."
|
143
143
|
sharder = MoveToGo::ShardHelper.new(options.shard_size)
|
144
144
|
models_to_serialize = sharder.shard_model(model)
|
@@ -69,6 +69,9 @@ module MoveToGo
|
|
69
69
|
# :attr_accessor: central_phone_number
|
70
70
|
immutable_accessor :central_phone_number
|
71
71
|
##
|
72
|
+
# :attr_accessor: source
|
73
|
+
immutable_accessor :source
|
74
|
+
##
|
72
75
|
# :attr_accessor: source_data
|
73
76
|
immutable_accessor :source_data
|
74
77
|
attr_accessor :rootmodel
|
@@ -269,6 +272,8 @@ module MoveToGo
|
|
269
272
|
if !@source.nil?
|
270
273
|
if @source.id.nil? || @source.id == ""
|
271
274
|
error = "#{error}\nReference to source must have an id"
|
275
|
+
elsif @source.id !~ /^\d{1}\d*:{1}\d{1}\d*$/
|
276
|
+
error = "#{error}\nInvalid source id '#{@source.id}', must have one ':' and only digits allowed, example '1:200010'"
|
272
277
|
end
|
273
278
|
end
|
274
279
|
|
@@ -59,7 +59,7 @@ module MoveToGo
|
|
59
59
|
when Symbol then val = org.instance_variable_get(field)
|
60
60
|
when Array then val = org.instance_variable_get(field[0]).instance_variable_get(field[1])
|
61
61
|
end
|
62
|
-
val != nil ? val.downcase.strip : val = ''
|
62
|
+
val != nil ? val.to_s.downcase.strip : val = ''
|
63
63
|
}
|
64
64
|
}
|
65
65
|
.select { |k, v| v.size > 1 }
|
@@ -31,7 +31,7 @@ module MoveToGo
|
|
31
31
|
{:id => :organizations, :type => :organizations},
|
32
32
|
{:id => :deals, :type => :deals},
|
33
33
|
{:id => :histories, :type => :histories},
|
34
|
-
{:id => :documents, :type => :documents}
|
34
|
+
{:id => :documents, :type => :documents}
|
35
35
|
]
|
36
36
|
end
|
37
37
|
|
@@ -117,6 +117,12 @@ module MoveToGo
|
|
117
117
|
raise AlreadyAddedError, "Already added an organization with integration_id #{organization.integration_id}"
|
118
118
|
end
|
119
119
|
|
120
|
+
if !organization.source.nil?
|
121
|
+
if !@organizations.find{|key,value| value.source.id == organization.source.id if !value.source.nil?}.nil?
|
122
|
+
raise AlreadyAddedError, "Source id already exists, sourceId: #{organization.source.id}"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
120
126
|
@organizations[organization.integration_id] = organization
|
121
127
|
organization.rootmodel = self
|
122
128
|
organization.set_is_immutable
|
@@ -35,7 +35,6 @@ def convert_source
|
|
35
35
|
if defined?(ORGANIZATION_SHEET)
|
36
36
|
if excel_workbook.has_sheet?(ORGANIZATION_SHEET)
|
37
37
|
organization_rows = excel_workbook.rows_for_sheet ORGANIZATION_SHEET
|
38
|
-
converter.organization_hook(row, organization, rootmodel) if defined? converter.organization_hook
|
39
38
|
else
|
40
39
|
puts "WARNING: can't find sheet '#{ORGANIZATION_SHEET}'"
|
41
40
|
end
|
@@ -97,6 +96,7 @@ def convert_source
|
|
97
96
|
organization_rows.each do |row|
|
98
97
|
organization = converter.to_organization(row, rootmodel)
|
99
98
|
rootmodel.add_organization(organization)
|
99
|
+
converter.organization_hook(row, organization, rootmodel) if defined? converter.organization_hook
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -36,7 +36,6 @@ def convert_source
|
|
36
36
|
if defined?(ORGANIZATION_SHEET)
|
37
37
|
if excel_workbook.has_sheet?(ORGANIZATION_SHEET)
|
38
38
|
organization_rows = excel_workbook.rows_for_sheet ORGANIZATION_SHEET
|
39
|
-
converter.organization_hook(row, organization, rootmodel) if defined? converter.organization_hook
|
40
39
|
else
|
41
40
|
puts "WARNING: can't find sheet '#{ORGANIZATION_SHEET}'"
|
42
41
|
end
|
@@ -98,6 +97,7 @@ def convert_source
|
|
98
97
|
organization_rows.with_progress().each do |row|
|
99
98
|
organization = converter.to_organization(row, rootmodel)
|
100
99
|
rootmodel.add_organization(organization)
|
100
|
+
converter.organization_hook(row, organization, rootmodel) if defined? converter.organization_hook
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
data/spec/organization_spec.rb
CHANGED
@@ -56,7 +56,7 @@ describe "Organization" do
|
|
56
56
|
organization.validate.should eq ""
|
57
57
|
end
|
58
58
|
|
59
|
-
it "will fail on
|
59
|
+
it "will fail on validation if it has a source with no sourceid" do
|
60
60
|
# given
|
61
61
|
organization.name = "Lundalogik"
|
62
62
|
|
@@ -69,6 +69,72 @@ describe "Organization" do
|
|
69
69
|
organization.validate.length.should be > 0
|
70
70
|
end
|
71
71
|
|
72
|
+
it "will fail on source validation, only numbers" do
|
73
|
+
# given
|
74
|
+
organization.name = "Lundalogik"
|
75
|
+
|
76
|
+
# when
|
77
|
+
organization.with_source do |source|
|
78
|
+
source.par_se('11234')
|
79
|
+
end
|
80
|
+
|
81
|
+
# then
|
82
|
+
organization.validate.length.should be > 0
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
it "will fail on source validation, begins with :" do
|
87
|
+
# given
|
88
|
+
organization.name = "Lundalogik"
|
89
|
+
|
90
|
+
# when
|
91
|
+
organization.with_source do |source|
|
92
|
+
source.par_se(':11234')
|
93
|
+
end
|
94
|
+
|
95
|
+
# then
|
96
|
+
organization.validate.length.should be > 0
|
97
|
+
end
|
98
|
+
|
99
|
+
it "will fail on source validation, ends with :" do
|
100
|
+
# given
|
101
|
+
organization.name = "Lundalogik"
|
102
|
+
|
103
|
+
# when
|
104
|
+
organization.with_source do |source|
|
105
|
+
source.par_se('11234:')
|
106
|
+
end
|
107
|
+
|
108
|
+
# then
|
109
|
+
organization.validate.length.should be > 0
|
110
|
+
end
|
111
|
+
|
112
|
+
it "will not fail on source validation, pattern 1" do
|
113
|
+
# given
|
114
|
+
organization.name = "Lundalogik"
|
115
|
+
|
116
|
+
# when
|
117
|
+
organization.with_source do |source|
|
118
|
+
source.par_se('1:1234')
|
119
|
+
end
|
120
|
+
|
121
|
+
# then
|
122
|
+
organization.validate.length.should be == 0
|
123
|
+
end
|
124
|
+
|
125
|
+
it "will not fail on source validation, pattern 2" do
|
126
|
+
# given
|
127
|
+
organization.name = "Lundalogik"
|
128
|
+
|
129
|
+
# when
|
130
|
+
organization.with_source do |source|
|
131
|
+
source.par_se('113:234')
|
132
|
+
end
|
133
|
+
|
134
|
+
# then
|
135
|
+
organization.validate.length.should be == 0
|
136
|
+
end
|
137
|
+
|
72
138
|
it "will fail on validation if no name is specified" do
|
73
139
|
# given
|
74
140
|
organization.name = ""
|
data/spec/organizations_spec.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'move-to-go'
|
3
|
+
require 'test/unit'
|
4
|
+
include Test::Unit::Assertions
|
3
5
|
|
4
6
|
describe MoveToGo::Organizations do
|
5
7
|
it "should find duplicates based on name of the organizations" do
|
@@ -231,4 +233,112 @@ describe MoveToGo::Organizations do
|
|
231
233
|
set_to_check.length.should eq 3
|
232
234
|
end
|
233
235
|
|
236
|
+
it "should not allow duplicated integration ids" do
|
237
|
+
# given
|
238
|
+
model = MoveToGo::RootModel.new
|
239
|
+
|
240
|
+
organization = MoveToGo::Organization.new
|
241
|
+
organization.name = "name1"
|
242
|
+
organization.integration_id = "1337"
|
243
|
+
model.add_organization(organization)
|
244
|
+
|
245
|
+
organization = MoveToGo::Organization.new
|
246
|
+
organization.name = "name2"
|
247
|
+
organization.integration_id = "1337"
|
248
|
+
|
249
|
+
assert_raise(MoveToGo::AlreadyAddedError) {
|
250
|
+
model.add_organization(organization)
|
251
|
+
}
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should allow different integration ids" do
|
255
|
+
# given
|
256
|
+
model = MoveToGo::RootModel.new
|
257
|
+
|
258
|
+
organization = MoveToGo::Organization.new
|
259
|
+
organization.name = "name1"
|
260
|
+
organization.integration_id = "1337"
|
261
|
+
model.add_organization(organization)
|
262
|
+
|
263
|
+
organization = MoveToGo::Organization.new
|
264
|
+
organization.name = "name2"
|
265
|
+
organization.integration_id = "1338"
|
266
|
+
|
267
|
+
assert_nothing_raised(MoveToGo::AlreadyAddedError) {
|
268
|
+
model.add_organization(organization)
|
269
|
+
}
|
270
|
+
end
|
271
|
+
|
272
|
+
it "should not allow duplicated source ids" do
|
273
|
+
# given
|
274
|
+
model = MoveToGo::RootModel.new
|
275
|
+
|
276
|
+
organization = MoveToGo::Organization.new
|
277
|
+
organization.name = "name1"
|
278
|
+
organization.integration_id = "1337"
|
279
|
+
organization.with_source do |source|
|
280
|
+
source.par_se('1111')
|
281
|
+
end
|
282
|
+
model.add_organization(organization)
|
283
|
+
|
284
|
+
organization = MoveToGo::Organization.new
|
285
|
+
organization.name = "name2"
|
286
|
+
organization.integration_id = "1338"
|
287
|
+
organization.with_source do |source|
|
288
|
+
source.par_se('1111')
|
289
|
+
end
|
290
|
+
|
291
|
+
# when, then
|
292
|
+
assert_raise(MoveToGo::AlreadyAddedError) {
|
293
|
+
model.add_organization(organization)
|
294
|
+
}
|
295
|
+
end
|
296
|
+
|
297
|
+
it "should allow different source ids" do
|
298
|
+
# given
|
299
|
+
model = MoveToGo::RootModel.new
|
300
|
+
|
301
|
+
organization = MoveToGo::Organization.new
|
302
|
+
organization.name = "name1"
|
303
|
+
organization.integration_id = "1337"
|
304
|
+
organization.with_source do |source|
|
305
|
+
source.par_se('1111')
|
306
|
+
end
|
307
|
+
model.add_organization(organization)
|
308
|
+
|
309
|
+
organization = MoveToGo::Organization.new
|
310
|
+
organization.name = "name2"
|
311
|
+
organization.integration_id = "1338"
|
312
|
+
organization.with_source do |source|
|
313
|
+
source.par_se('1112')
|
314
|
+
end
|
315
|
+
|
316
|
+
# when, then
|
317
|
+
assert_nothing_raised(MoveToGo::AlreadyAddedError) {
|
318
|
+
model.add_organization(organization)
|
319
|
+
}
|
320
|
+
end
|
321
|
+
|
322
|
+
it "Not all organization have source id" do
|
323
|
+
# given
|
324
|
+
model = MoveToGo::RootModel.new
|
325
|
+
|
326
|
+
organization = MoveToGo::Organization.new
|
327
|
+
organization.name = "name1"
|
328
|
+
organization.integration_id = "1337"
|
329
|
+
model.add_organization(organization)
|
330
|
+
|
331
|
+
organization = MoveToGo::Organization.new
|
332
|
+
organization.name = "name2"
|
333
|
+
organization.integration_id = "1338"
|
334
|
+
organization.with_source do |source|
|
335
|
+
source.par_se('1112')
|
336
|
+
end
|
337
|
+
|
338
|
+
# when, then
|
339
|
+
assert_nothing_raised(MoveToGo::AlreadyAddedError) {
|
340
|
+
model.add_organization(organization)
|
341
|
+
}
|
342
|
+
end
|
343
|
+
|
234
344
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: move-to-go
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petter Sandholdt
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2017-
|
16
|
+
date: 2017-04-12 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: iso_country_codes
|