move-to-go 5.0.11 → 5.4.1

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.
@@ -4,15 +4,16 @@ require 'move-to-go'
4
4
  require 'progress'
5
5
  require_relative("../converter")
6
6
 
7
- EXPORT_FOLDER = 'export'
8
7
  COWORKER_FILE = "#{EXPORT_FOLDER}/User.txt"
9
8
  ORGANIZATION_FILE = "#{EXPORT_FOLDER}/Company.txt"
10
9
  ORGANIZATION_HISTORY_FILE = "#{EXPORT_FOLDER}/Company-History.txt"
10
+ ORGANIZATION_TODO_FILE = "#{EXPORT_FOLDER}/Company-To do.txt"
11
11
  ORGANIZATION_DOCUMENT_FILE = "#{EXPORT_FOLDER}/Company-Document.txt"
12
12
  PERSON_FILE = "#{EXPORT_FOLDER}/Company-Person.txt"
13
13
  INCLUDE_FILE = "#{EXPORT_FOLDER}/Project-Included.txt"
14
14
  DEAL_FILE = "#{EXPORT_FOLDER}/Project.txt"
15
15
  DEAL_HISTORY_FILE = "#{EXPORT_FOLDER}/Project-History.txt"
16
+ DEAL_TODO_FILE = "#{EXPORT_FOLDER}/Project-To do.txt"
16
17
  PROJECT_DOCUMENT_FILE = "#{EXPORT_FOLDER}/Project-Document.txt"
17
18
 
18
19
  def convert_source
@@ -35,9 +36,12 @@ def convert_source
35
36
  # coworkers
36
37
  # start with these since they are referenced
37
38
  # from everywhere....
38
-
39
- process_rows(" - Reading Coworkers '#{COWORKER_FILE}'", COWORKER_FILE) do |row|
40
- rootmodel.add_coworker(to_coworker(row))
39
+ if(File.exists?(COWORKER_FILE))
40
+ process_rows(" - Reading Coworkers '#{COWORKER_FILE}'", COWORKER_FILE) do |row|
41
+ rootmodel.add_coworker(to_coworker(row))
42
+ end
43
+ else
44
+ puts "WARNING: can't find coworker file '#{COWORKER_FILE}'"
41
45
  end
42
46
 
43
47
  # organizations
@@ -48,49 +52,100 @@ def convert_source
48
52
  converter.organization_hook(row, organization, rootmodel) if defined? converter.organization_hook
49
53
  end
50
54
 
55
+ # Person - Consent connection
56
+ # Reads the file and creats a hash
57
+ # that connect persons to consents
58
+
59
+ if(defined?(PERSON_CONSENT_FILE) && File.exists?(PERSON_CONSENT_FILE))
60
+ if (defined?(VALID_EMAIL_CONSENTS) && VALID_EMAIL_CONSENTS.size > 0)
61
+ consent = Hash.new
62
+ process_rows(" - Reading Person Consents '#{PERSON_CONSENT_FILE}'", PERSON_CONSENT_FILE) do |row|
63
+ consent[row['idPerson']] = VALID_EMAIL_CONSENTS.include? row['String']
64
+ end
65
+ else
66
+ puts "WARNING: Person consent file exists but VALID_EMAIL_CONSENTS is not set."
67
+ end
68
+ end
69
+
51
70
  # persons
52
71
  # depends on organizations
53
72
  process_rows(" - Reading Persons '#{PERSON_FILE}'", PERSON_FILE) do |row|
54
73
  # init method also adds the person to the employer
55
- person = init_person(row, rootmodel)
74
+ person = init_person(row, rootmodel, consent)
56
75
  converter.to_person(person, row)
57
76
  end
58
77
 
59
78
  # organization histories
