fruit_to_lime 2.6.2 → 2.6.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.
@@ -31,9 +31,9 @@ module FruitToLime
31
31
  end
32
32
 
33
33
  def get_import_rows
34
- (serialize_variables+[
35
- {:id=>:organization, :type=>:organization_reference},
36
- {:id=>:person, :type=>:person_reference}
34
+ (serialize_variables + [
35
+ { :id => :organization, :type => :organization_reference},
36
+ { :id => :person, :type => :person_reference}
37
37
  ]).map do |p|
38
38
  map_to_row p
39
39
  end
@@ -1,3 +1,4 @@
1
+ require 'date'
1
2
  module FruitToLime
2
3
  class OrganizationReference
3
4
  include SerializeHelper
@@ -43,6 +44,10 @@ module FruitToLime
43
44
  attr_accessor :id, :integration_id, :name, :organization_number, :email, :web_site,
44
45
  :postal_address, :visit_address, :central_phone_number, :source_data
45
46
 
47
+ # Sets/gets the date when this organization's relation was
48
+ # changed. Default is Now.
49
+ attr_reader :relation_last_modified
50
+
46
51
  attr_reader :employees, :responsible_coworker, :relation
47
52
  # you add custom values by using {#set_custom_value}
48
53
  attr_reader :custom_values
@@ -135,11 +140,21 @@ module FruitToLime
135
140
  if relation == Relation::NoRelation || relation == Relation::WorkingOnIt ||
136
141
  relation == Relation::IsACustomer || relation == Relation::WasACustomer || relation == Relation::BeenInTouch
137
142
  @relation = relation
143
+ @relation_last_modified = Time.now.strftime("%Y-%m-%d") if @relation_last_modified.nil? &&
144
+ @relation != Relation::NoRelation
138
145
  else
139
146
  raise InvalidRelationError
140
147
  end
141
148
  end
142
149
 
150
+ def relation_last_modified=(date)
151
+ begin
152
+ @relation_last_modified = @relation != Relation::NoRelation ? Date.parse(date).strftime("%Y-%m-%d") : nil
153
+ rescue
154
+ raise InvalidValueError, date
155
+ end
156
+ end
157
+
143
158
  def find_employee_by_integration_id(integration_id)
144
159
  return nil if @employees.nil?
145
160
  return @employees.find do |e|
@@ -163,7 +178,8 @@ module FruitToLime
163
178
  { :id => :custom_values, :type => :custom_values },
164
179
  { :id => :tags, :type => :tags },
165
180
  { :id => :responsible_coworker, :type => :coworker_reference},
166
- { :id => :relation, :type => :string }
181
+ { :id => :relation, :type => :string },
182
+ { :id => :relation_last_modified, :type => :string }
167
183
  ]
168
184
  end
169
185
 
@@ -63,6 +63,54 @@ describe "Organization" do
63
63
  organization.relation = "hubbabubba"
64
64
  }.to raise_error(FruitToLime::InvalidRelationError)
65
65
  end
66
+
67
+ it "should not have a relation modified date if relation is NoRelation" do
68
+ # given, when
69
+ organization.relation = FruitToLime::Relation::NoRelation
70
+
71
+ # then
72
+ organization.relation_last_modified.nil?.should eq true
73
+ end
74
+
75
+ it "should have a relation modified date if relation is IsACustomer" do
76
+ # given, when
77
+ organization.relation = FruitToLime::Relation::IsACustomer
78
+
79
+ # then
80
+ organization.relation_last_modified.nil?.should eq false
81
+ end
82
+
83
+ it "should set relation last modified when relation is set" do
84
+ # given
85
+ organization.relation = FruitToLime::Relation::IsACustomer
86
+
87
+ # when
88
+ organization.relation_last_modified = "2014-07-01"
89
+
90
+ # then
91
+ organization.relation_last_modified.should eq "2014-07-01"
92
+ end
93
+
94
+ it "should not set relation last modified when relation is NoRelation" do
95
+ # given
96
+ organization.relation = FruitToLime::Relation::NoRelation
97
+
98
+ # when
99
+ organization.relation_last_modified = "2014-07-01"
100
+
101
+ # then
102
+ organization.relation_last_modified.nil?.should eq true
103
+ end
104
+
105
+ it "should only set relation last modified to valid date" do
106
+ # given
107
+ organization.relation = FruitToLime::Relation::IsACustomer
108
+
109
+ # when, then
110
+ expect {
111
+ organization.relation_last_modified = "hubbabubba"
112
+ }.to raise_error(FruitToLime::InvalidValueError)
113
+ end
66
114
  end
67
115
 
68
116
  describe "OrganizationReference" do
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.2
4
+ version: 2.6.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-07-14 00:00:00.000000000 Z
15
+ date: 2014-07-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: iso_country_codes