fruit_to_lime 2.7.0 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,4 +16,7 @@ module FruitToLime
16
16
 
17
17
  class InvalidDealStatusError < StandardError
18
18
  end
19
+
20
+ class InvalidNoteClassificationError < StandardError
21
+ end
19
22
  end
@@ -1,10 +1,14 @@
1
1
  module FruitToLime
2
2
  class Note
3
3
  include SerializeHelper
4
- attr_accessor :id, :text, :integration_id, :classification, :date
4
+ attr_accessor :id, :text, :integration_id, :date
5
5
 
6
6
  attr_reader :organization, :created_by, :person, :deal
7
7
 
8
+ # The note's classification. It should be a value from
9
+ # {#NoteClassification}. The default value is Comment.
10
+ attr_reader :classification
11
+
8
12
  def initialize(opt = nil)
9
13
  if !opt.nil?
10
14
  serialize_variables.each do |myattr|
@@ -12,6 +16,8 @@ module FruitToLime
12
16
  instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
13
17
  end
14
18
  end
19
+
20
+ @classification = NoteClassification::Comment if @classification.nil?
15
21
  end
16
22
 
17
23
  def serialize_variables
@@ -59,6 +65,17 @@ module FruitToLime
59
65
  @deal = DealReference.from_deal(deal)
60
66
  end
61
67
 
68
+ def classification=(classification)
69
+ if classification == NoteClassification::Comment || classification == NoteClassification::SalesCall ||
70
+ classification == NoteClassification::TalkedTo || classification == NoteClassification::TriedToReach ||
71
+ classification == NoteClassification::ClientVisit
72
+ @classification = classification
73
+ else
74
+ raise InvalidNoteClassificationError
75
+ end
76
+
77
+ end
78
+
62
79
  def validate
63
80
  error = String.new
64
81
 
@@ -0,0 +1,25 @@
1
+ module FruitToLime
2
+ # Defines a note's classification. This defines what kind of
3
+ # action that happened before the note was written.
4
+ module NoteClassification
5
+ # We talked to the client about a sale. This might be a phone call
6
+ # or a talk in person.
7
+ SalesCall = 0
8
+
9
+ # This is a general comment about the organization or deal.
10
+ Comment = 1
11
+
12
+ # This is a general comment regarding a talk we had with
13
+ # someone at the client.
14
+ TalkedTo = 2
15
+
16
+ # We tried to reach someone but failed.
17
+ TriedToReach = 3
18
+
19
+ # We had a meeting at the client's site.
20
+ ClientVisit = 4
21
+ end
22
+ end
23
+
24
+
25
+
@@ -95,4 +95,16 @@ describe "Note" do
95
95
  # then
96
96
  note.deal.is_a?(FruitToLime::DealReference).should eq true
97
97
  end
98
+
99
+ it "should have Comment as default classification" do
100
+ # then
101
+ note.classification.should eq FruitToLime::NoteClassification::Comment
102
+ end
103
+
104
+ it "should not accept invalid classifications" do
105
+ # when, then
106
+ expect {
107
+ note.classification = "hubbabubba"
108
+ }.to raise_error(FruitToLime::InvalidNoteClassificationError)
109
+ end
98
110
  end
@@ -85,7 +85,7 @@ class Converter
85
85
  # Set note properties from the row.
86
86
  organization = @rootmodel.find_organization_by_integration_id(row['KUNDNR'])
87
87
  unless organization.nil?
88
- note.organization = organization.to_reference
88
+ note.organization = organization
89
89
  end
90
90
  note.created_by = @rootmodel.import_coworker
91
91
  note.text = row['ANTECK_1']
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.7.0
4
+ version: 2.7.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-09-02 00:00:00.000000000 Z
15
+ date: 2014-09-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: iso_country_codes
@@ -186,6 +186,7 @@ files:
186
186
  - lib/fruit_to_lime/model/documents.rb
187
187
  - lib/fruit_to_lime/model/link.rb
188
188
  - lib/fruit_to_lime/model/note.rb
189
+ - lib/fruit_to_lime/model/note_classification.rb
189
190
  - lib/fruit_to_lime/model/organization.rb
190
191
  - lib/fruit_to_lime/model/person.rb
191
192
  - lib/fruit_to_lime/model/referencetosource.rb