60
- process_rows(" - Reading Organization History '#{ORGANIZATION_HISTORY_FILE}'", ORGANIZATION_HISTORY_FILE) do |row|
61
- # adds itself if applicable
62
- rootmodel.add_history(to_organization_history(converter, row, rootmodel))
79
+ if(File.exists?(ORGANIZATION_HISTORY_FILE))
80
+ process_rows(" - Reading Organization History '#{ORGANIZATION_HISTORY_FILE}'", ORGANIZATION_HISTORY_FILE) do |row|
81
+ # adds itself if applicable
82
+ rootmodel.add_history(to_organization_history(converter, row, rootmodel))
83
+ end
84
+ else
85
+ puts "WARNING: can't find organization history file '#{ORGANIZATION_HISTORY_FILE}'"
86
+ end
87
+
88
+ # organization todos
89
+ if(File.exists?(ORGANIZATION_TODO_FILE))
90
+ process_rows(" - Reading Organization Todos '#{ORGANIZATION_TODO_FILE}'", ORGANIZATION_TODO_FILE) do |row|
91
+ # adds itself if applicable
92
+ rootmodel.add_todo(to_organization_todo(converter, row, rootmodel))
93
+ end
94
+ else
95
+ puts "WARNING: can't find organization history file '#{ORGANIZATION_TODO_FILE}'"
63
96
  end
64
97
 
65
98
  # Organization - Deal connection
66
99
  # Reads the includes.txt and creats a hash
67
- # that connect organizations to deals
100
+ # that connect organizations to deals
68
101
  process_rows(" - Reading Organization Deals '#{INCLUDE_FILE}'", INCLUDE_FILE) do |row|
69
102
  includes[row['idProject']] = row['idCompany']
70
103
  end
71
104
 
72
105
  # deals
73
106
  # deals can reference coworkers (responsible), organizations
74
- # and persons (contact)
107
+ # and persons (contact)
75
108
  process_rows(" - Reading Deals '#{DEAL_FILE}'", DEAL_FILE) do |row|
76
109
  deal = init_deal(row, rootmodel, includes)
77
110
  rootmodel.add_deal(converter.to_deal(deal, row))
78
111
  end
79
112
 
80
113
  # deal histories
81
- process_rows(" - Reading Deal Histories '#{DEAL_HISTORY_FILE}'", DEAL_HISTORY_FILE) do |row|
82
- # adds itself if applicable
83
- rootmodel.add_history(to_deal_history(converter, row, rootmodel))
114
+ if(File.exists?(DEAL_HISTORY_FILE))
115
+ process_rows(" - Reading Deal Histories '#{DEAL_HISTORY_FILE}'", DEAL_HISTORY_FILE) do |row|
116
+ # adds itself if applicable
117
+ rootmodel.add_history(to_deal_history(converter, row, rootmodel))
118
+ end
119
+ else
120
+ puts "WARNING: can't find deal history file '#{DEAL_HISTORY_FILE}'"
121
+ end
122
+
123
+ # deal todos
124
+ if(File.exists?(DEAL_TODO_FILE))
125
+ process_rows(" - Reading Deal Todos '#{DEAL_TODO_FILE}'", DEAL_TODO_FILE) do |row|
126
+ # adds itself if applicable
127
+ rootmodel.add_todo(to_deal_todo(converter, row, rootmodel))
128
+ end
129
+ else
130
+ puts "WARNING: can't find deal history file '#{DEAL_TODO_FILE}'"
84
131
  end
85
132
 
86
133
  # documents
87
134
  if defined?(IMPORT_DOCUMENTS) && !IMPORT_DOCUMENTS.nil? && IMPORT_DOCUMENTS
88
- process_rows(" - Reading Organization Documents", ORGANIZATION_DOCUMENT_FILE) do |row|
89
- rootmodel.add_file(to_organization_document(row, rootmodel))
135
+ if(File.exists?(ORGANIZATION_DOCUMENT_FILE))
136
+ process_rows(" - Reading Organization Documents", ORGANIZATION_DOCUMENT_FILE) do |row|
137
+ rootmodel.add_file(to_organization_document(row, rootmodel))
138
+ end
139
+ else
140
+ puts "WARNING: can't find company documents file '#{ORGANIZATION_DOCUMENT_FILE}'"
90
141
  end
91
142
 
92
- process_rows(" - Reading Project Documents", PROJECT_DOCUMENT_FILE) do |row|
93
- rootmodel.add_file(to_deal_document(row, rootmodel))
143
+ if(File.exists?(PROJECT_DOCUMENT_FILE))
144
+ process_rows(" - Reading Project Documents", PROJECT_DOCUMENT_FILE) do |row|
145
+ rootmodel.add_file(to_deal_document(row, rootmodel))
146
+ end
147
+ else
148
+ puts "WARNING: can't find project documents file '#{PROJECT_DOCUMENT_FILE}'"
94
149
  end
95
150
  end
96
151
 
@@ -99,7 +154,7 @@ end
99
154
 
