fruit_to_lime 2.6.1 → 2.6.2

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.
@@ -2,7 +2,7 @@ module FruitToLime
2
2
  class CustomFieldReference
3
3
  include SerializeHelper, ModelWithIntegrationIdSameAs
4
4
 
5
- attr_accessor :id, :integration_id
5
+ attr_accessor :integration_id
6
6
 
7
7
  def initialize(opt=nil)
8
8
  if opt != nil
@@ -14,7 +14,7 @@ module FruitToLime
14
14
  end
15
15
 
16
16
  def serialize_variables
17
- [:id, :integration_id].map {|p| { :id => p, :type => :string } }
17
+ [:integration_id].map {|p| { :id => p, :type => :string } }
18
18
  end
19
19
 
20
20
  def get_import_rows
@@ -47,7 +47,7 @@ module FruitToLime
47
47
  end
48
48
 
49
49
  def find_status_by_label(label)
50
- return nil if @statuses.nil?
50
+ return nil if @statuses.nil? || label.nil?
51
51
 
52
52
  return @statuses.find do |status|
53
53
  !status.label.nil? && status.label.casecmp(label) == 0
@@ -55,7 +55,7 @@ module FruitToLime
55
55
  end
56
56
 
57
57
  def find_status_by_integration_id(integration_id)
58
- return nil if @statuses.nil?
58
+ return nil if @statuses.nil? || integration_id.nil?
59
59
 
60
60
  return @statuses.find do |status|
61
61
  !status.integration_id.nil? && status.integration_id.casecmp(integration_id) == 0
@@ -2,7 +2,7 @@ module FruitToLime
2
2
  class DealStatusReference
3
3
  include SerializeHelper
4
4
 
5
- attr_accessor :id, :label, :integration_id
5
+ attr_accessor :label, :integration_id
6
6
 
7
7
  def initialize(opt = nil)
8
8
  if opt != nil
@@ -14,7 +14,7 @@ module FruitToLime
14
14
  end
15
15
 
16
16
  def serialize_variables
17
- [:id, :integration_id, :label].map {|p| {:id => p, :type => :string} }
17
+ [:integration_id, :label].map {|p| {:id => p, :type => :string} }
18
18
  end
19
19
 
20
20
  def serialize_name
@@ -29,8 +29,6 @@ module FruitToLime
29
29
  return deal_status.to_reference
30
30
  elsif deal_status.is_a?(String)
31
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
32
  end
35
33
 
36
34
  raise InvalidDealStatusError
@@ -39,8 +37,8 @@ module FruitToLime
39
37
  def validate
40
38
  error = ""
41
39
 
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"
40
+ if (@label.nil? || @label.empty?) && (@integration_id.nil? || @integration_id.empty?)
41
+ error = "label and integration_id can't all be nil or empty"
44
42
  end
45
43
 
46
44
  return error
@@ -24,7 +24,6 @@ module FruitToLime
24
24
 
25
25
  def to_reference()
26
26
  reference = DealStatusReference.new
27
- reference.id = @id
28
27
  reference.label = @label
29
28
  reference.integration_id = @integration_id
30
29
 
@@ -31,7 +31,7 @@ module FruitToLime
31
31
  module ModelWithIntegrationIdSameAs
32
32
  # check if other is same as regarding integration_id or id
33
33
  def same_as?(other)
34
- if @integration_id!=nil && @integration_id == other.integration_id
34
+ if @integration_id != nil && @integration_id == other.integration_id
35
35
  return true
36
36
  end
37
37
  if @id != nil && @id == other.id
@@ -68,6 +68,18 @@ describe "DealClassSettings" do
68
68
  status.should eq nil
69
69
  end
70
70
 
71
+ it "should find nil by label if label is nil" do
72
+ # given
73
+ deal_class_settings.add_status({:label => "1. Kvalificering", :integration_id => "qualify"})
74
+ deal_class_settings.add_status({:label => "2. Skickat offert", :integration_id => "tender sent"})
75
+
76
+ # when
77
+ status = deal_class_settings.find_status_by_label(nil)
78
+
79
+ # then
80
+ status.should eq nil
81
+ end
82
+
71
83
  it "should find nil by integration id if no statuses are defined" do
72
84
  # given, when
