go_import 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/bin/go-import +96 -0
  2. data/lib/go_import/csv_helper.rb +47 -0
  3. data/lib/go_import/email_helper.rb +10 -0
  4. data/lib/go_import/errors.rb +22 -0
  5. data/lib/go_import/excel_helper.rb +10 -0
  6. data/lib/go_import/global_phone.json +6571 -0
  7. data/lib/go_import/model/address.rb +61 -0
  8. data/lib/go_import/model/class_settings.rb +50 -0
  9. data/lib/go_import/model/coworker.rb +76 -0
  10. data/lib/go_import/model/coworker_reference.rb +33 -0
  11. data/lib/go_import/model/customfield.rb +87 -0
  12. data/lib/go_import/model/deal.rb +172 -0
  13. data/lib/go_import/model/deal_class_settings.rb +73 -0
  14. data/lib/go_import/model/deal_state.rb +15 -0
  15. data/lib/go_import/model/deal_status.rb +23 -0
  16. data/lib/go_import/model/deal_status_reference.rb +47 -0
  17. data/lib/go_import/model/deal_status_setting.rb +49 -0
  18. data/lib/go_import/model/documents.rb +51 -0
  19. data/lib/go_import/model/link.rb +70 -0
  20. data/lib/go_import/model/note.rb +97 -0
  21. data/lib/go_import/model/note_classification.rb +25 -0
  22. data/lib/go_import/model/organization.rb +219 -0
  23. data/lib/go_import/model/person.rb +151 -0
  24. data/lib/go_import/model/referencetosource.rb +46 -0
  25. data/lib/go_import/model/relation.rb +23 -0
  26. data/lib/go_import/model/rootmodel.rb +359 -0
  27. data/lib/go_import/model/settings.rb +61 -0
  28. data/lib/go_import/model/tag.rb +35 -0
  29. data/lib/go_import/model_helpers.rb +54 -0
  30. data/lib/go_import/phone_helper.rb +74 -0
  31. data/lib/go_import/roo_helper.rb +80 -0
  32. data/lib/go_import/serialize_helper.rb +186 -0
  33. data/lib/go_import/source.rb +87 -0
  34. data/lib/go_import/templating.rb +52 -0
  35. data/lib/go_import.rb +19 -0
  36. data/sources/csv/.gitignore +14 -0
  37. data/sources/csv/.go_import/runner.rb +62 -0
  38. data/sources/csv/Gemfile +5 -0
  39. data/sources/csv/Rakefile.rb +7 -0
  40. data/sources/csv/converter.rb +179 -0
  41. data/sources/csv/data/coworkers.csv +2 -0
  42. data/sources/csv/data/deals.csv +2 -0
  43. data/sources/csv/data/organizations.csv +2 -0
  44. data/sources/csv/data/persons.csv +2 -0
  45. data/sources/csv/spec/exporter_spec.rb +17 -0
  46. data/sources/csv/spec/sample_data/coworkers.csv +2 -0
  47. data/sources/csv/spec/sample_data/deals.csv +2 -0
  48. data/sources/csv/spec/sample_data/organizations.csv +2 -0
  49. data/sources/csv/spec/sample_data/persons.csv +2 -0
  50. data/sources/csv/spec/spec_helper.rb +30 -0
  51. data/sources/easy/.gitignore +14 -0
  52. data/sources/easy/.go_import/runner.rb +115 -0
  53. data/sources/easy/Export/readme.txt +6 -0
  54. data/sources/easy/Gemfile +5 -0
  55. data/sources/easy/Rakefile.rb +7 -0
  56. data/sources/easy/converter.rb +435 -0
  57. data/sources/easy/spec/exporter_spec.rb +10 -0
  58. data/sources/easy/spec/sample_data/Company.txt +649 -0
  59. data/sources/easy/spec/spec_helper.rb +30 -0
  60. data/sources/excel/.gitignore +14 -0
  61. data/sources/excel/.go_import/runner.rb +116 -0
  62. data/sources/excel/Gemfile +6 -0
  63. data/sources/excel/Rakefile.rb +7 -0
  64. data/sources/excel/converter.rb +130 -0
  65. data/sources/excel/spec/sample_data/sample.xlsx +0 -0
  66. data/sources/excel/spec/spec_helper.rb +26 -0
  67. data/sources/excel/spec/tomodel_spec.rb +18 -0
  68. data/sources/excel/template.xlsx +0 -0
  69. data/spec/address_spec.rb +49 -0
  70. data/spec/class_settings_spec.rb +37 -0
  71. data/spec/coworker_spec.rb +94 -0
  72. data/spec/custom_field_spec.rb +22 -0
  73. data/spec/deal_class_settings_spec.rb +104 -0
  74. data/spec/deal_spec.rb +182 -0
  75. data/spec/deal_status_reference_spec.rb +17 -0
  76. data/spec/documents_spec.rb +37 -0
  77. data/spec/helpers/csv_helper_spec.rb +29 -0
  78. data/spec/helpers/email_helper_spec.rb +32 -0
  79. data/spec/helpers/phone_helper_spec.rb +97 -0
  80. data/spec/helpers/roo_helper_spec.rb +10 -0
  81. data/spec/helpers/serialize_helper_spec.rb +249 -0
  82. data/spec/helpers/xsd_validate_spec.rb +55 -0
  83. data/spec/link_spec.rb +106 -0
  84. data/spec/note_spec.rb +110 -0
  85. data/spec/organization_spec.rb +151 -0
  86. data/spec/person_spec.rb +132 -0
  87. data/spec/rootmodel_spec.rb +371 -0
  88. data/spec/spec_helper.rb +30 -0
  89. data/spec/templating_spec.rb +12 -0
  90. metadata +306 -0
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require 'go_import'
3
+ require 'nokogiri'
4
+ describe GoImport::SerializeHelper do
5
+ describe "Validate according to xsd" do
6
+ let(:validate_result) {
7
+ i = GoImport::RootModel.new
8
+ i.settings.with_organization do |s|
9
+ s.set_custom_field({:integration_id=>"2", :title=>"cf title"})
10
+ s.set_custom_field({:integration_id=>"3", :title=>"cf title2"})
11
+ end
12
+ i.add_coworker({
13
+ :integration_id=>"123",
14
+ :first_name=>"Kalle",
15
+ :last_name=>"Anka",
16
+ :email=>"kalle.anka@vonanka.com"
17
+ })
18
+ o = GoImport::Organization.new
19
+ o.name = "Ankeborgs bibliotek"
20
+ o.with_source do |source|
21
+ source.par_se('122345')
22
+ end
23
+ #o.source_ref = {:name=>'Go',:id=>"PASE122345"}
24
+ o.set_tag("tag:bibliotek")
25
+ o.set_tag("tag:Bj\u{00F6}rk")
26
+ o.set_custom_field({:integration_id=>"2", :value=>"cf value"})
27
+ o.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
28
+ o.with_postal_address do |addr|
29
+ addr.city = "Ankeborg"
30
+ end
31
+ o.with_visit_address do |addr|
32
+ addr.city = "Gaaseborg"
33
+ end
34
+ coworker = GoImport::Coworker.new({:integration_id => "1", :first_name => "Vincent", :last_name => "Vega"})
35
+ o.responsible_coworker = coworker
36
+
37
+ emp = o.add_employee({
38
+ :integration_id => "1",
39
+ :first_name => "Kalle",
40
+ :last_name => "Anka"
41
+ })
42
+ emp.direct_phone_number = '234234234'
43
+ emp.currently_employed = true
44
+ i.organizations.push(o)
45
+ xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
46
+
47
+ xsd = Nokogiri::XML::Schema(File.read(xsd_file))
48
+ doc = Nokogiri::XML(GoImport::SerializeHelper::serialize(i,-1))
49
+ xsd.validate(doc)
50
+ }
51
+ it "Should not contain validation errors" do
52
+ expect(validate_result).to eq([])
53
+ end
54
+ end
55
+ end
data/spec/link_spec.rb ADDED
@@ -0,0 +1,106 @@
1
+ require "spec_helper"
2
+ require 'go_import'
3
+
4
+ describe "Link" do
5
+ let("link") {
6
+ GoImport::Link.new
7
+ }
8
+
9
+ it "is valid when it has url, created_by and organization" do
10
+ # given
11
+ link.url = "http://dropbox.com/"
12
+ link.created_by = GoImport::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
13
+ link.organization = GoImport::OrganizationReference.new({ :integration_id => "456", :heading => "Lundalogik" })
14
+
15
+ # when, then
16
+ link.validate.should eq ""
17
+ end
18
+
19
+ it "is valid when it has url, created_by and deal" do
20
+ # given
21
+ link.url = "http://dropbox.com/"
22
+ link.created_by = GoImport::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
23
+ link.deal = GoImport::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
24
+
25
+ # when, then
26
+ link.validate.should eq ""
27
+ end
28
+
29
+ it "is not valid when it has url and deal" do
30
+ # must have a created_by
31
+ # given
32
+ link.url = "http://dropbox.com/"
33
+ link.deal = GoImport::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
34
+
35
+ # when, then
36
+ link.validate.length.should be > 0
37
+ end
38
+
39
+ it "is not valid when it has url and created_by" do
40
+ # must have an deal or organization
41
+ # given
42
+ link.url = "http://dropbox.com/"
43
+ link.created_by = GoImport::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
44
+
45
+ # when, then
46
+ link.validate.length.should be > 0
47
+ end
48
+
49
+ it "is not valid when it has deal and created_by" do
50
+ # must have an url
51
+ # given
52
+ link.created_by = GoImport::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
53
+ link.deal = GoImport::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
54
+
55
+ # when, then
56
+ link.validate.length.should be > 0
57
+ end
58
+
59
+ it "is not valid when it has url, created_by, deal and orgaization" do
60
+ # given
61
+ link.url = "http://dropbox.com/"
62
+ link.created_by = GoImport::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
63
+ link.deal = GoImport::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
64
+ link.organization = GoImport::OrganizationReference.new({ :integration_id => "456", :heading => "Lundalogik" })
65
+
66
+ # when, then
67
+ link.validate.length.should be > 0
68
+ end
69
+
70
+ it "will auto convert org to org.ref during assignment" do
71
+ # given
72
+ org = GoImport::Organization.new({:integration_id => "123", :name => "Beagle Boys!"})
73
+
74
+ # when
75
+ link.organization = org
76
+
77
+ # then
78
+ link.organization.is_a?(GoImport::OrganizationReference).should eq true
79
+ end
80
+
81
+ it "will auto convert deal to deal.ref during assignment" do
82
+ # given
83
+ deal = GoImport::Deal.new({:integration_id => "123" })
84
+ deal.name = "The new deal"
85
+
86
+ # when
87
+ link.deal = deal
88
+
89
+ # then
90
+ link.deal.is_a?(GoImport::DealReference).should eq true
91
+ end
92
+
93
+ it "will auto convert coworker to coworker.ref during assignment" do
94
+ # given
95
+ coworker = GoImport::Coworker.new({:integration_id => "123" })
96
+ coworker.parse_name_to_firstname_lastname_se "Billy Bob"
97
+
98
+ # when
99
+ link.created_by = coworker
100
+
101
+ # then
102
+ link.created_by.is_a?(GoImport::CoworkerReference).should eq true
103
+ end
104
+
105
+
106
+ end
data/spec/note_spec.rb ADDED
@@ -0,0 +1,110 @@
1
+ require "spec_helper"
2
+ require 'go_import'
3
+
4
+ describe "Note" do
5
+ let("note") {
6
+ GoImport::Note.new
7
+ }
8
+
9
+ it "must have a text" do
10
+ note.validate.length.should be > 0
11
+ end
12
+
13
+ it "is valid when it has text, created_by and organization" do
14
+ # given
15
+ note.text = "They are very interested in the new deal (the one where you get a free bike as a gift)"
16
+ note.created_by = GoImport::CoworkerReference.new( { :integration_id => "123", :heading => "kalle anka" } )
17
+ note.organization = GoImport::OrganizationReference.new({ :integration_id => "456", :heading => "Lundalogik" })
18
+
19
+ # when, then
20
+ note.validate.should eq ""
21
+ end
22
+
23
+ it "is valid when it has text, created_by and person" do
24
+ # given
25
+ note.text = "They are very interested in the new deal (the one where you get a free bike as a gift)"
26
+ note.created_by = GoImport::CoworkerReference.new( { :integration_id => "123", :heading => "kalle anka" } )
27
+ note.person = GoImport::Person.new({ :integration_id => "456", :heading => "Billy Bob" })
28
+
29
+ # when, then
30
+ note.validate.should eq ""
31
+ end
32
+
33
+ it "is valid when it has text, created_by and deal" do
34
+ # given
35
+ note.text = "They are very interested in the new deal (the one where you get a free bike as a gift)"
36
+ note.created_by = GoImport::CoworkerReference.new( { :integration_id => "123", :heading => "kalle anka" } )
37
+ note.deal = GoImport::Deal.new({ :integration_id => "456", :heading => "The new deal" })
38
+
39
+ # when, then
40
+ note.validate.should eq ""
41
+ end
42
+
43
+ it "is invalid if no note has no attached objects" do
44
+ # given
45
+ note.text = "They are very interested in the new deal (the one where you get a free bike as a gift)"
46
+ note.created_by = GoImport::CoworkerReference.new( { :integration_id => "123", :heading => "kalle anka" } )
47
+
48
+ # when, then
49
+ note.validate.length.should be > 0
50
+ end
51
+
52
+ it "will auto convert org to org.ref during assignment" do
53
+ # given
54
+ org = GoImport::Organization.new({:integration_id => "123", :name => "Beagle Boys!"})
55
+
56
+ # when
57
+ note.organization = org
58
+
59
+ # then
60
+ note.organization.is_a?(GoImport::OrganizationReference).should eq true
61
+ end
62
+
63
+ it "will auto convert person to person.ref during assignment" do
64
+ # given
65
+ person = GoImport::Person.new({:integration_id => "123" })
66
+ person.parse_name_to_firstname_lastname_se "Billy Bob"
67
+
68
+ # when
69
+ note.person = person
70
+
71
+ # then
72
+ note.person.is_a?(GoImport::PersonReference).should eq true
73
+ end
74
+
75
+ it "will auto convert coworker to coworker.ref during assignment" do
76
+ # given
77
+ coworker = GoImport::Coworker.new({:integration_id => "123" })
78
+ coworker.parse_name_to_firstname_lastname_se "Billy Bob"
79
+
80
+ # when
81
+ note.created_by = coworker
82
+
83
+ # then
84
+ note.created_by.is_a?(GoImport::CoworkerReference).should eq true
85
+ end
86
+
87
+ it "will auto convert deal to deal.ref during assignment" do
88
+ # given
89
+ deal = GoImport::Deal.new({:integration_id => "123" })
90
+ deal.name = "The new deal"
91
+
92
+ # when
93
+ note.deal = deal
94
+
95
+ # then
96
+ note.deal.is_a?(GoImport::DealReference).should eq true
97
+ end
98
+
99
+ it "should have Comment as default classification" do
100
+ # then
101
+ note.classification.should eq GoImport::NoteClassification::Comment
102
+ end
103
+
104
+ it "should not accept invalid classifications" do
105
+ # when, then
106
+ expect {
107
+ note.classification = "hubbabubba"
108
+ }.to raise_error(GoImport::InvalidNoteClassificationError)
109
+ end
110
+ end
@@ -0,0 +1,151 @@
1
+ require "spec_helper"
2
+ require 'go_import'
3
+
4
+ describe "Organization" do
5
+ let(:organization) {
6
+ GoImport::Organization.new
7
+ }
8
+
9
+ it "must have a name" do
10
+ organization.name = "Lundalogik"
11
+
12
+ organization.validate.should eq ""
13
+ end
14
+
15
+ it "will fail on validateion if it has a source with no sourceid" do
16
+ # given
17
+ organization.name = "Lundalogik"
18
+
19
+ # when
20
+ organization.with_source do |source|
21
+ source.par_se('')
22
+ end
23
+
24
+ # then
25
+ organization.validate.length.should be > 0
26
+ end
27
+
28
+ it "will fail on validation if no name is specified" do
29
+ # given
30
+ organization.name = ""
31
+
32
+ # when, then
33
+ organization.validate.length.should be > 0
34
+ end
35
+
36
+ it "will auto convert coworker to coworker.ref during assignment" do
37
+ # given
38
+ coworker = GoImport::Coworker.new({:integration_id => "456", :first_name => "Billy", :last_name => "Bob"})
39
+
40
+ # when
41
+ organization.responsible_coworker = coworker
42
+
43
+ # then
44
+ organization.responsible_coworker.is_a?(GoImport::CoworkerReference).should eq true
45
+ end
46
+
47
+ it "will have a no relation as default" do
48
+ # given, when, then
49
+ organization.relation.should eq GoImport::Relation::NoRelation
50
+ end
51
+
52
+ it "should only accept relations from Relations enum" do
53
+ # given, when
54
+ organization.relation = GoImport::Relation::IsACustomer
55
+
56
+ # then
57
+ organization.relation.should eq GoImport::Relation::IsACustomer
58
+ end
59
+
60
+ it "should not accept invalid relations" do
61
+ # when, then
62
+ expect {
63
+ organization.relation = "hubbabubba"
64
+ }.to raise_error(GoImport::InvalidRelationError)
65
+ end
66
+
67
+ it "should not have a relation modified date if relation is NoRelation" do
68
+ # given, when
69
+ organization.relation = GoImport::Relation::NoRelation
70
+
71
+ # then
72
+ organization.relation_last_modified.nil?.should eq true
73
+ end
74
+
75
+ it "should have a relation modified date if relation is IsACustomer" do
76
+ # given, when
77
+ organization.relation = GoImport::Relation::IsACustomer
78
+
79
+ # then
80
+ organization.relation_last_modified.nil?.should eq false
81
+ end
82
+
83
+ it "should set relation last modified when relation is set" do
84
+ # given
85
+ organization.relation = GoImport::Relation::IsACustomer
86
+
87
+ # when
88
+ organization.relation_last_modified = "2014-07-01"
89
+
90
+ # then
91
+ organization.relation_last_modified.should eq "2014-07-01"
92
+ end
93
+
94
+ it "should not set relation last modified when relation is NoRelation" do
95
+ # given
96
+ organization.relation = GoImport::Relation::NoRelation
97
+
98
+ # when
99
+ organization.relation_last_modified = "2014-07-01"
100
+
101
+ # then
102
+ organization.relation_last_modified.nil?.should eq true
103
+ end
104
+
105
+ it "should only set relation last modified to valid date" do
106
+ # given
107
+ organization.relation = GoImport::Relation::IsACustomer
108
+
109
+ # when, then
110
+ expect {
111
+ organization.relation_last_modified = "hubbabubba"
112
+ }.to raise_error(GoImport::InvalidValueError)
113
+ end
114
+ end
115
+
116
+ describe "OrganizationReference" do
117
+ it "can be created from an organization" do
118
+ # given
119
+ org = GoImport::Organization.new
120
+ org.name = "Lundalogik"
121
+ org.integration_id = "123"
122
+
123
+ # when
124
+ ref = GoImport::OrganizationReference.from_organization(org)
125
+
126
+ # then
127
+ ref.is_a?(GoImport::OrganizationReference).should eq true
128
+ ref.heading.should eq "Lundalogik"
129
+ ref.integration_id.should eq "123"
130
+ end
131
+
132
+ it "can be created from an organization_reference" do
133
+ # given
134
+ orgref = GoImport::OrganizationReference.new
135
+ orgref.heading = "Lundalogik"
136
+
137
+ # when
138
+ ref = GoImport::OrganizationReference.from_organization(orgref)
139
+
140
+ # then
141
+ ref.is_a?(GoImport::OrganizationReference).should eq true
142
+ end
143
+
144
+ it "is nil when created from nil" do
145
+ # given, when
146
+ ref = GoImport::OrganizationReference.from_organization(nil)
147
+
148
+ # then
149
+ ref.should eq nil
150
+ end
151
+ end
@@ -0,0 +1,132 @@
1
+ require "spec_helper"
2
+ require 'go_import'
3
+
4
+ describe "Person" do
5
+ let(:person) {
6
+ GoImport::Person.new
7
+ }
8
+
9
+ it "can set a customfield" do
10
+ person.set_custom_field({:integration_id=>'the key',
11
+ :value=> 'the value'})
12
+
13
+ value = person.custom_values[0]
14
+ field = value.field
15
+ field.integration_id.should eq 'the key'
16
+ value.value.should eq 'the value'
17
+ end
18
+
19
+ it "will set custom field with same integration_id to the last value" do
20
+ person.set_custom_field({:integration_id=>'the key',
21
+ :value=> 'the value'})
22
+
23
+ person.set_custom_field({:integration_id=>'the key',
24
+ :value=> 'the value 2'})
25
+ value = person.custom_values[0]
26
+ field = value.field
27
+
28
+ person.custom_values.length.should eq 1
29
+ field.integration_id.should eq 'the key'
30
+ value.value.should eq 'the value 2'
31
+ end
32
+
33
+ it "will set custom field with same id to the last value" do
34
+ person.set_custom_field({ :integration_id => 'the id', :value=> 'the value' })
35
+
36
+ person.set_custom_field({ :integration_id => 'the id', :value=> 'the value 2'})
37
+ value = person.custom_values[0]
38
+ field = value.field
39
+
40
+ person.custom_values.length.should eq 1
41
+ field.integration_id.should eq 'the id'
42
+ value.value.should eq 'the value 2'
43
+ end
44
+
45
+ it "will set custom field (using set_custom_value) with same integration_id to the last value" do
46
+ person.set_custom_value('the id', 'the value')
47
+
48
+ person.set_custom_value('the id', 'the value 2')
49
+ value = person.custom_values[0]
50
+ field = value.field
51
+
52
+ person.custom_values.length.should eq 1
53
+ field.integration_id.should eq 'the id'
54
+ value.value.should eq 'the value 2'
55
+ end
56
+
57
+ it "will only set tag once" do
58
+ person.set_tag('tag1')
59
+ person.set_tag('tag1')
60
+ person.tags.length.should eq 1
61
+ tag = person.tags[0]
62
+ tag.value.should eq 'tag1'
63
+ end
64
+
65
+ it "should have a firstname if no lastname" do
66
+ person.first_name = "Vincent"
67
+ person.last_name = nil
68
+
69
+ error = person.validate
70
+ error.should be_empty
71
+ end
72
+
73
+ it "should be currently employed if nothing specified" do
74
+ expect(person.currently_employed).to eq(true)
75
+ end
76
+
77
+ it "should have a lastname if no firstname" do
78
+ person.first_name = String.new
79
+ person.last_name = "Vega"
80
+
81
+ error = person.validate
82
+ error.should be_empty
83
+ end
84
+
85
+ it "shouldnt pass validation with no firstname and lastname" do
86
+ person.first_name = String.new
87
+ person.last_name = nil
88
+
89
+ error = person.validate
90
+ error.should start_with("A firstname or lastname is required for person")
91
+ end
92
+
93
+ it "should auto convert org to org.ref during assignment" do
94
+ # given
95
+ org = GoImport::Organization.new({:integration_id => "123", :name => "Lundalogik"})
96
+
97
+ # when
98
+ person.organization = org
99
+
100
+ # then
101
+ person.organization.is_a?(GoImport::OrganizationReference).should eq true
102
+ end
103
+
104
+ describe "parse_name_to_firstname_lastname_se" do
105
+ it "can parse 'Kalle Nilsson' into firstname 'Kalle' and lastname 'Nilsson'" do
106
+ person.parse_name_to_firstname_lastname_se 'Kalle Nilsson'
107
+
108
+ person.first_name.should eq 'Kalle'
109
+ person.last_name.should eq 'Nilsson'
110
+ end
111
+
112
+ it "can parse 'Kalle Svensson Nilsson' into firstname 'Kalle' and lastname 'Svensson Nilsson'" do
113
+ person.parse_name_to_firstname_lastname_se 'Kalle Svensson Nilsson'
114
+
115
+ person.first_name.should eq 'Kalle'
116
+ person.last_name.should eq 'Svensson Nilsson'
117
+ end
118
+
119
+ it "sets default name when name is empty" do
120
+ person.parse_name_to_firstname_lastname_se '', 'a default'
121
+
122
+ person.first_name.should eq 'a default'
123
+ end
124
+
125
+ it "sets default name when name is nil" do
126
+ person.parse_name_to_firstname_lastname_se nil, 'a default'
127
+
128
+ person.first_name.should eq 'a default'
129
+ end
130
+ end
131
+ end
132
+