go_import 3.0.7 → 3.0.8
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/go_import/model/deal.rb +28 -7
- data/lib/go_import/model/file.rb +21 -9
- data/lib/go_import/model/link.rb +21 -9
- data/lib/go_import/model/note.rb +24 -8
- data/lib/go_import/model/organization.rb +6 -2
- data/lib/go_import/serialize_helper.rb +12 -3
- data/sources/VISMA/.go_import/runner.rb +3 -1
- data/sources/csv/.go_import/runner.rb +3 -1
- data/sources/easy/.go_import/runner.rb +1 -0
- data/sources/excel/.go_import/runner.rb +3 -1
- data/sources/excel/converter.rb +0 -1
- data/spec/deal_spec.rb +32 -7
- data/spec/file_spec.rb +9 -8
- data/spec/link_spec.rb +9 -6
- data/spec/note_spec.rb +17 -13
- data/spec/organization_spec.rb +3 -2
- metadata +2 -2
data/lib/go_import/model/deal.rb
CHANGED
@@ -56,9 +56,9 @@ module GoImport
|
|
56
56
|
}
|
57
57
|
} +
|
58
58
|
[
|
59
|
-
{ :id => :
|
60
|
-
{ :id => :
|
61
|
-
{ :id => :
|
59
|
+
{ :id => :customer_reference, :type => :organization_reference, :element_name => :customer },
|
60
|
+
{ :id => :responsible_coworker_reference, :type => :coworker_reference, :element_name => :responsible_coworker },
|
61
|
+
{ :id => :customer_contact_reference, :type => :person_reference, :element_name => :customer_contact},
|
62
62
|
{ :id => :custom_values, :type => :custom_values },
|
63
63
|
{ :id => :tags, :type => :tags },
|
64
64
|
{ :id => :status, :type => :deal_status }
|
@@ -131,20 +131,39 @@ module GoImport
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def customer=(customer)
|
134
|
-
@
|
134
|
+
@customer_reference = OrganizationReference.from_organization(customer)
|
135
|
+
|
136
|
+
if customer.is_a?(Organization)
|
137
|
+
@customer = customer
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Gets the customer to which this deal belongs
|
142
|
+
def customer()
|
143
|
+
return @customer
|
135
144
|
end
|
136
145
|
|
137
146
|
def responsible_coworker=(coworker)
|
138
|
-
@
|
147
|
+
@responsible_coworker_reference = CoworkerReference.from_coworker(coworker)
|
148
|
+
|
149
|
+
if coworker.is_a?(Coworker)
|
150
|
+
@responsible_coworker = coworker
|
151
|
+
end
|
139
152
|
end
|
140
153
|
|
141
154
|
def customer_contact=(person)
|
142
|
-
@
|
155
|
+
@customer_contact_reference = PersonReference.from_person(person)
|
156
|
+
|
157
|
+
if person.is_a?(Person)
|
158
|
+
@customer_contact = person
|
159
|
+
end
|
143
160
|
end
|
144
161
|
|
145
162
|
def value=(value)
|
146
163
|
if value.nil?
|
147
|
-
@value = 0
|
164
|
+
@value = "0"
|
165
|
+
elsif value.empty?
|
166
|
+
@value = "0"
|
148
167
|
else
|
149
168
|
# we have had some issues with LIME Easy imports where
|
150
169
|
# the value was in the format "357 000". We need to
|
@@ -155,6 +174,8 @@ module GoImport
|
|
155
174
|
@value = fixed_value
|
156
175
|
elsif is_float?(fixed_value)
|
157
176
|
@value = fixed_value
|
177
|
+
elsif fixed_value.length == 0
|
178
|
+
@value = "0"
|
158
179
|
else
|
159
180
|
raise InvalidValueError, value
|
160
181
|
end
|
data/lib/go_import/model/file.rb
CHANGED
@@ -41,9 +41,9 @@ module GoImport
|
|
41
41
|
}
|
42
42
|
} +
|
43
43
|
[
|
44
|
-
{ :id => :
|
45
|
-
{ :id => :
|
46
|
-
{ :id => :
|
44
|
+
{ :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by },
|
45
|
+
{ :id => :organization_reference, :type => :organization_reference, :element_name => :organization },
|
46
|
+
{ :id => :deal_reference, :type => :deal_reference, :element_name => :deal }
|
47
47
|
]
|
48
48
|
end
|
49
49
|
|
@@ -79,15 +79,27 @@ module GoImport
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def organization=(org)
|
82
|
-
@
|
82
|
+
@organization_reference = OrganizationReference.from_organization(org)
|
83
|
+
|
84
|
+
if org.is_a?(Organization)
|
85
|
+
@organization = org
|
86
|
+
end
|
83
87
|
end
|
84
88
|
|
85
89
|
def deal=(deal)
|
86
|
-
@
|
90
|
+
@deal_reference = DealReference.from_deal(deal)
|
91
|
+
|
92
|
+
if deal.is_a?(Deal)
|
93
|
+
@deal = deal
|
94
|
+
end
|
87
95
|
end
|
88
96
|
|
89
97
|
def created_by=(coworker)
|
90
|
-
@
|
98
|
+
@created_by_reference = CoworkerReference.from_coworker(coworker)
|
99
|
+
|
100
|
+
if coworker.is_a?(Coworker)
|
101
|
+
@created_by = coworker
|
102
|
+
end
|
91
103
|
end
|
92
104
|
|
93
105
|
def validate
|
@@ -117,15 +129,15 @@ module GoImport
|
|
117
129
|
error = "#{error}A file must have a name.\n"
|
118
130
|
end
|
119
131
|
|
120
|
-
if @
|
132
|
+
if @created_by_reference.nil?
|
121
133
|
error = "#{error}Created_by is required for file.\n"
|
122
134
|
end
|
123
135
|
|
124
|
-
if @
|
136
|
+
if @organization_reference.nil? && @deal_reference.nil?
|
125
137
|
error = "#{error}A file must have either an organization or a deal.\n"
|
126
138
|
end
|
127
139
|
|
128
|
-
if !@
|
140
|
+
if !@organization_reference.nil? && !@deal_reference.nil?
|
129
141
|
error = "#{error}A file can't be attached to both an organization and a deal."
|
130
142
|
end
|
131
143
|
|
data/lib/go_import/model/link.rb
CHANGED
@@ -26,22 +26,34 @@ module GoImport
|
|
26
26
|
}
|
27
27
|
} +
|
28
28
|
[
|
29
|
-
{ :id => :
|
30
|
-
{ :id => :
|
31
|
-
{ :id => :
|
29
|
+
{ :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by },
|
30
|
+
{ :id => :organization_reference, :type => :organization_reference, :element_name => :organization },
|
31
|
+
{ :id => :deal_reference, :type => :deal_reference, :element_name => :deal }
|
32
32
|
]
|
33
33
|
end
|
34
34
|
|
35
35
|
def organization=(org)
|
36
|
-
@
|
36
|
+
@organization_reference = OrganizationReference.from_organization(org)
|
37
|
+
|
38
|
+
if org.is_a?(Organization)
|
39
|
+
@organization = org
|
40
|
+
end
|
37
41
|
end
|
38
42
|
|
39
43
|
def deal=(deal)
|
40
|
-
@
|
44
|
+
@deal_reference = DealReference.from_deal(deal)
|
45
|
+
|
46
|
+
if deal.is_a?(Deal)
|
47
|
+
@deal = deal
|
48
|
+
end
|
41
49
|
end
|
42
50
|
|
43
51
|
def created_by=(coworker)
|
44
|
-
@
|
52
|
+
@created_by_reference = CoworkerReference.from_coworker(coworker)
|
53
|
+
|
54
|
+
if coworker.is_a?(Coworker)
|
55
|
+
@created_by = coworker
|
56
|
+
end
|
45
57
|
end
|
46
58
|
|
47
59
|
def validate
|
@@ -51,15 +63,15 @@ module GoImport
|
|
51
63
|
error = "Url is required for link\n"
|
52
64
|
end
|
53
65
|
|
54
|
-
if @
|
66
|
+
if @created_by_reference.nil?
|
55
67
|
error = "#{error}Created_by is required for link\n"
|
56
68
|
end
|
57
69
|
|
58
|
-
if @
|
70
|
+
if @organization_reference.nil? && @deal_reference.nil?
|
59
71
|
error = "#{error}A link must have either an organization or a deal\n"
|
60
72
|
end
|
61
73
|
|
62
|
-
if !@
|
74
|
+
if !@organization_reference.nil? && !@deal_reference.nil?
|
63
75
|
error = "#{error}A link can't be attached to both an organization and a deal"
|
64
76
|
end
|
65
77
|
|
data/lib/go_import/model/note.rb
CHANGED
@@ -29,10 +29,10 @@ module GoImport
|
|
29
29
|
} +
|
30
30
|
[
|
31
31
|
{ :id => :date, :type => :date },
|
32
|
-
{ :id => :
|
33
|
-
{ :id => :
|
34
|
-
{ :id => :
|
35
|
-
{ :id => :
|
32
|
+
{ :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by },
|
33
|
+
{ :id => :organization_reference, :type => :organization_reference, :element_name => :organization },
|
34
|
+
{ :id => :deal_reference, :type => :deal_reference, :element_name => :deal },
|
35
|
+
{ :id => :person_reference, :type => :person_reference, :element_name => :person }
|
36
36
|
]
|
37
37
|
end
|
38
38
|
|
@@ -50,19 +50,35 @@ module GoImport
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def organization=(org)
|
53
|
-
@
|
53
|
+
@organization_reference = OrganizationReference.from_organization(org)
|
54
|
+
|
55
|
+
if org.is_a?(Organization)
|
56
|
+
@organization = org
|
57
|
+
end
|
54
58
|
end
|
55
59
|
|
56
60
|
def created_by=(coworker)
|
57
|
-
@
|
61
|
+
@created_by_reference = CoworkerReference.from_coworker(coworker)
|
62
|
+
|
63
|
+
if coworker.is_a?(Coworker)
|
64
|
+
@created_by = coworker
|
65
|
+
end
|
58
66
|
end
|
59
67
|
|
60
68
|
def person=(person)
|
61
|
-
@
|
69
|
+
@person_reference = PersonReference.from_person(person)
|
70
|
+
|
71
|
+
if person.is_a?(Person)
|
72
|
+
@person = person
|
73
|
+
end
|
62
74
|
end
|
63
75
|
|
64
76
|
def deal=(deal)
|
65
|
-
@
|
77
|
+
@deal_reference = DealReference.from_deal(deal)
|
78
|
+
|
79
|
+
if deal.is_a?(Deal)
|
80
|
+
@deal = deal
|
81
|
+
end
|
66
82
|
end
|
67
83
|
|
68
84
|
def classification=(classification)
|
@@ -130,7 +130,11 @@ module GoImport
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def responsible_coworker=(coworker)
|
133
|
-
@
|
133
|
+
@responsible_coworker_reference = CoworkerReference.from_coworker(coworker)
|
134
|
+
|
135
|
+
if coworker.is_a?(Coworker)
|
136
|
+
@responsible_coworker = coworker
|
137
|
+
end
|
134
138
|
end
|
135
139
|
|
136
140
|
# Sets the organization's relation to the specified value. The
|
@@ -177,7 +181,7 @@ module GoImport
|
|
177
181
|
{ :id => :employees, :type => :persons },
|
178
182
|
{ :id => :custom_values, :type => :custom_values },
|
179
183
|
{ :id => :tags, :type => :tags },
|
180
|
-
{ :id => :
|
184
|
+
{ :id => :responsible_coworker_reference, :type => :coworker_reference, :element_name => :responsible_coworker},
|
181
185
|
{ :id => :relation, :type => :string },
|
182
186
|
{ :id => :relation_last_modified, :type => :string }
|
183
187
|
]
|
@@ -15,9 +15,18 @@ module GoImport
|
|
15
15
|
def self.serialize_variables_rexml(elem, obj)
|
16
16
|
if (obj.respond_to?(:serialize_variables))
|
17
17
|
obj.serialize_variables.each do |serialize_variable|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
if serialize_variable[:element_name].nil?
|
19
|
+
# Remove the @ and replace a _ with the next
|
20
|
+
# letter capitalized. Ie @customer_reference
|
21
|
+
# should be CustomerReference
|
22
|
+
element_name = serialize_variable[:id].to_s.gsub(/^\@/,'').split('_').map do |m|
|
23
|
+
m.capitalize
|
24
|
+
end.join('')
|
25
|
+
else
|
26
|
+
element_name = serialize_variable[:element_name].to_s.split('_').map do |m|
|
27
|
+
m.capitalize
|
28
|
+
end.join('')
|
29
|
+
end
|
21
30
|
|
22
31
|
raw_var = obj.instance_variable_get("@#{serialize_variable[:id].to_s}")
|
23
32
|
if raw_var != nil
|
@@ -37,7 +37,9 @@ def convert_source
|
|
37
37
|
organization_rows.each do |row|
|
38
38
|
if not row.nil?
|
39
39
|
if not row["NAMN"] == ""
|
40
|
-
|
40
|
+
organization = converter.to_organization(row, rootmodel)
|
41
|
+
organization.set_tag "Imported"
|
42
|
+
rootmodel.add_organization(organization)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -35,7 +35,9 @@ def convert_source
|
|
35
35
|
# organizations
|
36
36
|
if defined?(ORGANIZATION_FILE) && !ORGANIZATION_FILE.nil? && !ORGANIZATION_FILE.empty?
|
37
37
|
process_rows ORGANIZATION_FILE do |row|
|
38
|
-
|
38
|
+
organization = converter.to_organization(row, rootmodel)
|
39
|
+
organization.set_tag "Imported"
|
40
|
+
rootmodel.add_organization(organization)
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -105,6 +105,7 @@ end
|
|
105
105
|
|
106
106
|
def init_organization(row, rootmodel)
|
107
107
|
organization = GoImport::Organization.new
|
108
|
+
organization.set_tag "Imported"
|
108
109
|
# integration_id is typically the company Id in Easy
|
109
110
|
# Must be set to be able to import the same file more
|
110
111
|
# than once without creating duplicates
|
@@ -94,7 +94,9 @@ def convert_source
|
|
94
94
|
if defined?(organization_rows) && !organization_rows.nil?
|
95
95
|
puts "Trying to convert organizations..."
|
96
96
|
organization_rows.each do |row|
|
97
|
-
|
97
|
+
organization = converter.to_organization(row, rootmodel)
|
98
|
+
organization.set_tag "Imported"
|
99
|
+
rootmodel.add_organization(organization)
|
98
100
|
end
|
99
101
|
end
|
100
102
|
|
data/sources/excel/converter.rb
CHANGED
@@ -90,7 +90,6 @@ class Converter
|
|
90
90
|
|
91
91
|
def to_organization(row, rootmodel)
|
92
92
|
organization = GoImport::Organization.new()
|
93
|
-
organization.set_tag "Importerad"
|
94
93
|
|
95
94
|
# Integrationid is typically the id in the system that we are
|
96
95
|
# getting the csv from. Must be set to be able to import the
|
data/spec/deal_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe "Deal" do
|
|
6
6
|
GoImport::Deal.new
|
7
7
|
}
|
8
8
|
|
9
|
-
it "will
|
9
|
+
it "will set customer ref when customer is assigned" do
|
10
10
|
# given
|
11
11
|
org = GoImport::Organization.new({:integration_id => "123", :name => "Lundalogik"})
|
12
12
|
|
@@ -14,10 +14,11 @@ describe "Deal" do
|
|
14
14
|
deal.customer = org
|
15
15
|
|
16
16
|
# then
|
17
|
-
deal.customer.is_a?(GoImport::
|
17
|
+
deal.customer.is_a?(GoImport::Organization).should eq true
|
18
|
+
deal.instance_variable_get(:@customer_reference).is_a?(GoImport::OrganizationReference).should eq true
|
18
19
|
end
|
19
20
|
|
20
|
-
it "will
|
21
|
+
it "will set coworker ref when coworker is assigned" do
|
21
22
|
# given
|
22
23
|
coworker = GoImport::Coworker.new({:integration_id => "456", :first_name => "Billy", :last_name => "Bob"})
|
23
24
|
|
@@ -25,10 +26,11 @@ describe "Deal" do
|
|
25
26
|
deal.responsible_coworker = coworker
|
26
27
|
|
27
28
|
# then
|
28
|
-
deal.responsible_coworker.is_a?(GoImport::
|
29
|
+
deal.responsible_coworker.is_a?(GoImport::Coworker).should eq true
|
30
|
+
deal.instance_variable_get(:@responsible_coworker_reference).is_a?(GoImport::CoworkerReference).should eq true
|
29
31
|
end
|
30
32
|
|
31
|
-
it "will
|
33
|
+
it "will set person ref when person is assigned" do
|
32
34
|
# given
|
33
35
|
person = GoImport::Person.new({:integration_id => "123"})
|
34
36
|
|
@@ -36,7 +38,8 @@ describe "Deal" do
|
|
36
38
|
deal.customer_contact = person
|
37
39
|
|
38
40
|
# then
|
39
|
-
deal.customer_contact.is_a?(GoImport::
|
41
|
+
deal.customer_contact.is_a?(GoImport::Person).should eq true
|
42
|
+
deal.instance_variable_get(:@customer_contact_reference).is_a?(GoImport::PersonReference).should eq true
|
40
43
|
end
|
41
44
|
|
42
45
|
it "will fail on validation if name is empty" do
|
@@ -92,6 +95,28 @@ describe "Deal" do
|
|
92
95
|
deal.value.should eq "357000"
|
93
96
|
end
|
94
97
|
|
98
|
+
it "should set empty string to 0 value" do
|
99
|
+
# given
|
100
|
+
deal.name = "The deal with no value"
|
101
|
+
|
102
|
+
# when
|
103
|
+
deal.value = ""
|
104
|
+
|
105
|
+
# then
|
106
|
+
deal.value.should eq "0"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should set value to 0 if assigned a string with spaces" do
|
110
|
+
# given
|
111
|
+
deal.name = "The deal with no value"
|
112
|
+
|
113
|
+
# when
|
114
|
+
deal.value = " "
|
115
|
+
|
116
|
+
# then
|
117
|
+
deal.value.should eq "0"
|
118
|
+
end
|
119
|
+
|
95
120
|
it "should raise invalidvalueerror if value is not a number" do
|
96
121
|
# given
|
97
122
|
deal.name = "The deal with an invalid value"
|
@@ -132,7 +157,7 @@ describe "Deal" do
|
|
132
157
|
deal.value = nil
|
133
158
|
|
134
159
|
# then
|
135
|
-
deal.value.should eq 0
|
160
|
+
deal.value.should eq "0"
|
136
161
|
end
|
137
162
|
|
138
163
|
it "should set status_reference from status_setting" do
|
data/spec/file_spec.rb
CHANGED
@@ -101,7 +101,7 @@ describe "File" do
|
|
101
101
|
file.name.should eq ''
|
102
102
|
end
|
103
103
|
|
104
|
-
it "will
|
104
|
+
it "will set organization ref when organization is assinged" do
|
105
105
|
# given
|
106
106
|
org = GoImport::Organization.new({:integration_id => "123", :name => "Beagle Boys!"})
|
107
107
|
|
@@ -109,10 +109,11 @@ describe "File" do
|
|
109
109
|
file.organization = org
|
110
110
|
|
111
111
|
# then
|
112
|
-
file.organization.is_a?(GoImport::
|
112
|
+
file.organization.is_a?(GoImport::Organization).should eq true
|
113
|
+
file.instance_variable_get(:@organization_reference).is_a?(GoImport::OrganizationReference).should eq true
|
113
114
|
end
|
114
115
|
|
115
|
-
it "will
|
116
|
+
it "will set deal ref when deal is assinged" do
|
116
117
|
# given
|
117
118
|
deal = GoImport::Deal.new({:integration_id => "123" })
|
118
119
|
deal.name = "The new deal"
|
@@ -121,10 +122,11 @@ describe "File" do
|
|
121
122
|
file.deal = deal
|
122
123
|
|
123
124
|
# then
|
124
|
-
file.deal.is_a?(GoImport::
|
125
|
+
file.deal.is_a?(GoImport::Deal).should eq true
|
126
|
+
file.instance_variable_get(:@deal_reference).is_a?(GoImport::DealReference).should eq true
|
125
127
|
end
|
126
128
|
|
127
|
-
it "will
|
129
|
+
it "will set coworker ref when coworker is assinged" do
|
128
130
|
# given
|
129
131
|
coworker = GoImport::Coworker.new({:integration_id => "123" })
|
130
132
|
coworker.parse_name_to_firstname_lastname_se "Billy Bob"
|
@@ -133,8 +135,7 @@ describe "File" do
|
|
133
135
|
file.created_by = coworker
|
134
136
|
|
135
137
|
# then
|
136
|
-
file.created_by.is_a?(GoImport::
|
138
|
+
file.created_by.is_a?(GoImport::Coworker).should eq true
|
139
|
+
file.instance_variable_get(:@created_by_reference).is_a?(GoImport::CoworkerReference).should eq true
|
137
140
|
end
|
138
|
-
|
139
|
-
|
140
141
|
end
|
data/spec/link_spec.rb
CHANGED
@@ -67,7 +67,7 @@ describe "Link" do
|
|
67
67
|
link.validate.length.should be > 0
|
68
68
|
end
|
69
69
|
|
70
|
-
it "will
|
70
|
+
it "will set organization ref when organization is assigned" do
|
71
71
|
# given
|
72
72
|
org = GoImport::Organization.new({:integration_id => "123", :name => "Beagle Boys!"})
|
73
73
|
|
@@ -75,10 +75,11 @@ describe "Link" do
|
|
75
75
|
link.organization = org
|
76
76
|
|
77
77
|
# then
|
78
|
-
link.organization.is_a?(GoImport::
|
78
|
+
link.organization.is_a?(GoImport::Organization).should eq true
|
79
|
+
link.instance_variable_get(:@organization_reference).is_a?(GoImport::OrganizationReference).should eq true
|
79
80
|
end
|
80
81
|
|
81
|
-
it "will
|
82
|
+
it "will set deal ref when deal is assigned" do
|
82
83
|
# given
|
83
84
|
deal = GoImport::Deal.new({:integration_id => "123" })
|
84
85
|
deal.name = "The new deal"
|
@@ -87,10 +88,11 @@ describe "Link" do
|
|
87
88
|
link.deal = deal
|
88
89
|
|
89
90
|
# then
|
90
|
-
link.deal.is_a?(GoImport::
|
91
|
+
link.deal.is_a?(GoImport::Deal).should eq true
|
92
|
+
link.instance_variable_get(:@deal_reference).is_a?(GoImport::DealReference).should eq true
|
91
93
|
end
|
92
94
|
|
93
|
-
it "will
|
95
|
+
it "will set coworker ref when coworker is assigned" do
|
94
96
|
# given
|
95
97
|
coworker = GoImport::Coworker.new({:integration_id => "123" })
|
96
98
|
coworker.parse_name_to_firstname_lastname_se "Billy Bob"
|
@@ -99,6 +101,7 @@ describe "Link" do
|
|
99
101
|
link.created_by = coworker
|
100
102
|
|
101
103
|
# then
|
102
|
-
link.created_by.is_a?(GoImport::
|
104
|
+
link.created_by.is_a?(GoImport::Coworker).should eq true
|
105
|
+
link.instance_variable_get(:@created_by_reference).is_a?(GoImport::CoworkerReference).should eq true
|
103
106
|
end
|
104
107
|
end
|
data/spec/note_spec.rb
CHANGED
@@ -13,8 +13,8 @@ describe "Note" do
|
|
13
13
|
it "is valid when it has text, created_by and organization" do
|
14
14
|
# given
|
15
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::
|
17
|
-
note.organization = GoImport::
|
16
|
+
note.created_by = GoImport::Coworker.new( { :integration_id => "123", :heading => "kalle anka" } )
|
17
|
+
note.organization = GoImport::Organization.new({ :integration_id => "456", :heading => "Lundalogik" })
|
18
18
|
|
19
19
|
# when, then
|
20
20
|
note.validate.should eq ""
|
@@ -23,7 +23,7 @@ describe "Note" do
|
|
23
23
|
it "is valid when it has text, created_by and person" do
|
24
24
|
# given
|
25
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::
|
26
|
+
note.created_by = GoImport::Coworker.new( { :integration_id => "123", :heading => "kalle anka" } )
|
27
27
|
note.person = GoImport::Person.new({ :integration_id => "456", :heading => "Billy Bob" })
|
28
28
|
|
29
29
|
# when, then
|
@@ -33,7 +33,7 @@ describe "Note" do
|
|
33
33
|
it "is valid when it has text, created_by and deal" do
|
34
34
|
# given
|
35
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::
|
36
|
+
note.created_by = GoImport::Coworker.new( { :integration_id => "123", :heading => "kalle anka" } )
|
37
37
|
note.deal = GoImport::Deal.new({ :integration_id => "456", :heading => "The new deal" })
|
38
38
|
|
39
39
|
# when, then
|
@@ -43,13 +43,13 @@ describe "Note" do
|
|
43
43
|
it "is invalid if no note has no attached objects" do
|
44
44
|
# given
|
45
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::
|
46
|
+
note.created_by = GoImport::Coworker.new( { :integration_id => "123", :heading => "kalle anka" } )
|
47
47
|
|
48
48
|
# when, then
|
49
49
|
note.validate.length.should be > 0
|
50
50
|
end
|
51
51
|
|
52
|
-
it "will
|
52
|
+
it "will set organization ref when organization is assinged" do
|
53
53
|
# given
|
54
54
|
org = GoImport::Organization.new({:integration_id => "123", :name => "Beagle Boys!"})
|
55
55
|
|
@@ -57,10 +57,11 @@ describe "Note" do
|
|
57
57
|
note.organization = org
|
58
58
|
|
59
59
|
# then
|
60
|
-
note.organization.is_a?(GoImport::
|
60
|
+
note.organization.is_a?(GoImport::Organization).should eq true
|
61
|
+
note.instance_variable_get(:@organization_reference).is_a?(GoImport::OrganizationReference).should eq true
|
61
62
|
end
|
62
63
|
|
63
|
-
it "will
|
64
|
+
it "will set person ref when person is assinged" do
|
64
65
|
# given
|
65
66
|
person = GoImport::Person.new({:integration_id => "123" })
|
66
67
|
person.parse_name_to_firstname_lastname_se "Billy Bob"
|
@@ -69,10 +70,11 @@ describe "Note" do
|
|
69
70
|
note.person = person
|
70
71
|
|
71
72
|
# then
|
72
|
-
note.person.is_a?(GoImport::
|
73
|
+
note.person.is_a?(GoImport::Person).should eq true
|
74
|
+
note.instance_variable_get(:@person_reference).is_a?(GoImport::PersonReference).should eq true
|
73
75
|
end
|
74
76
|
|
75
|
-
it "will
|
77
|
+
it "will set coworker ref when coworker is assinged" do
|
76
78
|
# given
|
77
79
|
coworker = GoImport::Coworker.new({:integration_id => "123" })
|
78
80
|
coworker.parse_name_to_firstname_lastname_se "Billy Bob"
|
@@ -81,10 +83,11 @@ describe "Note" do
|
|
81
83
|
note.created_by = coworker
|
82
84
|
|
83
85
|
# then
|
84
|
-
note.created_by.is_a?(GoImport::
|
86
|
+
note.created_by.is_a?(GoImport::Coworker).should eq true
|
87
|
+
note.instance_variable_get(:@created_by_reference).is_a?(GoImport::CoworkerReference).should eq true
|
85
88
|
end
|
86
89
|
|
87
|
-
it "will
|
90
|
+
it "will set deal ref when deal is assinged" do
|
88
91
|
# given
|
89
92
|
deal = GoImport::Deal.new({:integration_id => "123" })
|
90
93
|
deal.name = "The new deal"
|
@@ -93,7 +96,8 @@ describe "Note" do
|
|
93
96
|
note.deal = deal
|
94
97
|
|
95
98
|
# then
|
96
|
-
note.deal.is_a?(GoImport::
|
99
|
+
note.deal.is_a?(GoImport::Deal).should eq true
|
100
|
+
note.instance_variable_get(:@deal_reference).is_a?(GoImport::DealReference).should eq true
|
97
101
|
end
|
98
102
|
|
99
103
|
it "should have Comment as default classification" do
|
data/spec/organization_spec.rb
CHANGED
@@ -33,7 +33,7 @@ describe "Organization" do
|
|
33
33
|
organization.validate.length.should be > 0
|
34
34
|
end
|
35
35
|
|
36
|
-
it "will
|
36
|
+
it "will set coworker ref when coworker is assigned" do
|
37
37
|
# given
|
38
38
|
coworker = GoImport::Coworker.new({:integration_id => "456", :first_name => "Billy", :last_name => "Bob"})
|
39
39
|
|
@@ -41,7 +41,8 @@ describe "Organization" do
|
|
41
41
|
organization.responsible_coworker = coworker
|
42
42
|
|
43
43
|
# then
|
44
|
-
organization.responsible_coworker.is_a?(GoImport::
|
44
|
+
organization.responsible_coworker.is_a?(GoImport::Coworker).should eq true
|
45
|
+
organization.instance_variable_get(:@responsible_coworker_reference).is_a?(GoImport::CoworkerReference).should eq true
|
45
46
|
end
|
46
47
|
|
47
48
|
it "will have a no relation as default" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-10-
|
15
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: iso_country_codes
|