100
155
  def to_coworker(row)
101
156
  coworker = MoveToGo::Coworker.new
102
-
157
+
103
158
  # integration_id is typically the userId in Easy
104
159
  # Must be set to be able to import the same file more
105
160
  # than once without creating duplicates
@@ -129,7 +184,7 @@ def init_organization(row, rootmodel)
129
184
  return organization
130
185
  end
131
186
 
132
- def init_person(row, rootmodel)
187
+ def init_person(row, rootmodel, consent)
133
188
  person = MoveToGo::Person.new
134
189
 
135
190
  # Easy standard fields created in configure method Easy
@@ -140,7 +195,9 @@ def init_person(row, rootmodel)
140
195
  person.integration_id = row['idPerson']
141
196
  person.first_name = row['First name']
142
197
  person.last_name = row['Last name']
143
-
198
+ if (!consent.nil?)
199
+ person.has_mail_consent = !!consent[row['idPerson']]
200
+ end
144
201
  # set employer connection
145
202
  employer = rootmodel.find_organization_by_integration_id(row['idCompany'])
146
203
  if employer
@@ -162,7 +219,7 @@ def to_organization_history(converter, row, rootmodel)
162
219
  history.created_by = coworker
163
220
  history.person = organization.find_employee_by_integration_id(row['idPerson'])
164
221
  history.date = row['Date']
165
-
222
+
166
223
  if converter.respond_to?(:get_history_classification_for_activity_on_company)
167
224
  # we will get an InvalidHistoryClassificationError if we are
168
225
  # setting and invalid classification. So no need to verify
@@ -173,7 +230,7 @@ def to_organization_history(converter, row, rootmodel)
173
230
  if classification.nil?
174
231
  classification = MoveToGo::HistoryClassification::Comment
175
232
  end
176
-
233
+
177
234
  history.classification = classification
178
235
 
179
236
  history.text = row['History']
@@ -188,6 +245,35 @@ def to_organization_history(converter, row, rootmodel)
188
245
  return nil
189
246
  end
190
247
 
248
+ # Turns a row from the Easy exported Company-To do.txt file into
249
+ # a move-to-go model that is used to generate xml.
250
+ def to_organization_todo(converter, row, rootmodel)
251
+ organization = rootmodel.find_organization_by_integration_id(row['idCompany'])
252
+ coworker = rootmodel.find_coworker_by_integration_id(row['idUser'])
253
+
254
+ if organization && coworker
255
+ todo = MoveToGo::Todo.new()
256
+ todo.organization = organization
257
+ todo.created_by = coworker
258
+ todo.assigned_coworker = coworker
259
+ todo.person = organization.find_employee_by_integration_id(row['idPerson'])
260
+ if row['Start time'] != ''
261
+ todo.date_start = "#{row['Start date']} #{row['Start time']}"
262
+ todo.date_start_has_time = true
263
+ else
264
+ todo.date_start = row['Start date'] != '' ? row['Start date'] : Date.today.to_s
265
+ todo.date_start_has_time = false
266
+ end
267
+
268
+ todo.date_checked = DateTime.now if row['Done'] == "1"
269
+ todo.text = row['Description']
270
+
271
+ return todo.text.empty? ? nil : todo
272
+ end
273
+
274
+ return nil
275
+ end
276
+
191
277
  def to_organization_document(row, rootmodel)
192
278
  file = MoveToGo::File.new()
193
279
 
@@ -284,14 +370,14 @@ def to_deal_history(converter, row, rootmodel)
284
370
  if classification.nil?
285
371
  classification = MoveToGo::HistoryClassification::Comment
286
372
  end
287
-
373
+
288
374
  history.classification = classification
289
375
  history.text = row['RawHistory'].to_s.sub("#{row['Category']}:", "")
290
376
  else
291
377
  history.classification = MoveToGo::HistoryClassification::Comment
292
378
  history.text = row['RawHistory']
293
379
  end
294
-
380
+
295
381
 
296
382
  return history.text.empty? ? nil : history
297
383
  end
@@ -299,6 +385,35 @@ def to_deal_history(converter, row, rootmodel)
299
385
  return nil
300
386
  end
301
387
 
