fruit_to_lime 2.5.3 → 2.5.5

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.
Files changed (57) hide show
  1. data/lib/fruit_to_lime.rb +17 -17
  2. data/lib/fruit_to_lime/csv_helper.rb +47 -47
  3. data/lib/fruit_to_lime/email_helper.rb +10 -10
  4. data/lib/fruit_to_lime/errors.rb +16 -16
  5. data/lib/fruit_to_lime/excel_helper.rb +10 -10
  6. data/lib/fruit_to_lime/global_phone.json +6571 -6571
  7. data/lib/fruit_to_lime/model/address.rb +60 -60
  8. data/lib/fruit_to_lime/model/class_settings.rb +50 -50
  9. data/lib/fruit_to_lime/model/coworker.rb +76 -76
  10. data/lib/fruit_to_lime/model/coworker_reference.rb +33 -33
  11. data/lib/fruit_to_lime/model/customfield.rb +87 -87
  12. data/lib/fruit_to_lime/model/deal.rb +141 -145
  13. data/lib/fruit_to_lime/model/deal_status.rb +12 -12
  14. data/lib/fruit_to_lime/model/note.rb +79 -79
  15. data/lib/fruit_to_lime/model/organization.rb +203 -197
  16. data/lib/fruit_to_lime/model/person.rb +151 -151
  17. data/lib/fruit_to_lime/model/referencetosource.rb +45 -45
  18. data/lib/fruit_to_lime/model/relation.rb +23 -23
  19. data/lib/fruit_to_lime/model/rootmodel.rb +338 -330
  20. data/lib/fruit_to_lime/model/settings.rb +60 -60
  21. data/lib/fruit_to_lime/model/tag.rb +35 -35
  22. data/lib/fruit_to_lime/model_helpers.rb +54 -54
  23. data/lib/fruit_to_lime/phone_helper.rb +74 -74
  24. data/lib/fruit_to_lime/roo_helper.rb +72 -72
  25. data/lib/fruit_to_lime/serialize_helper.rb +186 -186
  26. data/lib/fruit_to_lime/templating.rb +52 -52
  27. data/spec/address_spec.rb +48 -48
  28. data/spec/class_settings_spec.rb +37 -37
  29. data/spec/coworker_spec.rb +94 -94
  30. data/spec/custom_field_spec.rb +22 -22
  31. data/spec/deal_spec.rb +101 -102
  32. data/spec/helpers/csv_helper_spec.rb +29 -29
  33. data/spec/helpers/email_helper_spec.rb +32 -32
  34. data/spec/helpers/phone_helper_spec.rb +97 -97
  35. data/spec/helpers/serialize_helper_spec.rb +249 -249
  36. data/spec/helpers/xsd_validate_spec.rb +58 -58
  37. data/spec/note_spec.rb +98 -67
  38. data/spec/organization_spec.rb +103 -89
  39. data/spec/person_spec.rb +134 -134
  40. data/spec/rootmodel_spec.rb +277 -230
  41. data/spec/templating_spec.rb +11 -11
  42. data/templates/csv/lib/tomodel.rb +230 -230
  43. data/templates/csv/spec/exporter_spec.rb +17 -17
  44. data/templates/csv/spec/sample_data/coworkers.csv +2 -2
  45. data/templates/csv/spec/sample_data/deals.csv +2 -2
  46. data/templates/csv/spec/sample_data/organizations.csv +2 -2
  47. data/templates/csv/spec/sample_data/persons.csv +2 -2
  48. data/templates/easy/Gemfile +5 -0
  49. data/templates/easy/Rakefile.rb +7 -0
  50. data/templates/easy/convert.rb +3 -0
  51. data/templates/easy/lib/tomodel.rb +330 -0
  52. data/templates/easy/spec/exporter_spec.rb +10 -0
  53. data/templates/easy/spec/sample_data/Company.txt +649 -0
  54. data/templates/easy/spec/spec_helper.rb +24 -0
  55. data/templates/excel/lib/tomodel.rb +207 -207
  56. data/templates/sqlserver/lib/tomodel.rb +79 -79
  57. metadata +10 -3