73
85
  status = deal_class_settings.find_status_by_integration_id("3. Won")
@@ -76,6 +88,17 @@ describe "DealClassSettings" do
76
88
  status.should eq nil
77
89
  end
78
90
 
91
+ it "should find nil by integration id if integration id is nil" do
92
+ # given
93
+ deal_class_settings.add_status({:label => "1. Kvalificering", :integration_id => "qualify"})
94
+ deal_class_settings.add_status({:label => "2. Skickat offert", :integration_id => "tender sent"})
95
+
96
+ # when
97
+ status = deal_class_settings.find_status_by_integration_id(nil)
98
+
99
+ # then
100
+ status.should eq nil
101
+ end
79
102
  end
80
103
 
81
104
 
data/spec/deal_spec.rb CHANGED
@@ -152,7 +152,7 @@ describe "Deal" do
152
152
  deal.status.status_reference.integration_id.should eq "123"
153
153
  end
154
154
 
155
- it "should set status_reference from label if status is a string" do
155
+ it "should set status_reference from label and integrationid if status is a string" do
156
156
  # This case should be used when the status is already defined
157
157
  # in the appliation and is referenced by label
158
158
 
@@ -166,24 +166,7 @@ describe "Deal" do
166
166
  deal.status.is_a?(FruitToLime::DealStatus).should eq true
167
167
  deal.status.status_reference.is_a?(FruitToLime::DealStatusReference).should eq true
168
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"
169
+ deal.status.status_reference.integration_id.should eq "Driv"
187
170
  end
188
171
 
189
172
  it "should raise error if status reference cant be created" do
@@ -36,7 +36,7 @@ describe FruitToLime::SerializeHelper do
36
36
  v = FruitToLime::CustomValue.new
37
37
  v.value = "<text>"
38
38
  v.field = FruitToLime::CustomFieldReference.new()
39
- v.field.id = "1"
39
+ v.field.integration_id = "1"
40
40
  FruitToLime::SerializeHelper::serialize(v,-1)
41
41
  }
42
42
  it "should contain encoded text" do
data/spec/person_spec.rb CHANGED
@@ -31,23 +31,21 @@ describe "Person" do
31
31
  end
32
32
 
33
33
  it "will set custom field with same id to the last value" do
34
- person.set_custom_field({:id=>'the id',
35
- :value=> 'the value'})
34
+ person.set_custom_field({ :integration_id => 'the id', :value=> 'the value' })
36
35
 
37
- person.set_custom_field({:id=>'the id',
38
- :value=> 'the value 2'})
36
+ person.set_custom_field({ :integration_id => 'the id', :value=> 'the value 2'})
39
37
  value = person.custom_values[0]
40
38
  field = value.field
41
39
 
42
40
  person.custom_values.length.should eq 1
43
- field.id.should eq 'the id'
41
+ field.integration_id.should eq 'the id'
44
42
  value.value.should eq 'the value 2'
45
43
  end
46
44
 
47
45
  it "will set custom field (using set_custom_value) with same integration_id to the last value" do
48
- person.set_custom_value('the id','the value')
46
+ person.set_custom_value('the id', 'the value')
49
47
 
50
- person.set_custom_value('the id','the value 2')
48
+ person.set_custom_value('the id', 'the value 2')
51
49
  value = person.custom_values[0]
52
50
  field = value.field
53
51
 
@@ -1,2 +1,2 @@
1
- id;name;value;responsible_id;customer_id;customer_contact_id
2
- 333;Feta affären;10000;666;6;123
1
+ id;name;value;responsible_id;customer_id;customer_contact_id;status
2
+ 333;Feta affären;10000;666;6;123;Vunnen
@@ -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
3
  #require 'rspec/rails'
4
- require 'rspec/autorun'
4
+ #require 'rspec/autorun'
5
5
 
6
6
  # Requires supporting ruby files with custom matchers and macros, etc,
7
7
  # in spec/support/ and its subdirectories.
8
8
  #Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
9
9
 
10
10
  RSpec.configure do |config|
11
- # ## Mock Framework
12
- #
13
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
- #
15
- # config.mock_with :mocha
16
- # config.mock_with :flexmock
17
- # config.mock_with :rr
11
+ # ## Mock Framework
12
+ #
13
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
+ #
15
+ # config.mock_with :mocha
16
+ # config.mock_with :flexmock
17
+ # config.mock_with :rr
18
18
 