388
+ # Turns a row from the Easy exported Project-To do.txt file into
389
+ # a move-to-go model that is used to generate xml.
390
+ def to_deal_todo(converter, row, rootmodel)
391
+ deal = rootmodel.find_deal_by_integration_id(row['idProject'])
392
+ coworker = rootmodel.find_coworker_by_integration_id(row['idUser'])
393
+
394
+ if deal && coworker
395
+ todo = MoveToGo::Todo.new()
396
+ todo.deal = deal
397
+ todo.organization = deal.customer
398
+ todo.created_by = coworker
399
+ todo.assigned_coworker = coworker
400
+ todo.person = todo.organization.find_employee_by_integration_id(row['idPerson'])
401
+ if row['Start time'] != ''
402
+ todo.date_start = "#{row['Start date']} #{row['Start time']}"
403
+ todo.date_start_has_time = true
404
+ else
405
+ todo.date_start = row['Start date'] != '' ? row['Start date'] : Date.today.to_s
406
+ todo.date_start_has_time = false
407
+ end
408
+
409
+ todo.date_checked = DateTime.now if row['Done'] == "1"
410
+ todo.text = row['Description']
411
+
412
+ return todo.text.empty? ? nil : todo
413
+ end
414
+
415
+ return nil
416
+ end
302
417
 
303
418
  def validate_constants()
304
419
  if !defined?(ORGANIZATION_RESPONSIBLE_FIELD)
@@ -321,6 +436,13 @@ def validate_constants()
321
436
  Otherwise you should define 'IMPORT_DOCUMENTS' in converter.rb
322
437
  with the value 'true'."
323
438
  end
439
+
440
+ if !defined?(VALID_EMAIL_CONSENTS) || VALID_EMAIL_CONSENTS.empty?
441
+ puts "WARNING: You havce not defined any valid email consents.
442
+ No person will now have the 'Email consent given' set.
443
+ To set the valid email consents, define 'VALID_EMAIL_CONSENTS' with
444
+ the strings from Company-Person-Consent.txt that are valid for email."
445
+ end
324
446
  end
325
447
 
326
448
 
@@ -336,13 +458,8 @@ def process_rows(description, file_name)
336
458
  end
337
459
 
338
460
  def make_sure_database_has_been_exported()
339
- return File.exists?(COWORKER_FILE) &&
340
- File.exists?(ORGANIZATION_FILE) &&
341
- File.exists?(ORGANIZATION_HISTORY_FILE) &&
342
- File.exists?(ORGANIZATION_DOCUMENT_FILE) &&
461
+ return File.exists?(ORGANIZATION_FILE) &&
343
462
  File.exists?(PERSON_FILE) &&
344
- File.exists?(INCLUDE_FILE) &&
345
- File.exists?(DEAL_FILE) &&
346
- File.exists?(DEAL_HISTORY_FILE) &&
347
- File.exists?(PROJECT_DOCUMENT_FILE)
463
+ # File.exists?(INCLUDE_FILE) &&
464
+ File.exists?(DEAL_FILE)
348
465
  end
@@ -39,6 +39,22 @@ require 'move-to-go'
39
39
  ## Constants
40
40
  # Edit these constants to fit your needs
41
41
 
42
+ # The export folder, it's probably called 'Export' if you haven't changed it.
43
+ EXPORT_FOLDER = 'Export'
44
+
45
+ # This file referes to the consent set super field in Lime Easy
46
+ # where the customer have their email consents.
47
+ PERSON_CONSENT_FILE = "#{EXPORT_FOLDER}/Company-Person-Samtycken.txt"
48
+
49
+ # Valid Consents strings for setting E-mail consent.
50
+ # Which of the set alternatives should be converted to
51
+ # E-mail consent in Lime Go. Just name them here, and
52
+ # move-to-go will fetch them from the file above.
53
+
54
+ # VALID_EMAIL_CONSENTS = ['Ok för nyhetsbrev', 'Ok för produktnyheter']
55
+ VALID_EMAIL_CONSENTS = ['Nyhetsbrev']
56
+
57
+
42
58
  # determines if documents should be imported.
43
59
  # IMPORT_DOCUMENTS = true
44
60
 
@@ -305,7 +321,7 @@ class Converter
305
321
  # return the note will get the default classification 'Comment'
306
322
 
307
323
  # case activity
308
- # when 'SalesCall'
324
+ # when 'SalesCall'
309
325
  # classification = MoveToGo::HistoryClassification::SalesCall
310
326
  # when 'Customer Visit'
