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
data/spec/file_spec.rb
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'move-to-go'
|
3
|
+
|
4
|
+
describe "File" do
|
5
|
+
let ("file") {
|
6
|
+
MoveToGo::File.new
|
7
|
+
}
|
8
|
+
|
9
|
+
it "is valid when it has path, created_by and organization" do
|
10
|
+
# given
|
11
|
+
file.path = "spec/sample_data/offert.docx"
|
12
|
+
file.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123" } )
|
13
|
+
file.organization = MoveToGo::OrganizationReference.new( { :integration_id => "456" } )
|
14
|
+
|
15
|
+
# when, then
|
16
|
+
file.validate.should eq ""
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is valid when it has name, path, created_by and deal" do
|
20
|
+
# given
|
21
|
+
file.name = "Offert"
|
22
|
+
file.path = "spec/sample_data/offert.docx"
|
23
|
+
file.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123" } )
|
24
|
+
file.deal = MoveToGo::DealReference.new( { :integration_id => "456" } )
|
25
|
+
|
26
|
+
# when, then
|
27
|
+
file.validate.should eq ""
|
28
|
+
end
|
29
|
+
|
30
|
+
it "is valid when it has name, invalid path, created_by and deal but ignores the path" do
|
31
|
+
# given
|
32
|
+
file.name = "Offert"
|
33
|
+
file.path = "c:\\mydocs\\offert.docx"
|
34
|
+
file.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123" } )
|
35
|
+
file.deal = MoveToGo::DealReference.new( { :integration_id => "456" } )
|
36
|
+
|
37
|
+
# when, then
|
38
|
+
file.validate(true).should eq ""
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
it "is not valid when it has path and deal" do
|
43
|
+
# must have a created_by
|
44
|
+
# given
|
45
|
+
file.path = "c:\mydocs\deal.xls"
|
46
|
+
file.deal = MoveToGo::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
|
47
|
+
|
48
|
+
# when, then
|
49
|
+
file.validate.length.should be > 0
|
50
|
+
end
|
51
|
+
|
52
|
+
it "is not valid when it has path and created_by" do
|
53
|
+
# must have an deal or organization
|
54
|
+
# given
|
55
|
+
file.path = "c:\mydocs\deal.xls"
|
56
|
+
file.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
|
57
|
+
|
58
|
+
# when, then
|
59
|
+
file.validate.length.should be > 0
|
60
|
+
end
|
61
|
+
|
62
|
+
it "is not valid when it has deal and created_by" do
|
63
|
+
# must have a path
|
64
|
+
# given
|
65
|
+
file.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
|
66
|
+
file.deal = MoveToGo::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
|
67
|
+
|
68
|
+
# when, then
|
69
|
+
file.validate.length.should be > 0
|
70
|
+
end
|
71
|
+
|
72
|
+
it "knows when a path is not relative" do
|
73
|
+
# given
|
74
|
+
file.path = "c:\\files\\myfile.doc"
|
75
|
+
|
76
|
+
# when, then
|
77
|
+
file.has_relative_path?().should eq false
|
78
|
+
end
|
79
|
+
|
80
|
+
it "knows when a path is relative" do
|
81
|
+
# given
|
82
|
+
file.path = "files/myfile.doc"
|
83
|
+
|
84
|
+
# when, then
|
85
|
+
file.has_relative_path?().should eq true
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
it "will use filename from path as name if name set not explicit" do
|
90
|
+
# given
|
91
|
+
file.path = "some/files/myfile.docx"
|
92
|
+
file.name = ""
|
93
|
+
|
94
|
+
# when, then
|
95
|
+
file.name.should eq 'myfile.docx'
|
96
|
+
end
|
97
|
+
|
98
|
+
it "will use name as name if name is set explicit" do
|
99
|
+
# given
|
100
|
+
file.path = "some/files/myfile.docx"
|
101
|
+
file.name = "This is a filename"
|
102
|
+
|
103
|
+
# when, then
|
104
|
+
file.name.should eq 'This is a filename'
|
105
|
+
end
|
106
|
+
|
107
|
+
it "will not have a name if name is not set or path is empty" do
|
108
|
+
# given
|
109
|
+
file.path = ""
|
110
|
+
file.name = ""
|
111
|
+
|
112
|
+
# when, then
|
113
|
+
file.name.should eq ''
|
114
|
+
end
|
115
|
+
|
116
|
+
it "will set organization ref when organization is assinged" do
|
117
|
+
# given
|
118
|
+
org = MoveToGo::Organization.new({:integration_id => "123", :name => "Beagle Boys!"})
|
119
|
+
|
120
|
+
# when
|
121
|
+
file.organization = org
|
122
|
+
|
123
|
+
# then
|
124
|
+
file.organization.is_a?(MoveToGo::Organization).should eq true
|
125
|
+
file.instance_variable_get(:@organization_reference).is_a?(MoveToGo::OrganizationReference).should eq true
|
126
|
+
end
|
127
|
+
|
128
|
+
it "will set deal ref when deal is assinged" do
|
129
|
+
# given
|
130
|
+
deal = MoveToGo::Deal.new({:integration_id => "123" })
|
131
|
+
deal.name = "The new deal"
|
132
|
+
|
133
|
+
# when
|
134
|
+
file.deal = deal
|
135
|
+
|
136
|
+
# then
|
137
|
+
file.deal.is_a?(MoveToGo::Deal).should eq true
|
138
|
+
file.instance_variable_get(:@deal_reference).is_a?(MoveToGo::DealReference).should eq true
|
139
|
+
end
|
140
|
+
|
141
|
+
it "will set coworker ref when coworker is assinged" do
|
142
|
+
# given
|
143
|
+
coworker = MoveToGo::Coworker.new({:integration_id => "123" })
|
144
|
+
coworker.parse_name_to_firstname_lastname_se "Billy Bob"
|
145
|
+
|
146
|
+
# when
|
147
|
+
file.created_by = coworker
|
148
|
+
|
149
|
+
# then
|
150
|
+
file.created_by.is_a?(MoveToGo::Coworker).should eq true
|
151
|
+
file.instance_variable_get(:@created_by_reference).is_a?(MoveToGo::CoworkerReference).should eq true
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "is large" do
|
155
|
+
before(:all) do
|
156
|
+
n = 100
|
157
|
+
File.open("spec/sample_data/large.mpeg", 'w') do |f|
|
158
|
+
contents = "x" * (1024*1024)
|
159
|
+
n.to_i.times { f.write(contents) }
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
after(:all) do
|
164
|
+
File.delete "spec/sample_data/large.mpeg"
|
165
|
+
end
|
166
|
+
|
167
|
+
it "is not valid" do
|
168
|
+
# must be less than 100 Mb
|
169
|
+
file.path = "spec/sample_data/large.mpeg"
|
170
|
+
file.created_by = MoveToGo::CoworkerReference.new( { :integration_id => "123" } )
|
171
|
+
file.organization = MoveToGo::OrganizationReference.new( { :integration_id => "456" } )
|
172
|
+
|
173
|
+
# when, then
|
174
|
+
file.validate.length.should be > 0
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: iso-8859-1
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'move-to-go'
|
4
|
+
|
5
|
+
describe MoveToGo::CsvHelper do
|
6
|
+
it "should" do
|
7
|
+
v = MoveToGo::CsvHelper.text_to_hashes("id;navn
|
8
|
+
1;Noerrebro")
|
9
|
+
v.should include({"id"=>"1","navn"=>"Noerrebro"})
|
10
|
+
end
|
11
|
+
it "should handle sv chars" do
|
12
|
+
v = MoveToGo::CsvHelper.text_to_hashes("id;navn
|
13
|
+
1;Bj\u{00F6}rk")
|
14
|
+
v.should include({"id"=>"1","navn"=>"Bj\u{00F6}rk"})
|
15
|
+
end
|
16
|
+
it "should handle escaped newlines" do
|
17
|
+
v = MoveToGo::CsvHelper.text_to_hashes("id;navn
|
18
|
+
1;\"Bj\u{00F6}rk
|
19
|
+
And a new line\"")
|
20
|
+
v.should include({"id"=>"1","navn"=>"Bj\u{00F6}rk
|
21
|
+
And a new line"})
|
22
|
+
end
|
23
|
+
it "should handle escaped newlines with ',' as delim" do
|
24
|
+
v = MoveToGo::CsvHelper.text_to_hashes("id,navn
|
25
|
+
1,\"Bj\u{00F6}rk
|
26
|
+
And a new line\"")
|
27
|
+
v.should include({"id"=>"1","navn"=>"Bj\u{00F6}rk
|
28
|
+
And a new line"})
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should handled values with ," do
|
32
|
+
# given
|
33
|
+
str = "id,name,text
|
34
|
+
1,lundalogik,\"hej, hopp\""
|
35
|
+
|
36
|
+
# when
|
37
|
+
v = MoveToGo::CsvHelper.text_to_hashes(str)
|
38
|
+
|
39
|
+
# then
|
40
|
+
v.should include({
|
41
|
+
"id" => "1",
|
42
|
+
"name" => "lundalogik",
|
43
|
+
"text" => "hej, hopp"})
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: iso-8859-1
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'move-to-go'
|
4
|
+
|
5
|
+
describe MoveToGo::EmailHelper do
|
6
|
+
it "should validate a common email address" do
|
7
|
+
# given
|
8
|
+
import_email = "apl@lundalogik.se"
|
9
|
+
|
10
|
+
# when, then
|
11
|
+
MoveToGo::EmailHelper.is_valid?(import_email).should eq true
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should validate an address with firstname.lastname" do
|
15
|
+
MoveToGo::EmailHelper.is_valid?("firstname.lastname@example.com").should eq true
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should validate an address with lots of subdomains" do
|
19
|
+
MoveToGo::EmailHelper.is_valid?("firstname.lastname@sub1.sub2.example.com").should eq true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should validate an address with some special chars" do
|
23
|
+
MoveToGo::EmailHelper.is_valid?("firstname-lastname+=@sub1.sub2.example.com").should eq true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should validate an address with no top level domain" do
|
27
|
+
MoveToGo::EmailHelper.is_valid?("firstname@example").should eq true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should not validate an invalid address" do
|
31
|
+
MoveToGo::EmailHelper.is_valid?("hubbabubba").should eq false
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should not validate an address with swedish chars" do
|
35
|
+
MoveToGo::EmailHelper.is_valid?("info.bor�s@example.se").should eq false
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'move-to-go'
|
3
|
+
|
4
|
+
describe MoveToGo::PhoneHelper do
|
5
|
+
before(:each) do
|
6
|
+
MoveToGo::PhoneHelper.set_country_code(:se)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should parse phonenumbers" do
|
10
|
+
# given, when
|
11
|
+
nice_number = MoveToGo::PhoneHelper.parse_numbers("0709-685226")
|
12
|
+
|
13
|
+
# then
|
14
|
+
nice_number.should eq "+46709685226"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should parse multiple numbers with default delimiter" do
|
18
|
+
# given
|
19
|
+
source = "046 - 270 48 00, 0709-685226"
|
20
|
+
|
21
|
+
# when
|
22
|
+
home, mobile = MoveToGo::PhoneHelper.parse_numbers(source)
|
23
|
+
|
24
|
+
# then
|
25
|
+
home.should eq "+46462704800"
|
26
|
+
mobile.should eq "+46709685226"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should parse multiple numbers with custom delimiter" do
|
30
|
+
# given
|
31
|
+
source = "046 - 270 48 00/ 0709-685226"
|
32
|
+
|
33
|
+
# when
|
34
|
+
home, mobile = MoveToGo::PhoneHelper.parse_numbers(source, '/')
|
35
|
+
|
36
|
+
# then
|
37
|
+
home.should eq "+46462704800"
|
38
|
+
mobile.should eq "+46709685226"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should parse numbers with different delimiters" do
|
42
|
+
# given
|
43
|
+
source1 = "046 - 270 48 00/ 0709-685226"
|
44
|
+
source2 = "08-562 776 00, 070-73 85 180"
|
45
|
+
source3 = "031-712 44 00\\\\ 0707 38 52 72/, 031 71 244 04"
|
46
|
+
|
47
|
+
# when
|
48
|
+
home1, mobile1 = MoveToGo::PhoneHelper.parse_numbers(source1, ['/', ',', "\\\\"])
|
49
|
+
home2, mobile2 = MoveToGo::PhoneHelper.parse_numbers(source2, ['/', ',', "\\\\"])
|
50
|
+
home3, mobile3, direct3 = MoveToGo::PhoneHelper.parse_numbers(source3, ['/', ',', "\\\\"])
|
51
|
+
|
52
|
+
# then
|
53
|
+
home1.should eq "+46462704800"
|
54
|
+
mobile1.should eq "+46709685226"
|
55
|
+
|
56
|
+
home2.should eq "+46856277600"
|
57
|
+
mobile2.should eq "+46707385180"
|
58
|
+
|
59
|
+
home3.should eq "+46317124400"
|
60
|
+
mobile3.should eq "+46707385272"
|
61
|
+
direct3.should eq "+46317124404"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should not mess with invalid numbers by default" do
|
65
|
+
# given
|
66
|
+
source = "im not a number"
|
67
|
+
|
68
|
+
# when
|
69
|
+
number = MoveToGo::PhoneHelper.parse_numbers(source)
|
70
|
+
|
71
|
+
# then
|
72
|
+
number.should eq "im not a number"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should not mess with invalid numbers unless strict mode" do
|
76
|
+
# given
|
77
|
+
source = "im not a number"
|
78
|
+
|
79
|
+
# when
|
80
|
+
number = MoveToGo::PhoneHelper.parse_numbers_strict(source)
|
81
|
+
|
82
|
+
# then
|
83
|
+
number.should eq ""
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should parse foreign numbers" do
|
87
|
+
# given
|
88
|
+
source = "22 13 00 30"
|
89
|
+
|
90
|
+
# when
|
91
|
+
MoveToGo::PhoneHelper.set_country_code(:no)
|
92
|
+
number = MoveToGo::PhoneHelper.parse_numbers(source)
|
93
|
+
|
94
|
+
# then
|
95
|
+
number.should eq "+4722130030"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should handle nil" do
|
99
|
+
# given
|
100
|
+
source = nil
|
101
|
+
|
102
|
+
# when
|
103
|
+
number = MoveToGo::PhoneHelper.parse_numbers(source)
|
104
|
+
|
105
|
+
# then
|
106
|
+
number.should eq nil
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should handle empty string" do
|
110
|
+
# given
|
111
|
+
source = ""
|
112
|
+
|
113
|
+
# when
|
114
|
+
number = MoveToGo::PhoneHelper.parse_numbers(source)
|
115
|
+
|
116
|
+
# then
|
117
|
+
number.should eq ""
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'move-to-go'
|
3
|
+
require 'roo'
|
4
|
+
describe MoveToGo::RooHelper do
|
5
|
+
it "should handle sv chars" do
|
6
|
+
samplefile = File.join(File.dirname(__FILE__), '..', 'sample_data', 'excel.xlsx')
|
7
|
+
rows = MoveToGo::RooHelper.new(Roo::Excelx.new(samplefile)).rows
|
8
|
+
rows.should include({"Alpha"=>"L\u00E5s","Beta"=>"m\u00E4sk","\u00D6rjan"=>"l\u00E4sk","\u00C4skil"=>""})
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,253 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'move-to-go'
|
3
|
+
|
4
|
+
describe MoveToGo::SerializeHelper do
|
5
|
+
|
6
|
+
describe "Serialize history" do
|
7
|
+
let(:serialized) {
|
8
|
+
n = MoveToGo::History.new
|
9
|
+
n.text = "text"
|
10
|
+
MoveToGo::SerializeHelper::serialize(n,-1)
|
11
|
+
}
|
12
|
+
it "should contain text" do
|
13
|
+
serialized.should match(/<Text>[\n ]*text[\n ]*<\/Text>/)
|
14
|
+
end
|
15
|
+
it "should contain start tag" do
|
16
|
+
serialized.should match(/<History>/)
|
17
|
+
end
|
18
|
+
it "should be utf-8" do
|
19
|
+
serialized.encoding.should equal Encoding::UTF_8
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "Serialize history with xml inside" do
|
24
|
+
let(:serialized) {
|
25
|
+
n = MoveToGo::History.new
|
26
|
+
n.text = "<text>"
|
27
|
+
MoveToGo::SerializeHelper::serialize(n,-1)
|
28
|
+
}
|
29
|
+
it "should contain encoded text" do
|
30
|
+
serialized.should match(/<Text>[\n ]*<text>[\n ]*<\/Text>/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "Serialize custom value with xml inside" do
|
35
|
+
let(:serialized) {
|
36
|
+
v = MoveToGo::CustomValue.new
|
37
|
+
v.value = "<text>"
|
38
|
+
v.field = MoveToGo::CustomFieldReference.new()
|
39
|
+
v.field.integration_id = "1"
|
40
|
+
MoveToGo::SerializeHelper::serialize(v,-1)
|
41
|
+
}
|
42
|
+
it "should contain encoded text" do
|
43
|
+
serialized.should match(/<Value>[\n ]*<text>[\n ]*<\/Value>/)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "Serialize without data" do
|
49
|
+
let(:serialized) {
|
50
|
+
p = MoveToGo::Person.new
|
51
|
+
MoveToGo::SerializeHelper::serialize(p,-1)
|
52
|
+
}
|
53
|
+
it "should not contain fields that are not set" do
|
54
|
+
serialized.should_not match(/<Email>/)
|
55
|
+
serialized.should_not match(/<Position>/)
|
56
|
+
serialized.should_not match(/<AlternativeEmail>/)
|
57
|
+
serialized.should_not match(/<CustomValues>/)
|
58
|
+
end
|
59
|
+
it "should be utf-8" do
|
60
|
+
serialized.encoding.should equal Encoding::UTF_8
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "Serialize person" do
|
65
|
+
let(:serialized) {
|
66
|
+
p = MoveToGo::Person.new
|
67
|
+
p.id = "1"
|
68
|
+
p.first_name = "Kalle"
|
69
|
+
p.last_name = "Anka"
|
70
|
+
p.with_source do |source|
|
71
|
+
source.par_se('122345')
|
72
|
+
end
|
73
|
+
#p.source_ref = {:name => 'Go',:id => "PASE122345"}
|
74
|
+
p.with_postal_address do |addr|
|
75
|
+
addr.city = "Ankeborg"
|
76
|
+
end
|
77
|
+
p.currently_employed=true
|
78
|
+
p.set_tag("tag:anka")
|
79
|
+
p.set_tag("tag:Bj\u{00F6}rk")
|
80
|
+
p.set_tag("tag:<Bj\u{00F6}rk>")
|
81
|
+
# p.set_custom_field({:integration_id => "2", :value => "cf value"})
|
82
|
+
# p.set_custom_field({:integration_id => "3", :value => "cf Bj\u{00F6}rk"})
|
83
|
+
# p.set_custom_field({:integration_id => "4", :value => "cf <Bj\u{00F6}rk>"})
|
84
|
+
p.set_custom_value("2", "cf value")
|
85
|
+
p.set_custom_value("3", "cf Bj\u{00F6}rk")
|
86
|
+
p.set_custom_value("4", "cf <Bj\u{00F6}rk>")
|
87
|
+
MoveToGo::SerializeHelper::serialize(p,-1)
|
88
|
+
}
|
89
|
+
it "should contain first and last name" do
|
90
|
+
serialized.should match(/<FirstName>[\n ]*Kalle[\n ]*<\/FirstName>/)
|
91
|
+
serialized.should match(/Anka/)
|
92
|
+
end
|
93
|
+
it "should contain currently_employed" do
|
94
|
+
serialized.should match(/<CurrentlyEmployed>[\n ]*true[\n ]*<\/CurrentlyEmployed>/)
|
95
|
+
end
|
96
|
+
it "should tag name" do
|
97
|
+
serialized.should match(/tag:anka/)
|
98
|
+
end
|
99
|
+
it "should contain address" do
|
100
|
+
serialized.should match(/Ankeborg/)
|
101
|
+
end
|
102
|
+
it "should contain custom field" do
|
103
|
+
serialized.should match(/cf value/)
|
104
|
+
end
|
105
|
+
it "should contain reference to source" do
|
106
|
+
serialized.should match(/122345/)
|
107
|
+
end
|
108
|
+
it "should handle sv chars in tags" do
|
109
|
+
serialized.should match(/tag:Bj\u{00F6}rk/)
|
110
|
+
end
|
111
|
+
it "should handle sv chars in custom value" do
|
112
|
+
serialized.should match(/cf Bj\u{00F6}rk/)
|
113
|
+
end
|
114
|
+
it "should handle xml in tag" do
|
115
|
+
serialized.should match(/tag:<Bj\u{00F6}rk>/)
|
116
|
+
end
|
117
|
+
it "should handle xml in custom value" do
|
118
|
+
serialized.should match(/cf <Bj\u{00F6}rk>/)
|
119
|
+
end
|
120
|
+
it "should be utf-8" do
|
121
|
+
serialized.encoding.should equal Encoding::UTF_8
|
122
|
+
end
|
123
|
+
end
|
124
|
+
describe "Serialize organization" do
|
125
|
+
let(:serialized) {
|
126
|
+
organization = MoveToGo::Organization.new
|
127
|
+
organization.name = "Ankeborgs bibliotek"
|
128
|
+
organization.with_source do |source|
|
129
|
+
source.par_se('122345')
|
130
|
+
end
|
131
|
+
#organization.source_ref = {:name => 'Go',:id => "PASE122345"}
|
132
|
+
organization.set_tag("tag:bibliotek")
|
133
|
+
organization.set_tag("tag:Bj\u{00F6}rk")
|
134
|
+
organization.set_custom_value("2", "cf value")
|
135
|
+
organization.set_custom_value("3", "cf Bj\u{00F6}rk")
|
136
|
+
organization.with_postal_address do |addr|
|
137
|
+
addr.city = "Ankeborg"
|
138
|
+
end
|
139
|
+
organization.with_visit_address do |addr|
|
140
|
+
addr.city = "Gaaseborg"
|
141
|
+
end
|
142
|
+
organization.add_employee({
|
143
|
+
:integration_id => "1",
|
144
|
+
:first_name => "Kalle",
|
145
|
+
:last_name => "Anka"
|
146
|
+
})
|
147
|
+
MoveToGo::SerializeHelper::serialize(organization, -1)
|
148
|
+
}
|
149
|
+
|
150
|
+
it "should contain name" do
|
151
|
+
serialized.should match(/Ankeborgs bibliotek/)
|
152
|
+
end
|
153
|
+
it "should contain employee" do
|
154
|
+
serialized.should match(/Kalle/)
|
155
|
+
serialized.should match(/Anka/)
|
156
|
+
end
|
157
|
+
it "should contain address" do
|
158
|
+
serialized.should match(/Ankeborg/)
|
159
|
+
serialized.should match(/Gaaseborg/)
|
160
|
+
end
|
161
|
+
it "should tag name" do
|
162
|
+
serialized.should match(/<Tag>[\n ]*tag:bibliotek[\n ]*<\/Tag>/)
|
163
|
+
end
|
164
|
+
it "should contain custom field" do
|
165
|
+
serialized.should match(/cf value/)
|
166
|
+
#puts serialized
|
167
|
+
end
|
168
|
+
it "should contain reference to source" do
|
169
|
+
serialized.should match(/122345/)
|
170
|
+
end
|
171
|
+
it "should handle sv chars in tags" do
|
172
|
+
serialized.should match(/tag:Bj\u{00F6}rk/)
|
173
|
+
end
|
174
|
+
it "should handle sv chars in custom value" do
|
175
|
+
serialized.should match(/cf Bj\u{00F6}rk/)
|
176
|
+
end
|
177
|
+
it "should be utf-8" do
|
178
|
+
serialized.encoding.should equal Encoding::UTF_8
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "Serialize MoveToGo" do
|
183
|
+
let(:serialized) {
|
184
|
+
rootmodel = MoveToGo::RootModel.new
|
185
|
+
organization = MoveToGo::Organization.new
|
186
|
+
organization.name = "Ankeborgs bibliotek"
|
187
|
+
organization.integration_id = "123"
|
188
|
+
rootmodel.add_organization organization
|
189
|
+
MoveToGo::SerializeHelper::serialize(rootmodel, -1)
|
190
|
+
}
|
191
|
+
it "should contain name" do
|
192
|
+
serialized.should match(/Ankeborgs bibliotek/)
|
193
|
+
end
|
194
|
+
it "should have version" do
|
195
|
+
serialized.should match(/<GoImport Version='v3_0'/)
|
196
|
+
end
|
197
|
+
it "should be utf-8" do
|
198
|
+
serialized.encoding.should equal Encoding::UTF_8
|
199
|
+
end
|
200
|
+
end
|
201
|
+
describe "Get import rows" do
|
202
|
+
describe "for person" do
|
203
|
+
let(:import_rows) { MoveToGo::Person.new.get_import_rows }
|
204
|
+
it "should contain integration id" do
|
205
|
+
import_rows.should include({:id => 'integration_id', :name => 'Integration id', :type => :string})
|
206
|
+
import_rows.should include({:id => 'id', :name => 'Go id', :type => :string})
|
207
|
+
end
|
208
|
+
it "should contain address" do
|
209
|
+
expected = {:id => 'postal_address', :name => 'Postal address', :type => :address,
|
210
|
+
:model => [
|
211
|
+
{:id => 'street',:name => 'Street', :type => :string},
|
212
|
+
{:id => 'zip_code',:name => 'Zip code', :type => :string},
|
213
|
+
{:id => 'city',:name => 'City', :type => :string},
|
214
|
+
{:id => 'country_code',:name => 'Country code', :type => :string},
|
215
|
+
{:id => 'location',:name => 'Location', :type => :string},
|
216
|
+
{:id => 'country_name',:name => 'Country name', :type => :string},
|
217
|
+
]}
|
218
|
+
import_rows.should include(expected)
|
219
|
+
end
|
220
|
+
it "should contain organization" do
|
221
|
+
import_rows.should include({
|
222
|
+
:id => 'organization',
|
223
|
+
:name => 'Organization',
|
224
|
+
:type => :organization_reference,
|
225
|
+
:model => [
|
226
|
+
{:id => 'id', :name => 'Go id', :type => :string},
|
227
|
+
{:id => 'integration_id', :name => 'Integration id', :type => :string},
|
228
|
+
{:id => 'heading', :name => 'Heading', :type => :string}
|
229
|
+
]
|
230
|
+
})
|
231
|
+
end
|
232
|
+
end
|
233
|
+
describe "for organization" do
|
234
|
+
let(:import_rows) { MoveToGo::Organization.new.get_import_rows }
|
235
|
+
it "should contain integration id" do
|
236
|
+
import_rows.should include({:id => 'integration_id', :name => 'Integration id', :type => :string})
|
237
|
+
import_rows.should include({:id => 'id', :name => 'Go id', :type => :string})
|
238
|
+
end
|
239
|
+
it "should contain address" do
|
240
|
+
expected = {:id => 'postal_address', :name => 'Postal address', :type => :address,
|
241
|
+
:model => [
|
242
|
+
{:id => 'street',:name => 'Street', :type => :string},
|
243
|
+
{:id => 'zip_code',:name => 'Zip code', :type => :string},
|
244
|
+
{:id => 'city',:name => 'City', :type => :string},
|
245
|
+
{:id => 'country_code',:name => 'Country code', :type => :string},
|
246
|
+
{:id => 'location',:name => 'Location', :type => :string},
|
247
|
+
{:id => 'country_name',:name => 'Country name', :type => :string},
|
248
|
+
]}
|
249
|
+
import_rows.should include(expected)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|