19
- # Run specs in random order to surface order dependencies. If you find an
20
- # order dependency and want to debug it, you can fix the order by providing
21
- # the seed, which is printed after each run.
22
- # --seed 1234
23
- config.order = "random"
19
+ # Run specs in random order to surface order dependencies. If you find an
20
+ # order dependency and want to debug it, you can fix the order by providing
21
+ # the seed, which is printed after each run.
22
+ # --seed 1234
23
+ config.order = "random"
24
+
25
+ # Allow both should and expect syntax
26
+ # http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
27
+ config.expect_with :rspec do |c|
28
+ c.syntax = [:should, :expect]
29
+ end
24
30
  end
@@ -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
3
  #require 'rspec/rails'
4
- require 'rspec/autorun'
4
+ #require 'rspec/autorun'
5
5
 
6
6
  # Requires supporting ruby files with custom matchers and macros, etc,
7
7
  # in spec/support/ and its subdirectories.
8
8
  #Dir[File.join(File.dirname(File.absolute_path(__FILE__)),"support/**/*.rb")].each { |f| require f }
9
9
 
10
10
  RSpec.configure do |config|
11
- # ## Mock Framework
12
- #
13
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
- #
15
- # config.mock_with :mocha
16
- # config.mock_with :flexmock
17
- # config.mock_with :rr
11
+ # ## Mock Framework
12
+ #
13
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
+ #
15
+ # config.mock_with :mocha
16
+ # config.mock_with :flexmock
17
+ # config.mock_with :rr
18
18
 
19
- # Run specs in random order to surface order dependencies. If you find an
20
- # order dependency and want to debug it, you can fix the order by providing
21
- # the seed, which is printed after each run.
22
- # --seed 1234
23
- config.order = "random"
19
+ # Run specs in random order to surface order dependencies. If you find an
20
+ # order dependency and want to debug it, you can fix the order by providing
21
+ # the seed, which is printed after each run.
22
+ # --seed 1234
23
+ config.order = "random"
24
+
25
+ # Allow both should and expect syntax
26
+ # http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
27
+ config.expect_with :rspec do |c|
28
+ c.syntax = [:should, :expect]
29
+ end
24
30
  end
@@ -1,20 +1,26 @@
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
  RSpec.configure do |config|
6
- # ## Mock Framework
7
- #
8
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
9
- #
10
- # config.mock_with :mocha
11
- # config.mock_with :flexmock
12
- # config.mock_with :rr
6
+ # ## Mock Framework
7
+ #
8
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
9
+ #
10
+ # config.mock_with :mocha
11
+ # config.mock_with :flexmock
12
+ # config.mock_with :rr
13
13
 
14
- # Run specs in random order to surface order dependencies. If you find an
15
- # order dependency and want to debug it, you can fix the order by providing
16
- # the seed, which is printed after each run.
17
- # --seed 1234
18
- config.order = "random"
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = "random"
19
+
20
+ # Allow both should and expect syntax
21
+ # http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
22
+ config.expect_with :rspec do |c|
23
+ c.syntax = [:should, :expect]
24
+ end
19
25
  end
20
26
 
@@ -1,20 +1,26 @@
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
  RSpec.configure do |config|
6
- # ## Mock Framework
7
- #
8
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
9
- #
10
- # config.mock_with :mocha
11
- # config.mock_with :flexmock
12
- # config.mock_with :rr
6
+ # ## Mock Framework
7
+ #
8
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
9
+ #
10
+ # config.mock_with :mocha
11
+ # config.mock_with :flexmock
12
+ # config.mock_with :rr
13
13
 
14
- # Run specs in random order to surface order dependencies. If you find an
15
- # order dependency and want to debug it, you can fix the order by providing
16
- # the seed, which is printed after each run.
17
- # --seed 1234
18
- config.order = "random"
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = "random"
19
+
20
+ # Allow both should and expect syntax
21
+ # http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
22
+ config.expect_with :rspec do |c|
23
+ c.syntax = [:should, :expect]
24
+ end
19
25
  end
20
26
 
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.1
4
+ version: 2.6.2
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-09 00:00:00.000000000 Z
15
+ date: 2014-07-14 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: iso_country_codes