fruit_to_lime 2.3.1 → 2.3.2
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/bin/fruit_to_lime +24 -24
- data/lib/fruit_to_lime/email_helper.rb +10 -0
- data/lib/fruit_to_lime/errors.rb +4 -1
- data/lib/fruit_to_lime/excel_helper.rb +10 -0
- data/lib/fruit_to_lime/global_phone.json +6571 -0
- data/lib/fruit_to_lime/model/class_settings.rb +7 -4
- data/lib/fruit_to_lime/model/coworker.rb +2 -2
- data/lib/fruit_to_lime/model/coworker_reference.rb +10 -0
- data/lib/fruit_to_lime/model/deal.rb +12 -3
- data/lib/fruit_to_lime/model/note.rb +42 -1
- data/lib/fruit_to_lime/model/organization.rb +29 -7
- data/lib/fruit_to_lime/model/person.rb +26 -9
- data/lib/fruit_to_lime/model/rootmodel.rb +145 -9
- data/lib/fruit_to_lime/phone_helper.rb +74 -0
- data/lib/fruit_to_lime.rb +4 -1
- data/spec/class_settings_spec.rb +23 -3
- data/spec/deal_spec.rb +22 -12
- data/spec/helpers/email_helper_spec.rb +32 -0
- data/spec/helpers/phone_helper_spec.rb +97 -0
- data/spec/helpers/roo_helper_spec.rb +10 -10
- data/spec/note_spec.rb +55 -0
- data/spec/organization_spec.rb +57 -0
- data/spec/person_spec.rb +15 -6
- data/spec/rootmodel_spec.rb +133 -7
- data/spec/spec_helper.rb +24 -24
- data/templates/csv/Gemfile +5 -5
- data/templates/csv/Rakefile.rb +7 -7
- data/templates/csv/convert.rb +2 -2
- data/templates/csv/spec/spec_helper.rb +24 -24
- data/templates/excel/Gemfile +6 -6
- data/templates/excel/Rakefile.rb +7 -7
- data/templates/excel/convert.rb +2 -2
- data/templates/excel/lib/tomodel.rb +167 -29
- data/templates/excel/spec/spec_helper.rb +20 -20
- data/templates/excel/spec/tomodel_spec.rb +18 -18
- data/templates/excel/template.xlsx +0 -0
- data/templates/sqlserver/Gemfile +6 -6
- data/templates/sqlserver/Rakefile.rb +7 -7
- data/templates/sqlserver/convert.rb +2 -2
- data/templates/sqlserver/spec/spec_helper.rb +20 -20
- data/templates/sqlserver/spec/tomodel_spec.rb +9 -9
- metadata +47 -2
data/spec/deal_spec.rb
CHANGED
@@ -2,17 +2,27 @@ require "spec_helper"
|
|
2
2
|
require 'fruit_to_lime'
|
3
3
|
|
4
4
|
describe "Deal" do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
let(:deal){
|
6
|
+
FruitToLime::Deal.new
|
7
|
+
}
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
it "can attach a current status" do
|
10
|
+
deal.with_status do |status|
|
11
|
+
status.label = 'xyz'
|
12
|
+
status.id = '123'
|
13
|
+
status.date = DateTime.now
|
14
|
+
status.note = 'ho ho'
|
15
|
+
end
|
16
|
+
end
|
17
17
|
|
18
|
-
|
18
|
+
it "will auto convert org to org.ref during assignment" do
|
19
|
+
# given
|
20
|
+
org = FruitToLime::Organization.new({:integration_id => "123", :name => "Lundalogik"})
|
21
|
+
|
22
|
+
# when
|
23
|
+
deal.customer = org
|
24
|
+
|
25
|
+
# then
|
26
|
+
deal.customer.is_a?(FruitToLime::OrganizationReference).should eq true
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe FruitToLime::EmailHelper do
|
5
|
+
it "should validate a common email address" do
|
6
|
+
# given
|
7
|
+
import_email = "apl@lundalogik.se"
|
8
|
+
|
9
|
+
# when, then
|
10
|
+
FruitToLime::EmailHelper.is_valid?(import_email).should eq true
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should validate an address with firstname.lastname" do
|
14
|
+
FruitToLime::EmailHelper.is_valid?("firstname.lastname@example.com").should eq true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should validate an address with lots of subdomains" do
|
18
|
+
FruitToLime::EmailHelper.is_valid?("firstname.lastname@sub1.sub2.example.com").should eq true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should validate an address with some special chars" do
|
22
|
+
FruitToLime::EmailHelper.is_valid?("firstname-lastname+=@sub1.sub2.example.com").should eq true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should validate an address with no top level domain" do
|
26
|
+
FruitToLime::EmailHelper.is_valid?("firstname@example").should eq true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not validate an invalid address" do
|
30
|
+
FruitToLime::EmailHelper.is_valid?("hubbabubba").should eq false
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe FruitToLime::PhoneHelper do
|
5
|
+
before(:each) do
|
6
|
+
FruitToLime::PhoneHelper.set_country_code(:se)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should parse phonenumbers" do
|
10
|
+
# given, when
|
11
|
+
nice_number = FruitToLime::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 = FruitToLime::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 = FruitToLime::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 = FruitToLime::PhoneHelper.parse_numbers(source1, ['/', ',', "\\\\"])
|
49
|
+
home2, mobile2 = FruitToLime::PhoneHelper.parse_numbers(source2, ['/', ',', "\\\\"])
|
50
|
+
home3, mobile3, direct3 = FruitToLime::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 = FruitToLime::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 = FruitToLime::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
|
+
FruitToLime::PhoneHelper.set_country_code(:no)
|
92
|
+
number = FruitToLime::PhoneHelper.parse_numbers(source)
|
93
|
+
|
94
|
+
# then
|
95
|
+
number.should eq "+4722130030"
|
96
|
+
end
|
97
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fruit_to_lime'
|
3
|
-
require 'roo'
|
4
|
-
describe FruitToLime::RooHelper do
|
5
|
-
it "should handle sv chars" do
|
6
|
-
samplefile = File.join(File.dirname(__FILE__), '..', 'sample_data', 'excel.xlsx')
|
7
|
-
rows = FruitToLime::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
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
require 'roo'
|
4
|
+
describe FruitToLime::RooHelper do
|
5
|
+
it "should handle sv chars" do
|
6
|
+
samplefile = File.join(File.dirname(__FILE__), '..', 'sample_data', 'excel.xlsx')
|
7
|
+
rows = FruitToLime::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
|
data/spec/note_spec.rb
ADDED
@@ -0,0 +1,55 @@
|
|
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
|
+
end
|
@@ -0,0 +1,57 @@
|
|
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
|
+
end
|
21
|
+
|
22
|
+
describe "OrganizationReference" do
|
23
|
+
it "can be created from an organization" do
|
24
|
+
# given
|
25
|
+
org = FruitToLime::Organization.new
|
26
|
+
org.name = "Lundalogik"
|
27
|
+
org.integration_id = "123"
|
28
|
+
|
29
|
+
# when
|
30
|
+
ref = FruitToLime::OrganizationReference.from_organization(org)
|
31
|
+
|
32
|
+
# then
|
33
|
+
ref.is_a?(FruitToLime::OrganizationReference).should eq true
|
34
|
+
ref.heading.should eq "Lundalogik"
|
35
|
+
ref.integration_id.should eq "123"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can be created from an organization_reference" do
|
39
|
+
# given
|
40
|
+
orgref = FruitToLime::OrganizationReference.new
|
41
|
+
orgref.heading = "Lundalogik"
|
42
|
+
|
43
|
+
# when
|
44
|
+
ref = FruitToLime::OrganizationReference.from_organization(orgref)
|
45
|
+
|
46
|
+
# then
|
47
|
+
ref.is_a?(FruitToLime::OrganizationReference).should eq true
|
48
|
+
end
|
49
|
+
|
50
|
+
it "is nil when created from nil" do
|
51
|
+
# given, when
|
52
|
+
ref = FruitToLime::OrganizationReference.from_organization(nil)
|
53
|
+
|
54
|
+
# then
|
55
|
+
ref.should eq nil
|
56
|
+
end
|
57
|
+
end
|
data/spec/person_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe "Person" do
|
|
25
25
|
value = person.custom_values[0]
|
26
26
|
field = value.field
|
27
27
|
|
28
|
-
person.custom_values.length.should eq 1
|
28
|
+
person.custom_values.length.should eq 1
|
29
29
|
field.integration_id.should eq 'the key'
|
30
30
|
value.value.should eq 'the value 2'
|
31
31
|
end
|
@@ -39,7 +39,7 @@ describe "Person" do
|
|
39
39
|
value = person.custom_values[0]
|
40
40
|
field = value.field
|
41
41
|
|
42
|
-
person.custom_values.length.should eq 1
|
42
|
+
person.custom_values.length.should eq 1
|
43
43
|
field.id.should eq 'the id'
|
44
44
|
value.value.should eq 'the value 2'
|
45
45
|
end
|
@@ -51,16 +51,15 @@ describe "Person" do
|
|
51
51
|
value = person.custom_values[0]
|
52
52
|
field = value.field
|
53
53
|
|
54
|
-
person.custom_values.length.should eq 1
|
54
|
+
person.custom_values.length.should eq 1
|
55
55
|
field.integration_id.should eq 'the id'
|
56
56
|
value.value.should eq 'the value 2'
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
59
|
it "will only set tag once" do
|
61
60
|
person.set_tag('tag1')
|
62
61
|
person.set_tag('tag1')
|
63
|
-
person.tags.length.should eq 1
|
62
|
+
person.tags.length.should eq 1
|
64
63
|
tag = person.tags[0]
|
65
64
|
tag.value.should eq 'tag1'
|
66
65
|
end
|
@@ -93,13 +92,23 @@ describe "Person" do
|
|
93
92
|
error.should start_with("A firstname or lastname is required for person")
|
94
93
|
end
|
95
94
|
|
95
|
+
it "should auto convert org to org.ref during assignment" do
|
96
|
+
# given
|
97
|
+
org = FruitToLime::Organization.new({:integration_id => "123", :name => "Lundalogik"})
|
98
|
+
|
99
|
+
# when
|
100
|
+
person.organization = org
|
101
|
+
|
102
|
+
# then
|
103
|
+
person.organization.is_a?(FruitToLime::OrganizationReference).should eq true
|
104
|
+
end
|
105
|
+
|
96
106
|
describe "parse_name_to_firstname_lastname_se" do
|
97
107
|
it "can parse 'Kalle Nilsson' into firstname 'Kalle' and lastname 'Nilsson'" do
|
98
108
|
person.parse_name_to_firstname_lastname_se 'Kalle Nilsson'
|
99
109
|
|
100
110
|
person.first_name.should eq 'Kalle'
|
101
111
|
person.last_name.should eq 'Nilsson'
|
102
|
-
|
103
112
|
end
|
104
113
|
|
105
114
|
it "can parse 'Kalle Svensson Nilsson' into firstname 'Kalle' and lastname 'Svensson Nilsson'" do
|
data/spec/rootmodel_spec.rb
CHANGED
@@ -11,13 +11,12 @@ describe "RootModel" do
|
|
11
11
|
rootmodel.coworkers.length.should eq 1
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
14
|
it "can add a coworker from a hash" do
|
16
15
|
rootmodel.add_coworker({
|
17
|
-
:integration_id=>"123key",
|
18
|
-
:first_name=>"Kalle",
|
19
|
-
:last_name=>"Anka",
|
20
|
-
:email=>"kalle.anka@vonanka.com"
|
16
|
+
:integration_id => "123key",
|
17
|
+
:first_name => "Kalle",
|
18
|
+
:last_name => "Anka",
|
19
|
+
:email => "kalle.anka@vonanka.com"
|
21
20
|
})
|
22
21
|
rootmodel.find_coworker_by_integration_id("123key").first_name.should eq "Kalle"
|
23
22
|
rootmodel.coworkers.length.should eq 2
|
@@ -54,6 +53,134 @@ describe "RootModel" do
|
|
54
53
|
rootmodel.coworkers.length.should eq 2
|
55
54
|
end
|
56
55
|
|
56
|
+
it "can add an organization from hash" do
|
57
|
+
rootmodel.add_organization({
|
58
|
+
:integration_id => "123key",
|
59
|
+
:name => "Beagle Boys"
|
60
|
+
})
|
61
|
+
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
62
|
+
rootmodel.organizations.length.should eq 1
|
63
|
+
end
|
64
|
+
|
65
|
+
it "can add an organization from a new organization" do
|
66
|
+
# given
|
67
|
+
organization = FruitToLime::Organization.new
|
68
|
+
organization.integration_id = "123key"
|
69
|
+
organization.name = "Beagle Boys"
|
70
|
+
|
71
|
+
# when
|
72
|
+
rootmodel.add_organization(organization)
|
73
|
+
|
74
|
+
# then
|
75
|
+
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
76
|
+
rootmodel.organizations.length.should eq 1
|
77
|
+
end
|
78
|
+
|
79
|
+
it "will not add a new organizations when the organizations is already added (same integration id)" do
|
80
|
+
# given
|
81
|
+
rootmodel.add_organization({
|
82
|
+
:integration_id => "123key",
|
83
|
+
:name => "Beagle Boys"
|
84
|
+
})
|
85
|
+
rootmodel.organizations.length.should eq 1
|
86
|
+
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
87
|
+
|
88
|
+
# when, then
|
89
|
+
expect {
|
90
|
+
rootmodel.add_organization({
|
91
|
+
:integration_id => "123key",
|
92
|
+
:name => "Beagle Boys 2"
|
93
|
+
})
|
94
|
+
}.to raise_error(FruitToLime::AlreadyAddedError)
|
95
|
+
rootmodel.find_organization_by_integration_id("123key").name.should eq "Beagle Boys"
|
96
|
+
rootmodel.organizations.length.should eq 1
|
97
|
+
end
|
98
|
+
|
99
|
+
it "can add a deal from hash" do
|
100
|
+
rootmodel.add_deal({
|
101
|
+
:integration_id => "123key",
|
102
|
+
:name => "Big deal"
|
103
|
+
})
|
104
|
+
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
105
|
+
rootmodel.deals.length.should eq 1
|
106
|
+
end
|
107
|
+
|
108
|
+
it "can add a deal from a new deal" do
|
109
|
+
# given
|
110
|
+
deal = FruitToLime::Deal.new
|
111
|
+
deal.integration_id = "123key"
|
112
|
+
deal.name = "Big deal"
|
113
|
+
|
114
|
+
# when
|
115
|
+
rootmodel.add_deal(deal)
|
116
|
+
|
117
|
+
# then
|
118
|
+
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
119
|
+
rootmodel.deals.length.should eq 1
|
120
|
+
end
|
121
|
+
|
122
|
+
it "will not add a new deal when the deal is already added (same integration id)" do
|
123
|
+
# given
|
124
|
+
rootmodel.add_deal({
|
125
|
+
:integration_id => "123key",
|
126
|
+
:name => "Big deal"
|
127
|
+
})
|
128
|
+
rootmodel.deals.length.should eq 1
|
129
|
+
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
130
|
+
|
131
|
+
# when, then
|
132
|
+
expect {
|
133
|
+
rootmodel.add_deal({
|
134
|
+
:integration_id => "123key",
|
135
|
+
:name => "Bigger deal"
|
136
|
+
})
|
137
|
+
}.to raise_error(FruitToLime::AlreadyAddedError)
|
138
|
+
rootmodel.find_deal_by_integration_id("123key").name.should eq "Big deal"
|
139
|
+
rootmodel.deals.length.should eq 1
|
140
|
+
end
|
141
|
+
|
142
|
+
it "can add a note from hash" do
|
143
|
+
rootmodel.add_note({
|
144
|
+
:integration_id => "123key",
|
145
|
+
:text => "This is a note"
|
146
|
+
})
|
147
|
+
rootmodel.find_note_by_integration_id("123key").text.should eq "This is a note"
|
148
|
+
rootmodel.notes.length.should eq 1
|
149
|
+
end
|
150
|
+
|
151
|
+
it "can add a note from a new note" do
|
152
|
+
# given
|
153
|
+
note = FruitToLime::Note.new
|
154
|
+
note.integration_id = "123key"
|
155
|
+
note.text = "This is a note"
|
156
|
+
|
157
|
+
# when
|
158
|
+
rootmodel.add_note(note)
|
159
|
+
|
160
|
+
# then
|
161
|
+
rootmodel.find_note_by_integration_id("123key").text.should eq "This is a note"
|
162
|
+
rootmodel.notes.length.should eq 1
|
163
|
+
end
|
164
|
+
|
165
|
+
it "will not add a new organizations when the organizations is already added (same integration id)" do
|
166
|
+
# given
|
167
|
+
rootmodel.add_note({
|
168
|
+
:integration_id => "123key",
|
169
|
+
:text => "This is a note"
|
170
|
+
})
|
171
|
+
rootmodel.notes.length.should eq 1
|
172
|
+
|
173
|
+
# when, then
|
174
|
+
expect {
|
175
|
+
rootmodel.add_note({
|
176
|
+
:integration_id => "123key",
|
177
|
+
:text => "This is another note"
|
178
|
+
})
|
179
|
+
}.to raise_error(FruitToLime::AlreadyAddedError)
|
180
|
+
rootmodel.notes.length.should eq 1
|
181
|
+
rootmodel.find_note_by_integration_id("123key").text.should eq "This is a note"
|
182
|
+
end
|
183
|
+
|
57
184
|
it "will ignore empty integration ids during sanity check" do
|
58
185
|
org1 = FruitToLime::Organization.new
|
59
186
|
org1.name = "company 1"
|
@@ -65,7 +192,7 @@ describe "RootModel" do
|
|
65
192
|
|
66
193
|
rootmodel.sanity_check.should eq ""
|
67
194
|
end
|
68
|
-
|
195
|
+
|
69
196
|
it "will report when the same integration id is used during sanity check" do
|
70
197
|
org1 = FruitToLime::Organization.new
|
71
198
|
org1.integration_id = "1"
|
@@ -99,6 +226,5 @@ describe "RootModel" do
|
|
99
226
|
rootmodel.organizations.push org2
|
100
227
|
|
101
228
|
rootmodel.sanity_check.should eq "Duplicate person integration_id: 1."
|
102
|
-
|
103
229
|
end
|
104
230
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
-
#require File.expand_path("../../config/environment", __FILE__)
|
3
|
-
require 'rspec/autorun'
|
4
|
-
|
5
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
6
|
-
# in spec/support/ and its subdirectories.
|
7
|
-
Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
# ## Mock Framework
|
11
|
-
#
|
12
|
-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
13
|
-
#
|
14
|
-
# config.mock_with :mocha
|
15
|
-
# config.mock_with :flexmock
|
16
|
-
# config.mock_with :rr
|
17
|
-
|
18
|
-
# Run specs in random order to surface order dependencies. If you find an
|
19
|
-
# order dependency and want to debug it, you can fix the order by providing
|
20
|
-
# the seed, which is printed after each run.
|
21
|
-
# --seed 1234
|
22
|
-
config.order = "random"
|
23
|
-
end
|
24
|
-
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
#require File.expand_path("../../config/environment", __FILE__)
|
3
|
+
require 'rspec/autorun'
|
4
|
+
|
5
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
6
|
+
# in spec/support/ and its subdirectories.
|
7
|
+
Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
# ## Mock Framework
|
11
|
+
#
|
12
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
13
|
+
#
|
14
|
+
# config.mock_with :mocha
|
15
|
+
# config.mock_with :flexmock
|
16
|
+
# config.mock_with :rr
|
17
|
+
|
18
|
+
# Run specs in random order to surface order dependencies. If you find an
|
19
|
+
# order dependency and want to debug it, you can fix the order by providing
|
20
|
+
# the seed, which is printed after each run.
|
21
|
+
# --seed 1234
|
22
|
+
config.order = "random"
|
23
|
+
end
|
24
|
+
|
data/templates/csv/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
source 'http://rubygems.org'
|
2
|
-
|
3
|
-
gem 'thor'
|
4
|
-
gem 'fruit_to_lime'
|
5
|
-
gem 'rspec'
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'thor'
|
4
|
+
gem 'fruit_to_lime'
|
5
|
+
gem 'rspec'
|
data/templates/csv/Rakefile.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
6
|
-
task :default => :spec
|
7
|
-
task :test => :spec
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
task :test => :spec
|
data/templates/csv/convert.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require "./lib/tomodel"
|
2
|
-
|
1
|
+
require "./lib/tomodel"
|
2
|
+
|
3
3
|
Cli.start(ARGV)
|
@@ -1,24 +1,24 @@
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
-
#require File.expand_path("../../config/environment", __FILE__)
|
3
|
-
#require 'rspec/rails'
|
4
|
-
require 'rspec/autorun'
|
5
|
-
|
6
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
7
|
-
# in spec/support/ and its subdirectories.
|
8
|
-
#Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
|
9
|
-
|
10
|
-
RSpec.configure do |config|
|
11
|
-
# ## Mock Framework
|
12
|
-
#
|
13
|
-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
14
|
-
#
|
15
|
-
# config.mock_with :mocha
|
16
|
-
# config.mock_with :flexmock
|
17
|
-
# config.mock_with :rr
|
18
|
-
|
19
|
-
# Run specs in random order to surface order dependencies. If you find an
|
20
|
-
# order dependency and want to debug it, you can fix the order by providing
|
21
|
-
# the seed, which is printed after each run.
|
22
|
-
# --seed 1234
|
23
|
-
config.order = "random"
|
24
|
-
end
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
#require File.expand_path("../../config/environment", __FILE__)
|
3
|
+
#require 'rspec/rails'
|
4
|
+
require 'rspec/autorun'
|
5
|
+
|
6
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
7
|
+
# in spec/support/ and its subdirectories.
|
8
|
+
#Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
# ## Mock Framework
|
12
|
+
#
|
13
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
14
|
+
#
|
15
|
+
# config.mock_with :mocha
|
16
|
+
# config.mock_with :flexmock
|
17
|
+
# config.mock_with :rr
|
18
|
+
|
19
|
+
# Run specs in random order to surface order dependencies. If you find an
|
20
|
+
# order dependency and want to debug it, you can fix the order by providing
|
21
|
+
# the seed, which is printed after each run.
|
22
|
+
# --seed 1234
|
23
|
+
config.order = "random"
|
24
|
+
end
|
data/templates/excel/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source 'http://rubygems.org'
|
2
|
-
|
3
|
-
gem 'rspec'
|
4
|
-
gem 'roo'
|
5
|
-
gem 'thor'
|
6
|
-
gem 'fruit_to_lime'
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rspec'
|
4
|
+
gem 'roo'
|
5
|
+
gem 'thor'
|
6
|
+
gem 'fruit_to_lime'
|