fruit_to_lime 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fruit_to_lime/model/deal.rb +23 -4
- data/spec/coworker_spec.rb +22 -22
- data/spec/deal_spec.rb +33 -0
- metadata +2 -2
@@ -3,10 +3,9 @@ module FruitToLime
|
|
3
3
|
class Deal
|
4
4
|
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
5
5
|
|
6
|
-
attr_accessor :id, :integration_id, :name, :description, :probability, :value, :order_date,
|
7
|
-
:responsible_coworker, :customer_contact, :status
|
6
|
+
attr_accessor :id, :integration_id, :name, :description, :probability, :value, :order_date, :status
|
8
7
|
# you add custom values by using {#set_custom_value}
|
9
|
-
attr_reader :custom_values, :customer
|
8
|
+
attr_reader :custom_values, :customer, :responsible_coworker, :customer_contact
|
10
9
|
|
11
10
|
def serialize_variables
|
12
11
|
[ :id, :integration_id, :name, :description, :probability, :value, :order_date ].map {
|
@@ -46,7 +45,19 @@ module FruitToLime
|
|
46
45
|
error = String.new
|
47
46
|
|
48
47
|
if @name.nil? || @name.empty?
|
49
|
-
error = "A name is required for deal.\n
|
48
|
+
error = "A name is required for deal.\n}"
|
49
|
+
end
|
50
|
+
|
51
|
+
if @customer.nil?
|
52
|
+
error = "#{error}\nA customer is required for deal."
|
53
|
+
end
|
54
|
+
|
55
|
+
if @responsible_coworker.nil?
|
56
|
+
error = "#{error}\nA responsible coworker is required for deal."
|
57
|
+
end
|
58
|
+
|
59
|
+
if error.length > 0
|
60
|
+
error = "#{error}\n#{serialize()}"
|
50
61
|
end
|
51
62
|
|
52
63
|
return error
|
@@ -60,5 +71,13 @@ module FruitToLime
|
|
60
71
|
def customer=(customer)
|
61
72
|
@customer = OrganizationReference.from_organization(customer)
|
62
73
|
end
|
74
|
+
|
75
|
+
def responsible_coworker=(coworker)
|
76
|
+
@responsible_coworker = CoworkerReference.from_coworker(coworker)
|
77
|
+
end
|
78
|
+
|
79
|
+
def customer_contact=(person)
|
80
|
+
@customer_contact = PersonReference.from_person(person)
|
81
|
+
end
|
63
82
|
end
|
64
83
|
end
|
data/spec/coworker_spec.rb
CHANGED
@@ -33,36 +33,36 @@ describe "Coworker" do
|
|
33
33
|
coworker.parse_name_to_firstname_lastname_se nil, 'a default'
|
34
34
|
|
35
35
|
coworker.first_name.should eq 'a default'
|
36
|
-
end
|
36
|
+
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe "
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
describe "guess_email" do
|
40
|
+
it "guesses kalle.nilsson@x.com for coworker with firstname 'Kalle', lastname 'Nilsson' and domain set to 'x.com" do
|
41
|
+
coworker.first_name = 'Kalle'
|
42
|
+
coworker.last_name = 'Nilsson'
|
43
43
|
|
44
|
-
|
44
|
+
guessed = coworker.guess_email 'x.com'
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
guessed.should eq 'kalle.nilsson@x.com'
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
it "guesses '' when lastname is missing" do
|
50
|
+
coworker.first_name = 'Kalle'
|
51
|
+
coworker.last_name = ''
|
52
52
|
|
53
|
-
|
53
|
+
guessed = coworker.guess_email 'x.com'
|
54
54
|
|
55
|
-
|
56
|
-
|
55
|
+
guessed.should eq ''
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
it "guesses '' when firstname is missing" do
|
59
|
+
coworker.first_name = nil
|
60
|
+
coworker.last_name = 'Nilsson'
|
61
61
|
|
62
|
-
|
62
|
+
guessed = coworker.guess_email 'x.com'
|
63
63
|
|
64
|
-
|
65
|
-
|
64
|
+
guessed.should eq ''
|
65
|
+
end
|
66
66
|
|
67
67
|
it "guesses åäöèé to be aaoee" do
|
68
68
|
coworker.first_name = 'åäöèé'
|
@@ -80,7 +80,7 @@ describe "Coworker" do
|
|
80
80
|
guessed = coworker.guess_email 'x.com'
|
81
81
|
|
82
82
|
guessed.should eq 'sven-erik.nilsson@x.com'
|
83
|
-
end
|
83
|
+
end
|
84
84
|
|
85
85
|
it "guesses 'sven.nilsson-svensson@x.com' when lastnames has two names with ' ' between them" do
|
86
86
|
coworker.first_name = 'Sven'
|
@@ -89,6 +89,6 @@ describe "Coworker" do
|
|
89
89
|
guessed = coworker.guess_email 'x.com'
|
90
90
|
|
91
91
|
guessed.should eq 'sven.nilsson-svensson@x.com'
|
92
|
-
end
|
92
|
+
end
|
93
93
|
end
|
94
94
|
end
|
data/spec/deal_spec.rb
CHANGED
@@ -25,4 +25,37 @@ describe "Deal" do
|
|
25
25
|
# then
|
26
26
|
deal.customer.is_a?(FruitToLime::OrganizationReference).should eq true
|
27
27
|
end
|
28
|
+
|
29
|
+
it "will auto convert coworker to coworker.ref during assignment" do
|
30
|
+
# given
|
31
|
+
coworker = FruitToLime::Coworker.new({:integration_id => "456", :first_name => "Billy", :last_name => "Bob"})
|
32
|
+
|
33
|
+
# when
|
34
|
+
deal.responsible_coworker = coworker
|
35
|
+
|
36
|
+
# then
|
37
|
+
deal.responsible_coworker.is_a?(FruitToLime::CoworkerReference).should eq true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "will auto convert person to person.ref during assignment" do
|
41
|
+
# given
|
42
|
+
person = FruitToLime::Person.new({:integration_id => "123"})
|
43
|
+
|
44
|
+
# when
|
45
|
+
deal.customer_contact = person
|
46
|
+
|
47
|
+
# then
|
48
|
+
deal.customer_contact.is_a?(FruitToLime::PersonReference).should eq true
|
49
|
+
end
|
50
|
+
|
51
|
+
it "will fail on validation if name, responsible and customer is empty" do
|
52
|
+
# given, when
|
53
|
+
deal.name = "The big deal"
|
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
|
+
|
58
|
+
# then
|
59
|
+
deal.validate.should eq ""
|
60
|
+
end
|
28
61
|
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.4.
|
4
|
+
version: 2.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-05-
|
14
|
+
date: 2014-05-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: iso_country_codes
|