311
327
  # classification = MoveToGo::HistoryClassification::ClientVisit
@@ -314,7 +330,7 @@ class Converter
314
330
  # else
315
331
  # classification = MoveToGo::HistoryClassification::Comment
316
332
  # end
317
-
333
+
318
334
  # return classification
319
335
  end
320
336
 
@@ -326,20 +342,20 @@ class Converter
326
342
  # in LIME Go. The return value must be a value from the
327
343
  # MoveToGo::HistoryClassification enum. If no classification is
328
344
  # return the history will get the default classification 'Comment'
329
-
345
+
330
346
  # case activity
331
- # when 'Installation'
347
+ # when 'Installation'
332
348
  # classification = MoveToGo::HistoryClassification::ClientVisit
333
349
  # when 'No answer'
334
350
  # classification = MoveToGo::HistoryClassification::TriedToReach
335
351
  # else
336
352
  # classification = MoveToGo::HistoryClassification::Comment
337
353
  # end
338
-
354
+
339
355
  # return classification
340
356
  end
341
357
 
342
-
358
+
343
359
 
344
360
  # HOOKS
345
361
  #
@@ -355,7 +371,7 @@ class Converter
355
371
  # rootmodel.add_comment(comment)
356
372
  # end
357
373
  #end
358
-
374
+
359
375
 
360
376
  end
361
377
 
@@ -27,6 +27,19 @@ describe "File" do
27
27
  file.validate.should eq ""
28
28
  end
29
29
 
30
+ it "is valid when it has name, path, created_by, deal, person and organization" do
31
+ # given
32
+ file.name = "Offert"
33
+ file.path = "spec/sample_data/offert.docx"
34
+ file.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123" } )
35
+ file.deal = MoveToGo::DealReference.new( { :integration_id => "456" } )
36
+ file.person = MoveToGo::PersonReference.new( { :integration_id => "456" } )
37
+ file.organization = MoveToGo::OrganizationReference.new( { :integration_id => "456" } )
38
+
39
+ # when, then
40
+ file.validate.should eq ""
41
+ end
42
+
30
43
  it "is valid when it has name, invalid path, created_by and deal but ignores the path" do
31
44
  # given
32
45
  file.name = "Offert"
@@ -138,6 +151,20 @@ describe "File" do
138
151
  file.instance_variable_get(:@deal_reference).is_a?(MoveToGo::DealReference).should eq true
139
152
  end
140
153
 
154
+ it "will set person ref when person is assigned" do
155
+ # given
156
+ person = MoveToGo::Person.new({:integration_id => "123" })
157
+ person.first_name = "The"
158
+ person.last_name = "Limer"
159
+
160
+ # when
161
+ file.person = person
162
+
163
+ # then
164
+ file.person.is_a?(MoveToGo::Person).should eq true
165
+ file.instance_variable_get(:@person_reference).is_a?(MoveToGo::PersonReference).should eq true
166
+ end
167
+
141
168
  it "will set coworker ref when coworker is assinged" do
142
169
  # given
143
170
  coworker = MoveToGo::Coworker.new({:integration_id => "123" })
@@ -3,25 +3,30 @@ require 'move-to-go'
3
3
  require 'nokogiri'
4
4
  describe MoveToGo::SerializeHelper do
5
5
  describe "Validate according to xsd" do
