fruit_to_lime 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fruit_to_lime/errors.rb +3 -0
- data/lib/fruit_to_lime/model/class_settings.rb +1 -1
- data/lib/fruit_to_lime/model/deal.rb +23 -1
- data/lib/fruit_to_lime/model/deal_class_settings.rb +73 -0
- data/lib/fruit_to_lime/model/deal_state.rb +15 -0
- data/lib/fruit_to_lime/model/deal_status.rb +13 -2
- data/lib/fruit_to_lime/model/deal_status_reference.rb +49 -0
- data/lib/fruit_to_lime/model/deal_status_setting.rb +50 -0
- data/lib/fruit_to_lime/model/settings.rb +3 -3
- data/spec/deal_class_settings_spec.rb +81 -0
- data/spec/deal_spec.rb +98 -11
- data/spec/deal_status_reference_spec.rb +17 -0
- data/spec/spec_helper.rb +19 -13
- data/templates/csv/lib/tomodel.rb +18 -4
- data/templates/easy/lib/tomodel.rb +12 -3
- metadata +10 -2
data/lib/fruit_to_lime/errors.rb
CHANGED
@@ -23,7 +23,7 @@ module FruitToLime
|
|
23
23
|
|
24
24
|
# Set custom field. If there is already an existing custom field, then it is overwritten.
|
25
25
|
def set_custom_field(obj)
|
26
|
-
@custom_fields = [] if @custom_fields
|
26
|
+
@custom_fields = [] if @custom_fields.nil?
|
27
27
|
|
28
28
|
if obj.is_a?(CustomField)
|
29
29
|
field = obj
|
@@ -91,6 +91,14 @@ module FruitToLime
|
|
91
91
|
error = "A name is required for deal.\n}"
|
92
92
|
end
|
93
93
|
|
94
|
+
if !@status.nil? && @status.status_reference.nil?
|
95
|
+
error = "#{error}\nStatus must have a status reference."
|
96
|
+
end
|
97
|
+
|
98
|
+
if !@status.nil? && !@status.status_reference.nil? && @status.status_reference.validate.length > 0
|
99
|
+
error = "#{error}\n#{@status.status_reference.validate}"
|
100
|
+
end
|
101
|
+
|
94
102
|
if error.length > 0
|
95
103
|
error = "#{error}\n#{serialize()}"
|
96
104
|
end
|
@@ -98,11 +106,25 @@ module FruitToLime
|
|
98
106
|
return error
|
99
107
|
end
|
100
108
|
|
109
|
+
|
101
110
|
def with_status
|
102
|
-
@status = DealStatus.new
|
111
|
+
@status = DealStatus.new if @status.nil?
|
103
112
|
yield @status
|
104
113
|
end
|
105
114
|
|
115
|
+
# Sets the deal's status to the specifed status. The specifed
|
116
|
+
# status could be either a DealStatusSetting, a string or an
|
117
|
+
# integer. Use DealStatusSetting if you want to create new
|
118
|
+
# statuses during import (you will probably add the
|
119
|
+
# DealStatusSettings to the settings model). If the statuses
|
120
|
+
# already exists in the application use the status label
|
121
|
+
# (String) or id (Integer) here.
|
122
|
+
def status=(status)
|
123
|
+
@status = DealStatus.new if @status.nil?
|
124
|
+
|
125
|
+
@status.status_reference = DealStatusReference.from_deal_status(status)
|
126
|
+
end
|
127
|
+
|
106
128
|
def customer=(customer)
|
107
129
|
@customer = OrganizationReference.from_organization(customer)
|
108
130
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module FruitToLime
|
3
|
+
class DealClassSettings < ClassSettings
|
4
|
+
attr_reader :statuses
|
5
|
+
|
6
|
+
def initialize(opt = nil)
|
7
|
+
@statuses = []
|
8
|
+
if opt != nil
|
9
|
+
serialize_variables.each do |myattr|
|
10
|
+
val = opt[myattr[:id]]
|
11
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def serialize_variables
|
17
|
+
super() + [{:id => :statuses, :type => :statuses }]
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_status(obj)
|
21
|
+
@statuses = [] if @statuses.nil?
|
22
|
+
|
23
|
+
if obj.is_a?(DealStatusSetting)
|
24
|
+
status = obj
|
25
|
+
else
|
26
|
+
status = DealStatusSetting.new(obj)
|
27
|
+
end
|
28
|
+
|
29
|
+
if status.label.nil? || status.label.empty?
|
30
|
+
raise InvalidDealStatusError, "Deal status must have a label"
|
31
|
+
end
|
32
|
+
|
33
|
+
if status.assessment.nil?
|
34
|
+
status.assessment = DealState::NotAnEndState
|
35
|
+
end
|
36
|
+
|
37
|
+
index = @statuses.find_index do |deal_status|
|
38
|
+
deal_status.same_as?(status)
|
39
|
+
end
|
40
|
+
if index
|
41
|
+
@statuses.delete_at index
|
42
|
+
end
|
43
|
+
|
44
|
+
@statuses.push status
|
45
|
+
|
46
|
+
return status
|
47
|
+
end
|
48
|
+
|
49
|
+
def find_status_by_label(label)
|
50
|
+
return nil if @statuses.nil?
|
51
|
+
|
52
|
+
return @statuses.find do |status|
|
53
|
+
!status.label.nil? && status.label.casecmp(label) == 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def find_status_by_integration_id(integration_id)
|
58
|
+
return nil if @statuses.nil?
|
59
|
+
|
60
|
+
return @statuses.find do |status|
|
61
|
+
!status.integration_id.nil? && status.integration_id.casecmp(integration_id) == 0
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def find_status_by_id(id)
|
66
|
+
return nil if @statuses.nil?
|
67
|
+
|
68
|
+
return @statuses.find do |status|
|
69
|
+
!status.id.nil? && status.id.casecmp(integration_id) == 0
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module FruitToLime
|
2
|
+
module DealState
|
3
|
+
# This is the default, a deal with a status with this state is
|
4
|
+
# currently being worked on.
|
5
|
+
NotAnEndState = 0
|
6
|
+
|
7
|
+
# The deal has reached a positive end state, eg we have won
|
8
|
+
# the deal.
|
9
|
+
PositiveEndState = 1
|
10
|
+
|
11
|
+
# The deal has reached a negative end state, eg we have lost
|
12
|
+
# the deal.
|
13
|
+
NegativeEndState = -1
|
14
|
+
end
|
15
|
+
end
|
@@ -2,11 +2,22 @@ module FruitToLime
|
|
2
2
|
class DealStatus
|
3
3
|
include SerializeHelper
|
4
4
|
|
5
|
-
attr_accessor :id, :
|
5
|
+
attr_accessor :id, :date, :status_reference, :note
|
6
|
+
|
7
|
+
def initialize(opt = nil)
|
8
|
+
if opt != nil
|
9
|
+
serialize_variables.each do |myattr|
|
10
|
+
val = opt[myattr[:id]]
|
11
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
6
15
|
|
7
16
|
def serialize_variables
|
8
17
|
[ :id, :label, :note ].map{ |p| { :id => p, :type => :string } } +
|
9
|
-
|
18
|
+
[ :date ].map { |p| { :id => p, :type => :date } } +
|
19
|
+
[ :status_reference ].map { |p| { :id => p, :type => :deal_status_reference } }
|
10
20
|
end
|
21
|
+
|
11
22
|
end
|
12
23
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module FruitToLime
|
2
|
+
class DealStatusReference
|
3
|
+
include SerializeHelper
|
4
|
+
|
5
|
+
attr_accessor :id, :label, :integration_id
|
6
|
+
|
7
|
+
def initialize(opt = nil)
|
8
|
+
if opt != nil
|
9
|
+
serialize_variables.each do |myattr|
|
10
|
+
val = opt[myattr[:id]]
|
11
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def serialize_variables
|
17
|
+
[:id, :integration_id, :label].map {|p| {:id => p, :type => :string} }
|
18
|
+
end
|
19
|
+
|
20
|
+
def serialize_name
|
21
|
+
"StatusReference"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Converts the specifed status to a status reference.
|
25
|
+
def self.from_deal_status(deal_status)
|
26
|
+
if deal_status.nil?
|
27
|
+
return nil
|
28
|
+
elsif deal_status.is_a?(DealStatusSetting)
|
29
|
+
return deal_status.to_reference
|
30
|
+
elsif deal_status.is_a?(String)
|
31
|
+
return DealStatusReference.new({:label => deal_status, :integration_id => deal_status})
|
32
|
+
elsif deal_status.is_a?(Integer)
|
33
|
+
return DealStatusReference.new({:id => deal_status.to_s })
|
34
|
+
end
|
35
|
+
|
36
|
+
raise InvalidDealStatusError
|
37
|
+
end
|
38
|
+
|
39
|
+
def validate
|
40
|
+
error = ""
|
41
|
+
|
42
|
+
if (@id.nil? || @id.empty?) && (@label.nil? || @label.empty?) && (@integration_id.nil? || @integration_id.empty?)
|
43
|
+
error = "id, label and integration_id can't all be nil or empty"
|
44
|
+
end
|
45
|
+
|
46
|
+
return error
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module FruitToLime
|
3
|
+
class DealStatusSetting
|
4
|
+
include SerializeHelper
|
5
|
+
|
6
|
+
attr_accessor :id, :integration_id, :label, :assessment
|
7
|
+
|
8
|
+
def initialize(opt = nil)
|
9
|
+
if opt != nil
|
10
|
+
serialize_variables.each do |myattr|
|
11
|
+
val = opt[myattr[:id]]
|
12
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def serialize_variables
|
18
|
+
[ :id, :integration_id, :label, :assessment ].map{ |p| { :id => p, :type => :string } }
|
19
|
+
end
|
20
|
+
|
21
|
+
def serialize_name
|
22
|
+
"DealStatus"
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_reference()
|
26
|
+
reference = DealStatusReference.new
|
27
|
+
reference.id = @id
|
28
|
+
reference.label = @label
|
29
|
+
reference.integration_id = @integration_id
|
30
|
+
|
31
|
+
return reference
|
32
|
+
end
|
33
|
+
|
34
|
+
def same_as?(other)
|
35
|
+
if @integration_id != nil && @integration_id == other.integration_id
|
36
|
+
return true
|
37
|
+
end
|
38
|
+
|
39
|
+
if @id != nil && @id == other.id
|
40
|
+
return true
|
41
|
+
end
|
42
|
+
|
43
|
+
if @label != nil && @label == other.label
|
44
|
+
return true
|
45
|
+
end
|
46
|
+
|
47
|
+
return false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -3,7 +3,7 @@ module FruitToLime
|
|
3
3
|
class Settings
|
4
4
|
include SerializeHelper
|
5
5
|
attr_reader :organization, :person, :deal
|
6
|
-
|
6
|
+
|
7
7
|
# @example Add custom fields available for organization
|
8
8
|
# rootmodel.settings.with_organization do |organization_settings|
|
9
9
|
# organization_settings.set_custom_field({:integration_id=>"link_to_bi_system", :title=>"Link to BI system"})
|
@@ -37,7 +37,7 @@ module FruitToLime
|
|
37
37
|
# @see CustomField
|
38
38
|
# @see RootModel
|
39
39
|
def with_deal
|
40
|
-
@deal =
|
40
|
+
@deal = DealClassSettings.new if @deal ==nil
|
41
41
|
yield @deal
|
42
42
|
end
|
43
43
|
|
@@ -58,4 +58,4 @@ module FruitToLime
|
|
58
58
|
"Settings"
|
59
59
|
end
|
60
60
|
end
|
61
|
-
end
|
61
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fruit_to_lime"
|
3
|
+
|
4
|
+
describe "DealClassSettings" do
|
5
|
+
let(:deal_class_settings) {
|
6
|
+
FruitToLime::DealClassSettings.new
|
7
|
+
}
|
8
|
+
|
9
|
+
it "should not allow new deal status without a label" do
|
10
|
+
# given, when
|
11
|
+
begin
|
12
|
+
deal_class_settings.add_status({:integration_id => "123"})
|
13
|
+
rescue FruitToLime::InvalidDealStatusError
|
14
|
+
end
|
15
|
+
|
16
|
+
# then
|
17
|
+
deal_class_settings.statuses.length.should eq 0
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should set assessment to NotAnEndState as default" do
|
21
|
+
# given, when
|
22
|
+
status = deal_class_settings.add_status({:label => "1. Kvalificering"})
|
23
|
+
|
24
|
+
# then
|
25
|
+
status.assessment.should eq FruitToLime::DealState::NotAnEndState
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should set assessment if specified" do
|
29
|
+
# given, when
|
30
|
+
status = deal_class_settings.add_status({
|
31
|
+
:label => "4. Won deal",
|
32
|
+
:assessment => FruitToLime::DealState::PositiveEndState
|
33
|
+
})
|
34
|
+
|
35
|
+
# then
|
36
|
+
status.assessment.should eq FruitToLime::DealState::PositiveEndState
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should find a status by case insensitive label" do
|
40
|
+
# given
|
41
|
+
deal_class_settings.add_status({:label => "1. Kvalificering"})
|
42
|
+
deal_class_settings.add_status({:label => "2. Skickat offert"})
|
43
|
+
|
44
|
+
# when
|
45
|
+
status = deal_class_settings.find_status_by_label("2. skICkat OfFert")
|
46
|
+
|
47
|
+
# then
|
48
|
+
status.label.should eq "2. Skickat offert"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should find a status by integration id" do
|
52
|
+
# given
|
53
|
+
deal_class_settings.add_status({:label => "1. Kvalificering", :integration_id => "qualify"})
|
54
|
+
deal_class_settings.add_status({:label => "2. Skickat offert", :integration_id => "tender sent"})
|
55
|
+
|
56
|
+
# when
|
57
|
+
status = deal_class_settings.find_status_by_integration_id("tender SeNT")
|
58
|
+
|
59
|
+
# then
|
60
|
+
status.label.should eq "2. Skickat offert"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should find nil by label if no statuses are defined" do
|
64
|
+
# given, when
|
65
|
+
status = deal_class_settings.find_status_by_label("3. Won")
|
66
|
+
|
67
|
+
# then
|
68
|
+
status.should eq nil
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should find nil by integration id if no statuses are defined" do
|
72
|
+
# given, when
|
73
|
+
status = deal_class_settings.find_status_by_integration_id("3. Won")
|
74
|
+
|
75
|
+
# then
|
76
|
+
status.should eq nil
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
data/spec/deal_spec.rb
CHANGED
@@ -6,15 +6,6 @@ describe "Deal" do
|
|
6
6
|
FruitToLime::Deal.new
|
7
7
|
}
|
8
8
|
|
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
|
-
|
18
9
|
it "will auto convert org to org.ref during assignment" do
|
19
10
|
# given
|
20
11
|
org = FruitToLime::Organization.new({:integration_id => "123", :name => "Lundalogik"})
|
@@ -50,10 +41,44 @@ describe "Deal" do
|
|
50
41
|
|
51
42
|
it "will fail on validation if name is empty" do
|
52
43
|
# given
|
53
|
-
deal.name = "
|
44
|
+
deal.name = ""
|
45
|
+
deal.status = "required status"
|
46
|
+
|
47
|
+
# when, then
|
48
|
+
deal.validate.length.should be > 0
|
49
|
+
end
|
50
|
+
|
51
|
+
it "will fail on validation if name is nil" do
|
52
|
+
# given
|
53
|
+
deal.name = nil
|
54
|
+
deal.status = "required status"
|
54
55
|
|
55
56
|
# when, then
|
56
|
-
deal.validate.should
|
57
|
+
deal.validate.length.should be > 0
|
58
|
+
end
|
59
|
+
|
60
|
+
it "will fail on validation if status dont have a status reference" do
|
61
|
+
# given
|
62
|
+
deal.name = "Deal must have a name"
|
63
|
+
# this will create a status with a status_reference
|
64
|
+
deal.status = "Driv"
|
65
|
+
|
66
|
+
# when
|
67
|
+
# and this will set the reference to nil (this will probably
|
68
|
+
# never happen in the real world).
|
69
|
+
deal.status.status_reference = nil
|
70
|
+
|
71
|
+
# then
|
72
|
+
deal.validate.length.should be > 0
|
73
|
+
end
|
74
|
+
|
75
|
+
it "will fail on validation if status has an invalid status reference" do
|
76
|
+
# given
|
77
|
+
deal.name = "Deal must have a name"
|
78
|
+
deal.status = ""
|
79
|
+
|
80
|
+
# when, then
|
81
|
+
deal.validate.length.should be > 0
|
57
82
|
end
|
58
83
|
|
59
84
|
it "should convert value strings that looks like number to number" do
|
@@ -109,4 +134,66 @@ describe "Deal" do
|
|
109
134
|
# then
|
110
135
|
deal.value.should eq 0
|
111
136
|
end
|
137
|
+
|
138
|
+
it "should set status_reference from status_setting" do
|
139
|
+
# This case should be used when the status is defined in the rootmodel
|
140
|
+
|
141
|
+
# given
|
142
|
+
deal.name = "Deal with status from deal_status_setting"
|
143
|
+
deal_status_setting = FruitToLime::DealStatusSetting.new({:integration_id => "123", :label => "Driv"})
|
144
|
+
|
145
|
+
# when
|
146
|
+
deal.status = deal_status_setting
|
147
|
+
|
148
|
+
# then
|
149
|
+
deal.status.is_a?(FruitToLime::DealStatus).should eq true
|
150
|
+
deal.status.status_reference.is_a?(FruitToLime::DealStatusReference).should eq true
|
151
|
+
deal.status.status_reference.label.should eq "Driv"
|
152
|
+
deal.status.status_reference.integration_id.should eq "123"
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should set status_reference from label if status is a string" do
|
156
|
+
# This case should be used when the status is already defined
|
157
|
+
# in the appliation and is referenced by label
|
158
|
+
|
159
|
+
# given
|
160
|
+
deal.name = "Deal with status from label"
|
161
|
+
|
162
|
+
# when
|
163
|
+
deal.status = "Driv"
|
164
|
+
|
165
|
+
# then
|
166
|
+
deal.status.is_a?(FruitToLime::DealStatus).should eq true
|
167
|
+
deal.status.status_reference.is_a?(FruitToLime::DealStatusReference).should eq true
|
168
|
+
deal.status.status_reference.label.should eq "Driv"
|
169
|
+
deal.status.status_reference.id.nil?.should eq true
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should set status_reference from id if status is an integer" do
|
173
|
+
# This case should be used when the status is already defined
|
174
|
+
# in the application and is referenced by id
|
175
|
+
|
176
|
+
# given
|
177
|
+
deal.name = "Deal with status from id"
|
178
|
+
|
179
|
+
# when
|
180
|
+
deal.status = 123
|
181
|
+
|
182
|
+
# then
|
183
|
+
deal.status.is_a?(FruitToLime::DealStatus).should eq true
|
184
|
+
deal.status.status_reference.is_a?(FruitToLime::DealStatusReference).should eq true
|
185
|
+
deal.status.status_reference.label.nil?.should eq true
|
186
|
+
deal.status.status_reference.id.should eq "123"
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should raise error if status reference cant be created" do
|
190
|
+
# given
|
191
|
+
deal.name = "Deal with failed status"
|
192
|
+
|
193
|
+
# when, then
|
194
|
+
expect {
|
195
|
+
deal.status = FruitToLime::DealStatus.new({:id => 123})
|
196
|
+
}.to raise_error(FruitToLime::InvalidDealStatusError)
|
197
|
+
end
|
198
|
+
|
112
199
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe "DealStatusReference" do
|
5
|
+
let(:deal_status_reference){
|
6
|
+
FruitToLime::DealStatusReference.new
|
7
|
+
}
|
8
|
+
|
9
|
+
it "should fail on validation if name, id and integration_id is nil" do
|
10
|
+
# given
|
11
|
+
#deal_status_reference
|
12
|
+
|
13
|
+
# when, then
|
14
|
+
deal_status_reference.validate.length.should be > 0
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,30 @@
|
|
1
1
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
2
|
#require File.expand_path("../../config/environment", __FILE__)
|
3
|
-
require 'rspec/autorun'
|
3
|
+
#require 'rspec/autorun'
|
4
4
|
|
5
5
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
6
6
|
# in spec/support/ and its subdirectories.
|
7
7
|
Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
|
8
8
|
|
9
9
|
RSpec.configure do |config|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
+
|
24
|
+
# Allow both should and expect syntax
|
25
|
+
# http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
26
|
+
config.expect_with :rspec do |c|
|
27
|
+
c.syntax = [:should, :expect]
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
@@ -7,9 +7,9 @@ class Exporter
|
|
7
7
|
# coworker
|
8
8
|
def to_organization(row, rootmodel)
|
9
9
|
organization = FruitToLime::Organization.new
|
10
|
-
# Integrationid is typically the id in the system that
|
10
|
+
# Integrationid is typically the id in the system that
|
11
11
|
# we are getting the csv from. Must be set to be able
|
12
|
-
# to import the same file more than once without
|
12
|
+
# to import the same file more than once without
|
13
13
|
# creating duplicates
|
14
14
|
organization.integration_id = row['id']
|
15
15
|
organization.name = row['name']
|
@@ -70,7 +70,7 @@ class Exporter
|
|
70
70
|
|
71
71
|
# Tags and custom fields are set the same
|
72
72
|
# way as on organizations
|
73
|
-
|
73
|
+
|
74
74
|
return coworker
|
75
75
|
end
|
76
76
|
|
@@ -122,7 +122,13 @@ class Exporter
|
|
122
122
|
deal.probability = 50 # should be between 0 - 100
|
123
123
|
deal.order_date = '2014-01-05' # Format ?
|
124
124
|
|
125
|
-
# status,
|
125
|
+
# status, set this by either label, id or integration_id (use
|
126
|
+
# appropriate method to find status)
|
127
|
+
deal.status = rootmodel.settings.deal.find_status_by_label row['status']
|
128
|
+
|
129
|
+
# or set by existing status, search by label, integration_id
|
130
|
+
# (if string) or id (if integer).
|
131
|
+
# deal.status = "Won"
|
126
132
|
|
127
133
|
return deal
|
128
134
|
end
|
@@ -135,6 +141,14 @@ class Exporter
|
|
135
141
|
model.settings.with_organization do |organization|
|
136
142
|
organization.set_custom_field( { :integrationid => 'external_url', :title => 'Link to external system', :type => :Link } )
|
137
143
|
end
|
144
|
+
|
145
|
+
model.settings.with_deal do |deal|
|
146
|
+
deal.add_status({:label => "1. Kvalificering", :integration_id => "qualification"})
|
147
|
+
deal.add_status({:label => "Vunnen", :integration_id => "won",
|
148
|
+
:assessment => FruitToLime::DealState::PositiveEndState })
|
149
|
+
deal.add_status({:label => "Lost", :integration_id => "Lost",
|
150
|
+
:assessment => FruitToLime::DealState::NegativeEndState })
|
151
|
+
end
|
138
152
|
end
|
139
153
|
|
140
154
|
def process_rows(file_name)
|
@@ -215,10 +215,12 @@ class Exporter
|
|
215
215
|
# remove everything that is not an intiger
|
216
216
|
deal.probability = row['probability'].gsub(/[^\d]/,"").to_i unless row['probability'].nil?
|
217
217
|
|
218
|
-
#
|
218
|
+
# Sets the deal's status to the value of the Easy field. This
|
219
|
+
# assumes that the status is already created in LIME Go. To
|
220
|
+
# create statuses during import add them to the settings
|
221
|
+
# during configure.
|
219
222
|
if !row['Status'].empty?
|
220
|
-
deal.status =
|
221
|
-
deal.status.label = row['Status']
|
223
|
+
deal.status = row['Status']
|
222
224
|
end
|
223
225
|
|
224
226
|
# Tags
|
@@ -295,6 +297,13 @@ class Exporter
|
|
295
297
|
model.settings.with_person do |person|
|
296
298
|
person.set_custom_field( { :integration_id => 'shoe_size', :title => 'Shoe size', :type => :String} )
|
297
299
|
end
|
300
|
+
|
301
|
+
model.settings.with_deal do |deal|
|
302
|
+
# assessment is default DealState::NoEndState
|
303
|
+
deal.add_status( {:label => '1. Kvalificering' })
|
304
|
+
deal.add_status( {:label => '2. Deal closed', :assessment => DealState::PositiveEndState })
|
305
|
+
deal.add_status( {:label => '4. Deal lost', :assessment => DealState::NegativeEndState })
|
306
|
+
end
|
298
307
|
end
|
299
308
|
|
300
309
|
def process_rows(file_name)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fruit_to_lime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.1
|
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-07-
|
15
|
+
date: 2014-07-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: iso_country_codes
|
@@ -178,7 +178,11 @@ files:
|
|
178
178
|
- lib/fruit_to_lime/model/coworker_reference.rb
|
179
179
|
- lib/fruit_to_lime/model/customfield.rb
|
180
180
|
- lib/fruit_to_lime/model/deal.rb
|
181
|
+
- lib/fruit_to_lime/model/deal_class_settings.rb
|
182
|
+
- lib/fruit_to_lime/model/deal_state.rb
|
181
183
|
- lib/fruit_to_lime/model/deal_status.rb
|
184
|
+
- lib/fruit_to_lime/model/deal_status_reference.rb
|
185
|
+
- lib/fruit_to_lime/model/deal_status_setting.rb
|
182
186
|
- lib/fruit_to_lime/model/note.rb
|
183
187
|
- lib/fruit_to_lime/model/organization.rb
|
184
188
|
- lib/fruit_to_lime/model/person.rb
|
@@ -232,7 +236,9 @@ files:
|
|
232
236
|
- spec/class_settings_spec.rb
|
233
237
|
- spec/coworker_spec.rb
|
234
238
|
- spec/custom_field_spec.rb
|
239
|
+
- spec/deal_class_settings_spec.rb
|
235
240
|
- spec/deal_spec.rb
|
241
|
+
- spec/deal_status_reference_spec.rb
|
236
242
|
- spec/helpers/csv_helper_spec.rb
|
237
243
|
- spec/helpers/email_helper_spec.rb
|
238
244
|
- spec/helpers/phone_helper_spec.rb
|
@@ -274,7 +280,9 @@ test_files:
|
|
274
280
|
- spec/class_settings_spec.rb
|
275
281
|
- spec/coworker_spec.rb
|
276
282
|
- spec/custom_field_spec.rb
|
283
|
+
- spec/deal_class_settings_spec.rb
|
277
284
|
- spec/deal_spec.rb
|
285
|
+
- spec/deal_status_reference_spec.rb
|
278
286
|
- spec/helpers/csv_helper_spec.rb
|
279
287
|
- spec/helpers/email_helper_spec.rb
|
280
288
|
- spec/helpers/phone_helper_spec.rb
|