fruit_to_lime 2.5.2 → 2.5.3
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/fruit_to_lime/errors.rb +6 -0
- data/lib/fruit_to_lime/model/deal.rb +25 -2
- data/spec/deal_spec.rb +44 -3
- metadata +2 -2
data/lib/fruit_to_lime/errors.rb
CHANGED
@@ -36,12 +36,12 @@ module FruitToLime
|
|
36
36
|
# LIME Go before the import.
|
37
37
|
attr_accessor :status
|
38
38
|
|
39
|
-
attr_accessor :id, :integration_id, :name, :description, :probability, :
|
39
|
+
attr_accessor :id, :integration_id, :name, :description, :probability, :order_date
|
40
40
|
|
41
41
|
# you add custom values by using {#set_custom_value}
|
42
42
|
attr_reader :custom_values
|
43
43
|
|
44
|
-
attr_reader :customer, :responsible_coworker, :customer_contact
|
44
|
+
attr_reader :customer, :responsible_coworker, :customer_contact, :value
|
45
45
|
|
46
46
|
def serialize_variables
|
47
47
|
[ :id, :integration_id, :name, :description, :probability, :value, :order_date ].map {
|
@@ -118,5 +118,28 @@ module FruitToLime
|
|
118
118
|
def customer_contact=(person)
|
119
119
|
@customer_contact = PersonReference.from_person(person)
|
120
120
|
end
|
121
|
+
|
122
|
+
def value=(value)
|
123
|
+
# we have had some issues with LIME Easy imports where the
|
124
|
+
# value was in the format "357 000". We need to remove
|
125
|
+
# those spaces.
|
126
|
+
fixed_value = value.gsub(" ", "")
|
127
|
+
|
128
|
+
if is_integer?(fixed_value)
|
129
|
+
@value = fixed_value
|
130
|
+
elsif is_float?(fixed_value)
|
131
|
+
@value = fixed_value
|
132
|
+
else
|
133
|
+
raise InvalidValueError, value
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def is_integer?(value)
|
138
|
+
true if Integer(value) rescue false
|
139
|
+
end
|
140
|
+
|
141
|
+
def is_float?(value)
|
142
|
+
true if Float(value) rescue false
|
143
|
+
end
|
121
144
|
end
|
122
145
|
end
|
data/spec/deal_spec.rb
CHANGED
@@ -48,14 +48,55 @@ describe "Deal" do
|
|
48
48
|
deal.customer_contact.is_a?(FruitToLime::PersonReference).should eq true
|
49
49
|
end
|
50
50
|
|
51
|
-
it "will fail on validation if name
|
51
|
+
it "will fail on validation if name and customer is empty" do
|
52
52
|
# given, when
|
53
53
|
deal.name = "The big deal"
|
54
54
|
deal.customer = FruitToLime::Organization.new({:integration_id => "123", :name => "Lundalogik"})
|
55
|
-
deal.responsible_coworker =
|
56
|
-
FruitToLime::Coworker.new({ :integration_id => "456", :first_name => "Billy", :last_name => "Bob" })
|
57
55
|
|
58
56
|
# then
|
59
57
|
deal.validate.should eq ""
|
60
58
|
end
|
59
|
+
|
60
|
+
it "should convert value strings that looks like number to number" do
|
61
|
+
# given
|
62
|
+
deal.name = "The deal with a strange value"
|
63
|
+
|
64
|
+
# when
|
65
|
+
deal.value = "357 000"
|
66
|
+
|
67
|
+
# then
|
68
|
+
deal.value.should eq "357000"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should raise invalidvalueerror if value is not a number" do
|
72
|
+
# given
|
73
|
+
deal.name = "The deal with an invalid value"
|
74
|
+
|
75
|
+
# when, then
|
76
|
+
expect {
|
77
|
+
deal.value = "Im not a number"
|
78
|
+
}.to raise_error(FruitToLime::InvalidValueError)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should set value if value is an integer" do
|
82
|
+
# given
|
83
|
+
deal.name = "The new deal"
|
84
|
+
|
85
|
+
# when
|
86
|
+
deal.value = "100"
|
87
|
+
|
88
|
+
# then
|
89
|
+
deal.value.should eq "100"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should set value if value is a float" do
|
93
|
+
# given
|
94
|
+
deal.name = "The new deal"
|
95
|
+
|
96
|
+
# when
|
97
|
+
deal.value = "100.10"
|
98
|
+
|
99
|
+
# then
|
100
|
+
deal.value.should eq "100.10"
|
101
|
+
end
|
61
102
|
end
|
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.5.
|
4
|
+
version: 2.5.3
|
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-06-
|
15
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: iso_country_codes
|