6
- let(:validate_result) {
6
+ let(:rootmodel) do
7
7
  rootmodel = MoveToGo::RootModel.new
8
8
  rootmodel.settings.with_organization do |s|
9
9
  s.set_custom_field({:integration_id => "2", :title => "cf title"})
10
10
  s.set_custom_field({:integration_id => "3", :title => "cf title2"})
11
11
  end
12
- coworker = MoveToGo::Coworker.new({
13
- :integration_id => "123",
14
- :first_name => "Kalle",
15
- :last_name => "Anka",
16
- :email => "kalle.anka@vonanka.com"
17
- })
18
- rootmodel.add_coworker(coworker)
12
+ rootmodel
13
+ end
14
+
15
+ let(:coworker) do
16
+ MoveToGo::Coworker.new({
17
+ :integration_id => "123",
18
+ :first_name => "Kalle",
19
+ :last_name => "Anka",
20
+ :email => "kalle.anka@vonanka.com"
21
+ })
22
+ end
23
+
24
+ let(:organization) do
19
25
  organization = MoveToGo::Organization.new
20
26
  organization.name = "Ankeborgs bibliotek"
21
27
  organization.with_source do |source|
22
28
  source.par_se('122345')
23
29
  end
24
- #organization.source_ref = {:name => 'Go',:id => "PASE122345"}
25
30
  organization.set_tag("tag:bibliotek")
26
31
  organization.set_tag("tag:Bj\u{00F6}rk")
27
32
  organization.set_custom_value("2", "cf value")
@@ -33,25 +38,90 @@ describe MoveToGo::SerializeHelper do
33
38
  organization.with_visit_address do |addr|
34
39
  addr.city = "Gaaseborg"
35
40
  end
36
- coworker = MoveToGo::Coworker.new({:integration_id => "1", :first_name => "Vincent", :last_name => "Vega"})
37
- organization.responsible_coworker = coworker
41
+ organization
42
+ end
38
43
 
44
+ let(:employee) do
39
45
  emp = MoveToGo::Person.new
40
- emp.integration_id = "1"
46
+ emp.integration_id = "12345"
41
47
  emp.first_name = "Kalle"
42
48
  emp.last_name = "Anka"
43
49
  emp.direct_phone_number = '234234234'
44
50
  emp.currently_employed = true
51
+ emp
52
+ end
53
+
54
+ let(:deal) do
55
+ deal = MoveToGo::Deal.new
56
+ deal.integration_id = "42"
57
+ deal.name = "foo"
58
+ deal.offer_date = "2012-12-12T00:00:00"
59
+ deal.order_date = "2012-12-01T00:00:00"
60
+ deal.value = "0"
61
+ deal.probability = "20"
62
+ deal
63
+ end
64
+
65
+ let(:link) do
66
+ link = MoveToGo::Link.new
67
+ link.integration_id = "12"
68
+ link.url = "https://go.lime-go.com"
69
+ link
70
+ end
71
+
72
+ let(:file) do
73
+ file = MoveToGo::File.new
74
+ file.integration_id = "12"
75
+ file.name = "smallfile.txt"
76
+ file
77
+ end
78
+
79
+ it "Should not contain validation errors" do
80
+ rootmodel.add_coworker(coworker)
81
+ organization.responsible_coworker = MoveToGo::Coworker.new({:integration_id => "1", :first_name => "Vincent", :last_name => "Vega"})
82
+ organization.add_employee employee
45
83
  rootmodel.add_organization organization
84
+
85
+ doc = Nokogiri::XML(MoveToGo::SerializeHelper::serialize(rootmodel, -1))
86
+
46
87
  xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
88
+ xsd = Nokogiri::XML::Schema(File.read(xsd_file))
89
+ expect(xsd.validate(doc)).to eq([])
90
+ end
91
+
92
+ it "Documents can have many references" do
93
+ rootmodel.add_coworker(coworker)
94
+ organization.add_employee employee
95
+ rootmodel.add_organization organization
96
+ deal.customer = organization
97
+ rootmodel.add_deal deal
98
+
99
+ link.deal = deal
100
+ link.organization = organization
101
+ link.person = employee
102
+ rootmodel.add_link link
103
+
104
+ file.deal = deal
105
+ file.organization = organization
106
+ file.person = employee
107
+ rootmodel.add_file file
47
108
 
48
- xsd = Nokogiri::XML::Schema(File.read(xsd_file))
49
109
  doc = Nokogiri::XML(MoveToGo::SerializeHelper::serialize(rootmodel, -1))
50
- xsd.validate(doc)
51
- }
110
+ xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
111
+ xsd = Nokogiri::XML::Schema(File.read(xsd_file))
112
+ expect(xsd.validate(doc)).to eq([])
113
+ end
52
114
 
53
- it "Should not contain validation errors" do
54
- expect(validate_result).to eq([])
115
+ it "valudate deals" do
116
+ rootmodel.add_coworker(coworker)
117
+ rootmodel.add_organization organization
118
+ deal.customer = organization
119
+ rootmodel.add_deal deal
120
+
121
+ doc = Nokogiri::XML(MoveToGo::SerializeHelper::serialize(rootmodel, -1))
122
+ xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
123
+ xsd = Nokogiri::XML::Schema(File.read(xsd_file))
124
+ expect(xsd.validate(doc)).to eq([])
55
125
  end
56
126
  end
57
127
  end