fruit_to_lime 2.5.5 → 2.5.6
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.
- data/lib/fruit_to_lime.rb +17 -17
- data/lib/fruit_to_lime/csv_helper.rb +47 -47
- data/lib/fruit_to_lime/email_helper.rb +10 -10
- data/lib/fruit_to_lime/errors.rb +16 -16
- data/lib/fruit_to_lime/excel_helper.rb +10 -10
- data/lib/fruit_to_lime/global_phone.json +6571 -6571
- data/lib/fruit_to_lime/model/address.rb +60 -60
- data/lib/fruit_to_lime/model/class_settings.rb +50 -50
- data/lib/fruit_to_lime/model/coworker.rb +76 -76
- data/lib/fruit_to_lime/model/coworker_reference.rb +33 -33
- data/lib/fruit_to_lime/model/customfield.rb +87 -87
- data/lib/fruit_to_lime/model/deal.rb +141 -141
- data/lib/fruit_to_lime/model/deal_status.rb +12 -12
- data/lib/fruit_to_lime/model/note.rb +80 -79
- data/lib/fruit_to_lime/model/organization.rb +203 -203
- data/lib/fruit_to_lime/model/person.rb +151 -151
- data/lib/fruit_to_lime/model/referencetosource.rb +45 -45
- data/lib/fruit_to_lime/model/relation.rb +23 -23
- data/lib/fruit_to_lime/model/rootmodel.rb +342 -338
- data/lib/fruit_to_lime/model/settings.rb +60 -60
- data/lib/fruit_to_lime/model/tag.rb +35 -35
- data/lib/fruit_to_lime/model_helpers.rb +54 -54
- data/lib/fruit_to_lime/phone_helper.rb +74 -74
- data/lib/fruit_to_lime/roo_helper.rb +72 -72
- data/lib/fruit_to_lime/serialize_helper.rb +186 -186
- data/lib/fruit_to_lime/templating.rb +52 -52
- data/spec/address_spec.rb +48 -48
- data/spec/class_settings_spec.rb +37 -37
- data/spec/coworker_spec.rb +94 -94
- data/spec/custom_field_spec.rb +22 -22
- data/spec/deal_spec.rb +101 -101
- data/spec/helpers/csv_helper_spec.rb +29 -29
- data/spec/helpers/email_helper_spec.rb +32 -32
- data/spec/helpers/phone_helper_spec.rb +97 -97
- data/spec/helpers/serialize_helper_spec.rb +249 -249
- data/spec/helpers/xsd_validate_spec.rb +58 -58
- data/spec/note_spec.rb +98 -98
- data/spec/organization_spec.rb +103 -103
- data/spec/person_spec.rb +134 -134
- data/spec/rootmodel_spec.rb +306 -277
- data/spec/templating_spec.rb +11 -11
- data/templates/csv/lib/tomodel.rb +230 -230
- data/templates/csv/spec/exporter_spec.rb +17 -17
- data/templates/csv/spec/sample_data/coworkers.csv +2 -2
- data/templates/csv/spec/sample_data/deals.csv +2 -2
- data/templates/csv/spec/sample_data/organizations.csv +2 -2
- data/templates/csv/spec/sample_data/persons.csv +2 -2
- data/templates/easy/Gemfile +5 -5
- data/templates/easy/Rakefile.rb +7 -7
- data/templates/easy/convert.rb +2 -2
- data/templates/easy/spec/exporter_spec.rb +10 -10
- data/templates/easy/spec/spec_helper.rb +24 -24
- data/templates/excel/lib/tomodel.rb +207 -207
- data/templates/sqlserver/lib/tomodel.rb +79 -79
- metadata +3 -3
@@ -1,249 +1,249 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fruit_to_lime'
|
3
|
-
|
4
|
-
describe FruitToLime::SerializeHelper do
|
5
|
-
|
6
|
-
describe "Serialize note" do
|
7
|
-
let(:serialized) {
|
8
|
-
n = FruitToLime::Note.new
|
9
|
-
n.text = "text"
|
10
|
-
FruitToLime::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(/<Note>/)
|
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 note with xml inside" do
|
24
|
-
let(:serialized) {
|
25
|
-
n = FruitToLime::Note.new
|
26
|
-
n.text = "<text>"
|
27
|
-
FruitToLime::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 = FruitToLime::CustomValue.new
|
37
|
-
v.value = "<text>"
|
38
|
-
v.field = FruitToLime::CustomFieldReference.new()
|
39
|
-
v.field.id = "1"
|
40
|
-
FruitToLime::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 = FruitToLime::Person.new
|
51
|
-
FruitToLime::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(/<Tags>/)
|
58
|
-
serialized.should_not match(/<CustomValues>/)
|
59
|
-
end
|
60
|
-
it "should be utf-8" do
|
61
|
-
serialized.encoding.should equal Encoding::UTF_8
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "Serialize person" do
|
66
|
-
let(:serialized) {
|
67
|
-
p = FruitToLime::Person.new
|
68
|
-
p.id = "1"
|
69
|
-
p.first_name = "Kalle"
|
70
|
-
p.last_name = "Anka"
|
71
|
-
p.with_source do |source|
|
72
|
-
source.par_se('122345')
|
73
|
-
end
|
74
|
-
#p.source_ref = {:name=>'Go',:id=>"PASE122345"}
|
75
|
-
p.with_postal_address do |addr|
|
76
|
-
addr.city = "Ankeborg"
|
77
|
-
end
|
78
|
-
p.currently_employed=true
|
79
|
-
p.set_tag("tag:anka")
|
80
|
-
p.set_tag("tag:Bj\u{00F6}rk")
|
81
|
-
p.set_tag("tag:<Bj\u{00F6}rk>")
|
82
|
-
p.set_custom_field({:integration_id=>"2", :value=>"cf value"})
|
83
|
-
p.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
|
84
|
-
p.set_custom_field({:integration_id=>"4", :value=>"cf <Bj\u{00F6}rk>"})
|
85
|
-
FruitToLime::SerializeHelper::serialize(p,-1)
|
86
|
-
}
|
87
|
-
it "should contain first and last name" do
|
88
|
-
serialized.should match(/<FirstName>[\n ]*Kalle[\n ]*<\/FirstName>/)
|
89
|
-
serialized.should match(/Anka/)
|
90
|
-
end
|
91
|
-
it "should contain currently_employed" do
|
92
|
-
serialized.should match(/<CurrentlyEmployed>[\n ]*true[\n ]*<\/CurrentlyEmployed>/)
|
93
|
-
end
|
94
|
-
it "should tag name" do
|
95
|
-
serialized.should match(/tag:anka/)
|
96
|
-
end
|
97
|
-
it "should contain address" do
|
98
|
-
serialized.should match(/Ankeborg/)
|
99
|
-
end
|
100
|
-
it "should contain custom field" do
|
101
|
-
serialized.should match(/cf value/)
|
102
|
-
end
|
103
|
-
it "should contain reference to source" do
|
104
|
-
serialized.should match(/122345/)
|
105
|
-
end
|
106
|
-
it "should handle sv chars in tags" do
|
107
|
-
serialized.should match(/tag:Bj\u{00F6}rk/)
|
108
|
-
end
|
109
|
-
it "should handle sv chars in custom value" do
|
110
|
-
serialized.should match(/cf Bj\u{00F6}rk/)
|
111
|
-
end
|
112
|
-
it "should handle xml in tag" do
|
113
|
-
serialized.should match(/tag:<Bj\u{00F6}rk>/)
|
114
|
-
end
|
115
|
-
it "should handle xml in custom value" do
|
116
|
-
serialized.should match(/cf <Bj\u{00F6}rk>/)
|
117
|
-
end
|
118
|
-
it "should be utf-8" do
|
119
|
-
serialized.encoding.should equal Encoding::UTF_8
|
120
|
-
end
|
121
|
-
end
|
122
|
-
describe "Serialize organization" do
|
123
|
-
let(:serialized) {
|
124
|
-
o = FruitToLime::Organization.new
|
125
|
-
o.name = "Ankeborgs bibliotek"
|
126
|
-
o.with_source do |source|
|
127
|
-
source.par_se('122345')
|
128
|
-
end
|
129
|
-
#o.source_ref = {:name=>'Go',:id=>"PASE122345"}
|
130
|
-
o.set_tag("tag:bibliotek")
|
131
|
-
o.set_tag("tag:Bj\u{00F6}rk")
|
132
|
-
o.set_custom_field({:integration_id=>"2", :value=>"cf value"})
|
133
|
-
o.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
|
134
|
-
o.with_postal_address do |addr|
|
135
|
-
addr.city = "Ankeborg"
|
136
|
-
end
|
137
|
-
o.with_visit_address do |addr|
|
138
|
-
addr.city = "Gaaseborg"
|
139
|
-
end
|
140
|
-
o.add_employee({
|
141
|
-
:integration_id => "1",
|
142
|
-
:first_name => "Kalle",
|
143
|
-
:last_name => "Anka"
|
144
|
-
})
|
145
|
-
FruitToLime::SerializeHelper::serialize(o,-1)
|
146
|
-
}
|
147
|
-
it "should contain name" do
|
148
|
-
serialized.should match(/Ankeborgs bibliotek/)
|
149
|
-
end
|
150
|
-
it "should contain employee" do
|
151
|
-
serialized.should match(/Kalle/)
|
152
|
-
serialized.should match(/Anka/)
|
153
|
-
end
|
154
|
-
it "should contain address" do
|
155
|
-
serialized.should match(/Ankeborg/)
|
156
|
-
serialized.should match(/Gaaseborg/)
|
157
|
-
end
|
158
|
-
it "should tag name" do
|
159
|
-
serialized.should match(/<Tag>[\n ]*tag:bibliotek[\n ]*<\/Tag>/)
|
160
|
-
end
|
161
|
-
it "should contain custom field" do
|
162
|
-
serialized.should match(/cf value/)
|
163
|
-
#puts serialized
|
164
|
-
end
|
165
|
-
it "should contain reference to source" do
|
166
|
-
serialized.should match(/122345/)
|
167
|
-
end
|
168
|
-
it "should handle sv chars in tags" do
|
169
|
-
serialized.should match(/tag:Bj\u{00F6}rk/)
|
170
|
-
end
|
171
|
-
it "should handle sv chars in custom value" do
|
172
|
-
serialized.should match(/cf Bj\u{00F6}rk/)
|
173
|
-
end
|
174
|
-
it "should be utf-8" do
|
175
|
-
serialized.encoding.should equal Encoding::UTF_8
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe "Serialize goimport" do
|
180
|
-
let(:serialized) {
|
181
|
-
i = FruitToLime::RootModel.new
|
182
|
-
o = FruitToLime::Organization.new
|
183
|
-
o.name = "Ankeborgs bibliotek"
|
184
|
-
i.organizations.push(o)
|
185
|
-
FruitToLime::SerializeHelper::serialize(i,-1)
|
186
|
-
}
|
187
|
-
it "should contain name" do
|
188
|
-
serialized.should match(/Ankeborgs bibliotek/)
|
189
|
-
end
|
190
|
-
it "should have version" do
|
191
|
-
serialized.should match(/<GoImport Version='v2_0'/)
|
192
|
-
end
|
193
|
-
it "should be utf-8" do
|
194
|
-
serialized.encoding.should equal Encoding::UTF_8
|
195
|
-
end
|
196
|
-
end
|
197
|
-
describe "Get import rows" do
|
198
|
-
describe "for person" do
|
199
|
-
let(:import_rows) { FruitToLime::Person.new.get_import_rows }
|
200
|
-
it "should contain integration id" do
|
201
|
-
import_rows.should include({:id=>'integration_id', :name=>'Integration id', :type=>:string})
|
202
|
-
import_rows.should include({:id=>'id', :name=>'Go id', :type=>:string})
|
203
|
-
end
|
204
|
-
it "should contain address" do
|
205
|
-
expected = {:id=>'postal_address', :name=>'Postal address', :type=>:address,
|
206
|
-
:model=>[
|
207
|
-
{:id=>'street',:name=>'Street', :type=>:string},
|
208
|
-
{:id=>'zip_code',:name=>'Zip code', :type=>:string},
|
209
|
-
{:id=>'city',:name=>'City', :type=>:string},
|
210
|
-
{:id=>'country_code',:name=>'Country code', :type=>:string},
|
211
|
-
{:id=>'location',:name=>'Location', :type=>:string},
|
212
|
-
{:id=>'country_name',:name=>'Country name', :type=>:string},
|
213
|
-
]}
|
214
|
-
import_rows.should include(expected)
|
215
|
-
end
|
216
|
-
it "should contain organization" do
|
217
|
-
import_rows.should include({
|
218
|
-
:id=>'organization',
|
219
|
-
:name=>'Organization',
|
220
|
-
:type=>:organization_reference,
|
221
|
-
:model=>[
|
222
|
-
{:id=>'id', :name=>'Go id', :type=>:string},
|
223
|
-
{:id=>'integration_id', :name=>'Integration id', :type=>:string},
|
224
|
-
{:id=>'heading', :name=>'Heading', :type=>:string}
|
225
|
-
]
|
226
|
-
})
|
227
|
-
end
|
228
|
-
end
|
229
|
-
describe "for organization" do
|
230
|
-
let(:import_rows) { FruitToLime::Organization.new.get_import_rows }
|
231
|
-
it "should contain integration id" do
|
232
|
-
import_rows.should include({:id=>'integration_id', :name=>'Integration id', :type=>:string})
|
233
|
-
import_rows.should include({:id=>'id', :name=>'Go id', :type=>:string})
|
234
|
-
end
|
235
|
-
it "should contain address" do
|
236
|
-
expected = {:id=>'postal_address', :name=>'Postal address', :type=>:address,
|
237
|
-
:model=>[
|
238
|
-
{:id=>'street',:name=>'Street', :type=>:string},
|
239
|
-
{:id=>'zip_code',:name=>'Zip code', :type=>:string},
|
240
|
-
{:id=>'city',:name=>'City', :type=>:string},
|
241
|
-
{:id=>'country_code',:name=>'Country code', :type=>:string},
|
242
|
-
{:id=>'location',:name=>'Location', :type=>:string},
|
243
|
-
{:id=>'country_name',:name=>'Country name', :type=>:string},
|
244
|
-
]}
|
245
|
-
import_rows.should include(expected)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe FruitToLime::SerializeHelper do
|
5
|
+
|
6
|
+
describe "Serialize note" do
|
7
|
+
let(:serialized) {
|
8
|
+
n = FruitToLime::Note.new
|
9
|
+
n.text = "text"
|
10
|
+
FruitToLime::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(/<Note>/)
|
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 note with xml inside" do
|
24
|
+
let(:serialized) {
|
25
|
+
n = FruitToLime::Note.new
|
26
|
+
n.text = "<text>"
|
27
|
+
FruitToLime::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 = FruitToLime::CustomValue.new
|
37
|
+
v.value = "<text>"
|
38
|
+
v.field = FruitToLime::CustomFieldReference.new()
|
39
|
+
v.field.id = "1"
|
40
|
+
FruitToLime::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 = FruitToLime::Person.new
|
51
|
+
FruitToLime::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(/<Tags>/)
|
58
|
+
serialized.should_not match(/<CustomValues>/)
|
59
|
+
end
|
60
|
+
it "should be utf-8" do
|
61
|
+
serialized.encoding.should equal Encoding::UTF_8
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "Serialize person" do
|
66
|
+
let(:serialized) {
|
67
|
+
p = FruitToLime::Person.new
|
68
|
+
p.id = "1"
|
69
|
+
p.first_name = "Kalle"
|
70
|
+
p.last_name = "Anka"
|
71
|
+
p.with_source do |source|
|
72
|
+
source.par_se('122345')
|
73
|
+
end
|
74
|
+
#p.source_ref = {:name=>'Go',:id=>"PASE122345"}
|
75
|
+
p.with_postal_address do |addr|
|
76
|
+
addr.city = "Ankeborg"
|
77
|
+
end
|
78
|
+
p.currently_employed=true
|
79
|
+
p.set_tag("tag:anka")
|
80
|
+
p.set_tag("tag:Bj\u{00F6}rk")
|
81
|
+
p.set_tag("tag:<Bj\u{00F6}rk>")
|
82
|
+
p.set_custom_field({:integration_id=>"2", :value=>"cf value"})
|
83
|
+
p.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
|
84
|
+
p.set_custom_field({:integration_id=>"4", :value=>"cf <Bj\u{00F6}rk>"})
|
85
|
+
FruitToLime::SerializeHelper::serialize(p,-1)
|
86
|
+
}
|
87
|
+
it "should contain first and last name" do
|
88
|
+
serialized.should match(/<FirstName>[\n ]*Kalle[\n ]*<\/FirstName>/)
|
89
|
+
serialized.should match(/Anka/)
|
90
|
+
end
|
91
|
+
it "should contain currently_employed" do
|
92
|
+
serialized.should match(/<CurrentlyEmployed>[\n ]*true[\n ]*<\/CurrentlyEmployed>/)
|
93
|
+
end
|
94
|
+
it "should tag name" do
|
95
|
+
serialized.should match(/tag:anka/)
|
96
|
+
end
|
97
|
+
it "should contain address" do
|
98
|
+
serialized.should match(/Ankeborg/)
|
99
|
+
end
|
100
|
+
it "should contain custom field" do
|
101
|
+
serialized.should match(/cf value/)
|
102
|
+
end
|
103
|
+
it "should contain reference to source" do
|
104
|
+
serialized.should match(/122345/)
|
105
|
+
end
|
106
|
+
it "should handle sv chars in tags" do
|
107
|
+
serialized.should match(/tag:Bj\u{00F6}rk/)
|
108
|
+
end
|
109
|
+
it "should handle sv chars in custom value" do
|
110
|
+
serialized.should match(/cf Bj\u{00F6}rk/)
|
111
|
+
end
|
112
|
+
it "should handle xml in tag" do
|
113
|
+
serialized.should match(/tag:<Bj\u{00F6}rk>/)
|
114
|
+
end
|
115
|
+
it "should handle xml in custom value" do
|
116
|
+
serialized.should match(/cf <Bj\u{00F6}rk>/)
|
117
|
+
end
|
118
|
+
it "should be utf-8" do
|
119
|
+
serialized.encoding.should equal Encoding::UTF_8
|
120
|
+
end
|
121
|
+
end
|
122
|
+
describe "Serialize organization" do
|
123
|
+
let(:serialized) {
|
124
|
+
o = FruitToLime::Organization.new
|
125
|
+
o.name = "Ankeborgs bibliotek"
|
126
|
+
o.with_source do |source|
|
127
|
+
source.par_se('122345')
|
128
|
+
end
|
129
|
+
#o.source_ref = {:name=>'Go',:id=>"PASE122345"}
|
130
|
+
o.set_tag("tag:bibliotek")
|
131
|
+
o.set_tag("tag:Bj\u{00F6}rk")
|
132
|
+
o.set_custom_field({:integration_id=>"2", :value=>"cf value"})
|
133
|
+
o.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
|
134
|
+
o.with_postal_address do |addr|
|
135
|
+
addr.city = "Ankeborg"
|
136
|
+
end
|
137
|
+
o.with_visit_address do |addr|
|
138
|
+
addr.city = "Gaaseborg"
|
139
|
+
end
|
140
|
+
o.add_employee({
|
141
|
+
:integration_id => "1",
|
142
|
+
:first_name => "Kalle",
|
143
|
+
:last_name => "Anka"
|
144
|
+
})
|
145
|
+
FruitToLime::SerializeHelper::serialize(o,-1)
|
146
|
+
}
|
147
|
+
it "should contain name" do
|
148
|
+
serialized.should match(/Ankeborgs bibliotek/)
|
149
|
+
end
|
150
|
+
it "should contain employee" do
|
151
|
+
serialized.should match(/Kalle/)
|
152
|
+
serialized.should match(/Anka/)
|
153
|
+
end
|
154
|
+
it "should contain address" do
|
155
|
+
serialized.should match(/Ankeborg/)
|
156
|
+
serialized.should match(/Gaaseborg/)
|
157
|
+
end
|
158
|
+
it "should tag name" do
|
159
|
+
serialized.should match(/<Tag>[\n ]*tag:bibliotek[\n ]*<\/Tag>/)
|
160
|
+
end
|
161
|
+
it "should contain custom field" do
|
162
|
+
serialized.should match(/cf value/)
|
163
|
+
#puts serialized
|
164
|
+
end
|
165
|
+
it "should contain reference to source" do
|
166
|
+
serialized.should match(/122345/)
|
167
|
+
end
|
168
|
+
it "should handle sv chars in tags" do
|
169
|
+
serialized.should match(/tag:Bj\u{00F6}rk/)
|
170
|
+
end
|
171
|
+
it "should handle sv chars in custom value" do
|
172
|
+
serialized.should match(/cf Bj\u{00F6}rk/)
|
173
|
+
end
|
174
|
+
it "should be utf-8" do
|
175
|
+
serialized.encoding.should equal Encoding::UTF_8
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "Serialize goimport" do
|
180
|
+
let(:serialized) {
|
181
|
+
i = FruitToLime::RootModel.new
|
182
|
+
o = FruitToLime::Organization.new
|
183
|
+
o.name = "Ankeborgs bibliotek"
|
184
|
+
i.organizations.push(o)
|
185
|
+
FruitToLime::SerializeHelper::serialize(i,-1)
|
186
|
+
}
|
187
|
+
it "should contain name" do
|
188
|
+
serialized.should match(/Ankeborgs bibliotek/)
|
189
|
+
end
|
190
|
+
it "should have version" do
|
191
|
+
serialized.should match(/<GoImport Version='v2_0'/)
|
192
|
+
end
|
193
|
+
it "should be utf-8" do
|
194
|
+
serialized.encoding.should equal Encoding::UTF_8
|
195
|
+
end
|
196
|
+
end
|
197
|
+
describe "Get import rows" do
|
198
|
+
describe "for person" do
|
199
|
+
let(:import_rows) { FruitToLime::Person.new.get_import_rows }
|
200
|
+
it "should contain integration id" do
|
201
|
+
import_rows.should include({:id=>'integration_id', :name=>'Integration id', :type=>:string})
|
202
|
+
import_rows.should include({:id=>'id', :name=>'Go id', :type=>:string})
|
203
|
+
end
|
204
|
+
it "should contain address" do
|
205
|
+
expected = {:id=>'postal_address', :name=>'Postal address', :type=>:address,
|
206
|
+
:model=>[
|
207
|
+
{:id=>'street',:name=>'Street', :type=>:string},
|
208
|
+
{:id=>'zip_code',:name=>'Zip code', :type=>:string},
|
209
|
+
{:id=>'city',:name=>'City', :type=>:string},
|
210
|
+
{:id=>'country_code',:name=>'Country code', :type=>:string},
|
211
|
+
{:id=>'location',:name=>'Location', :type=>:string},
|
212
|
+
{:id=>'country_name',:name=>'Country name', :type=>:string},
|
213
|
+
]}
|
214
|
+
import_rows.should include(expected)
|
215
|
+
end
|
216
|
+
it "should contain organization" do
|
217
|
+
import_rows.should include({
|
218
|
+
:id=>'organization',
|
219
|
+
:name=>'Organization',
|
220
|
+
:type=>:organization_reference,
|
221
|
+
:model=>[
|
222
|
+
{:id=>'id', :name=>'Go id', :type=>:string},
|
223
|
+
{:id=>'integration_id', :name=>'Integration id', :type=>:string},
|
224
|
+
{:id=>'heading', :name=>'Heading', :type=>:string}
|
225
|
+
]
|
226
|
+
})
|
227
|
+
end
|
228
|
+
end
|
229
|
+
describe "for organization" do
|
230
|
+
let(:import_rows) { FruitToLime::Organization.new.get_import_rows }
|
231
|
+
it "should contain integration id" do
|
232
|
+
import_rows.should include({:id=>'integration_id', :name=>'Integration id', :type=>:string})
|
233
|
+
import_rows.should include({:id=>'id', :name=>'Go id', :type=>:string})
|
234
|
+
end
|
235
|
+
it "should contain address" do
|
236
|
+
expected = {:id=>'postal_address', :name=>'Postal address', :type=>:address,
|
237
|
+
:model=>[
|
238
|
+
{:id=>'street',:name=>'Street', :type=>:string},
|
239
|
+
{:id=>'zip_code',:name=>'Zip code', :type=>:string},
|
240
|
+
{:id=>'city',:name=>'City', :type=>:string},
|
241
|
+
{:id=>'country_code',:name=>'Country code', :type=>:string},
|
242
|
+
{:id=>'location',:name=>'Location', :type=>:string},
|
243
|
+
{:id=>'country_name',:name=>'Country name', :type=>:string},
|
244
|
+
]}
|
245
|
+
import_rows.should include(expected)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|