@@ -1,58 +1,58 @@
1
-
2
- require 'spec_helper'
3
- require 'fruit_to_lime'
4
- require 'nokogiri'
5
- describe FruitToLime::SerializeHelper do
6
-
7
- describe "Validate according to xsd" do
8
- let(:validate_result) {
9
- i = FruitToLime::RootModel.new
10
- i.settings.with_organization do |s|
11
- s.set_custom_field({:integration_id=>"2", :title=>"cf title"})
12
- s.set_custom_field({:integration_id=>"3", :title=>"cf title2"})
13
- end
14
- i.add_coworker({
15
- :integration_id=>"123",
16
- :first_name=>"Kalle",
17
- :last_name=>"Anka",
18
- :email=>"kalle.anka@vonanka.com"
19
- })
20
- o = FruitToLime::Organization.new
21
- o.name = "Ankeborgs bibliotek"
22
- o.with_source do |source|
23
- source.par_se('122345')
24
- end
25
- #o.source_ref = {:name=>'Go',:id=>"PASE122345"}
26
- o.set_tag("tag:bibliotek")
27
- o.set_tag("tag:Bj\u{00F6}rk")
28
- o.set_custom_field({:integration_id=>"2", :value=>"cf value"})
29
- o.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
30
- o.with_postal_address do |addr|
31
- addr.city = "Ankeborg"
32
- end
33
- o.with_visit_address do |addr|
34
- addr.city = "Gaaseborg"
35
- end
36
- coworker = FruitToLime::Coworker.new({:integration_id => "1", :first_name => "Vincent", :last_name => "Vega"})
37
- o.responsible_coworker = coworker
38
-
39
- emp = o.add_employee({
40
- :integration_id => "1",
41
- :first_name => "Kalle",
42
- :last_name => "Anka"
43
- })
44
- emp.direct_phone_number = '234234234'
45
- emp.currently_employed = true
46
- i.organizations.push(o)
47
- xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
48
-
49
- xsd = Nokogiri::XML::Schema(File.read(xsd_file))
50
- doc = Nokogiri::XML(FruitToLime::SerializeHelper::serialize(i,-1))
51
- xsd.validate(doc)
52
- }
53
- it "Should not contain validation errors" do
54
- expect(validate_result).to eq([])
55
- end
56
-
57
- end
58
- end
1
+
2
+ require 'spec_helper'
3
+ require 'fruit_to_lime'
4
+ require 'nokogiri'
5
+ describe FruitToLime::SerializeHelper do
6
+
7
+ describe "Validate according to xsd" do
8
+ let(:validate_result) {
9
+ i = FruitToLime::RootModel.new
10
+ i.settings.with_organization do |s|
11
+ s.set_custom_field({:integration_id=>"2", :title=>"cf title"})
12
+ s.set_custom_field({:integration_id=>"3", :title=>"cf title2"})
13
+ end
14
+ i.add_coworker({
15
+ :integration_id=>"123",
16
+ :first_name=>"Kalle",
17
+ :last_name=>"Anka",
18
+ :email=>"kalle.anka@vonanka.com"
19
+ })
20
+ o = FruitToLime::Organization.new
21
+ o.name = "Ankeborgs bibliotek"
22
+ o.with_source do |source|
23
+ source.par_se('122345')
24
+ end
25
+ #o.source_ref = {:name=>'Go',:id=>"PASE122345"}
26
+ o.set_tag("tag:bibliotek")
27
+ o.set_tag("tag:Bj\u{00F6}rk")
28
+ o.set_custom_field({:integration_id=>"2", :value=>"cf value"})
29
+ o.set_custom_field({:integration_id=>"3", :value=>"cf Bj\u{00F6}rk"})
30
+ o.with_postal_address do |addr|
31
+ addr.city = "Ankeborg"
32
+ end
33
+ o.with_visit_address do |addr|
34
+ addr.city = "Gaaseborg"
35
+ end
36
+ coworker = FruitToLime::Coworker.new({:integration_id => "1", :first_name => "Vincent", :last_name => "Vega"})
37
+ o.responsible_coworker = coworker
38
+
39
+ emp = o.add_employee({
40
+ :integration_id => "1",
41
+ :first_name => "Kalle",
42
+ :last_name => "Anka"
43
+ })
44
+ emp.direct_phone_number = '234234234'
45
+ emp.currently_employed = true
46
+ i.organizations.push(o)
47
+ xsd_file = File.join(File.dirname(__FILE__), '..', 'sample_data', 'schema0.xsd')
48
+
49
+ xsd = Nokogiri::XML::Schema(File.read(xsd_file))
50
+ doc = Nokogiri::XML(FruitToLime::SerializeHelper::serialize(i,-1))
51
+ xsd.validate(doc)
52
+ }
53
+ it "Should not contain validation errors" do
54
+ expect(validate_result).to eq([])
55
+ end
56
+
57
+ end
58
+ end
data/spec/note_spec.rb CHANGED
@@ -1,67 +1,98 @@
1
- require "spec_helper"
2
- require 'fruit_to_lime'
3
-
4
- describe "Note" do
5
- let("note") {
6
- FruitToLime::Note.new
7
- }
8
-
9
- it "must have a text" do
10
- note.validate.length > 0
11
- end
12
-
13
- it "is valid when it has text, created_by and organization" do
14
- note.text = "They are very interested in the new deal (the one where you get a free bike as a gift)"
15
- note.created_by = FruitToLime::CoworkerReference.new( { :integration_id => "123", :heading => "kalle anka" } )
16
- note.organization = FruitToLime::OrganizationReference.new({ :integration_id => "456", :heading => "Lundalogik" })
17
-
18
- note.validate.should eq ""
19
- end
20
-
21
- it "will auto convert org to org.ref during assignment" do
22
- # given
23
- org = FruitToLime::Organization.new({:integration_id => "123", :name => "Beagle Boys!"})
24
-
25
- # when
26
- note.organization = org
27
-
28
- # then
29
- note.organization.is_a?(FruitToLime::OrganizationReference).should eq true
30
- end
31
-
32
- it "will auto convert person to person.ref during assignment" do
33
- # given
34
- person = FruitToLime::Person.new({:integration_id => "123" })
35
- person.parse_name_to_firstname_lastname_se "Billy Bob"
36
-
37
- # when
38
- note.person = person
39
-
40
- # then
41
- note.person.is_a?(FruitToLime::PersonReference).should eq true
42
- end
43
-
44
- it "will auto convert coworker to coworker.ref during assignment" do
45
- # given
46
- coworker = FruitToLime::Coworker.new({:integration_id => "123" })
47
- coworker.parse_name_to_firstname_lastname_se "Billy Bob"
48
-
49
- # when
50
- note.created_by = coworker
51
-
52
- # then
53
- note.created_by.is_a?(FruitToLime::CoworkerReference).should eq true
54
- end
55
-
56
- it "will auto convert deal to deal.ref during assignment" do
57
- # given
58
- deal = FruitToLime::Deal.new({:integration_id => "123" })
59
- deal.name = "The new deal"
60
-
61
- # when
62
- note.deal = deal
63
-
64
- # then
65
- note.deal.is_a?(FruitToLime::DealReference).should eq true
66
- end
67
- end
1
+ require "spec_helper"
2
+ require 'fruit_to_lime'
3
+
4
+ describe "Note" do
5
+ let("note") {
6
+ FruitToLime::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 = FruitToLime::CoworkerReference.new( { :integration_id => "123", :heading => "kalle anka" } )
17
+ note.organization = FruitToLime::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 = FruitToLime::CoworkerReference.new( { :integration_id => "123", :heading => "kalle anka" } )
27
+ note.person = FruitToLime::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 = FruitToLime::CoworkerReference.new( { :integration_id => "123", :heading => "kalle anka" } )
37
+ note.deal = FruitToLime::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 = FruitToLime::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 = FruitToLime::Organization.new({:integration_id => "123", :name => "Beagle Boys!"})
55
+
56
+ # when
57
+ note.organization = org
58
+
59
+ # then
60
+ note.organization.is_a?(FruitToLime::OrganizationReference).should eq true
61
+ end
62
+
63
+ it "will auto convert person to person.ref during assignment" do
64
+ # given
65
+ person = FruitToLime::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?(FruitToLime::PersonReference).should eq true
73
+ end
74
+
75
+ it "will auto convert coworker to coworker.ref during assignment" do
76
+ # given
77
+ coworker = FruitToLime::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?(FruitToLime::CoworkerReference).should eq true
85
+ end
86
+
87
+ it "will auto convert deal to deal.ref during assignment" do
88
+ # given
89
+ deal = FruitToLime::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?(FruitToLime::DealReference).should eq true
97
+ end
98
+ end
@@ -1,89 +1,103 @@
1
- require "spec_helper"
2
- require 'fruit_to_lime'
3
-
4
- describe "Organization" do
5
- let(:organization) {
6
- FruitToLime::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 validation if no name is specified" do
16
- organization.name = ""
17
-
18
- organization.validate.length > 0
19
- end
20
-
21
- it "will auto convert coworker to coworker.ref during assignment" do
22
- # given
23
- coworker = FruitToLime::Coworker.new({:integration_id => "456", :first_name => "Billy", :last_name => "Bob"})
24
-
25
- # when
26
- organization.responsible_coworker = coworker
27
-
28
- # then
29
- organization.responsible_coworker.is_a?(FruitToLime::CoworkerReference).should eq true
30
- end
31
-
32
- it "will have a no relation as default" do
33
- # given, when, then
34
- organization.relation.should eq FruitToLime::Relation::NoRelation
35
- end
36
-
37
- it "should only accept relations from Relations enum" do
38
- # given, when
39
- organization.relation = FruitToLime::Relation::IsACustomer
40
-
41
- # then
42
- organization.relation.should eq FruitToLime::Relation::IsACustomer
43
- end
44
-
45
- it "should not accept invalid relations" do
46
- # when, then
47
- expect {
48
- organization.relation = "hubbabubba"
49
- }.to raise_error(FruitToLime::InvalidRelationError)
50
- end
51
-
52
- end
53
-
54
- describe "OrganizationReference" do
55
- it "can be created from an organization" do
56
- # given
57
- org = FruitToLime::Organization.new
58
- org.name = "Lundalogik"
59
- org.integration_id = "123"
60
-
61
- # when
62
- ref = FruitToLime::OrganizationReference.from_organization(org)
63
-
64
- # then
65
- ref.is_a?(FruitToLime::OrganizationReference).should eq true
66
- ref.heading.should eq "Lundalogik"
67
- ref.integration_id.should eq "123"
68
- end
69
-
70
- it "can be created from an organization_reference" do
71
- # given
72
- orgref = FruitToLime::OrganizationReference.new
73
- orgref.heading = "Lundalogik"
74
-
75
- # when
76
- ref = FruitToLime::OrganizationReference.from_organization(orgref)
77
-
78
- # then
79
- ref.is_a?(FruitToLime::OrganizationReference).should eq true
80
- end
81
-
82
- it "is nil when created from nil" do
83
- # given, when
84
- ref = FruitToLime::OrganizationReference.from_organization(nil)
85
-
86
- # then
87
- ref.should eq nil
88
- end
89
- end
1
+ require "spec_helper"
2
+ require 'fruit_to_lime'
3
+
4
+ describe "Organization" do
5
+ let(:organization) {
6
+ FruitToLime::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 = FruitToLime::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?(FruitToLime::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 FruitToLime::Relation::NoRelation
50
+ end
51
+
52
+ it "should only accept relations from Relations enum" do
53
+ # given, when
54
+ organization.relation = FruitToLime::Relation::IsACustomer
55
+
56
+ # then
57
+ organization.relation.should eq FruitToLime::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(FruitToLime::InvalidRelationError)
65
+ end
66
+ end
67
+
68
+ describe "OrganizationReference" do
69
+ it "can be created from an organization" do
70
+ # given
71
+ org = FruitToLime::Organization.new
72
+ org.name = "Lundalogik"
73
+ org.integration_id = "123"
74
+
75
+ # when
76
+ ref = FruitToLime::OrganizationReference.from_organization(org)
77
+
78
+ # then
79
+ ref.is_a?(FruitToLime::OrganizationReference).should eq true
80
+ ref.heading.should eq "Lundalogik"
81
+ ref.integration_id.should eq "123"
82
+ end
83
+
84
+ it "can be created from an organization_reference" do
85
+ # given
86
+ orgref = FruitToLime::OrganizationReference.new
87
+ orgref.heading = "Lundalogik"
88
+
89
+ # when
90
+ ref = FruitToLime::OrganizationReference.from_organization(orgref)
91
+
92
+ # then
93
+ ref.is_a?(FruitToLime::OrganizationReference).should eq true
94
+ end
95
+
96
+ it "is nil when created from nil" do
97
+ # given, when
98
+ ref = FruitToLime::OrganizationReference.from_organization(nil)
99
+
100
+ # then
101
+ ref.should eq nil
102
+ end
103
+ end