capsule_crm 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e6d24bb7037a3d119bccf9122b99dcc4c637a76
4
- data.tar.gz: d3963ea029b318ad0e730ef6d7fd8d37fe42a758
3
+ metadata.gz: 3a971137b1c0c66a676abb680757dd95d181483a
4
+ data.tar.gz: 9df7cb48de8496c48b9201afa44558e786433ffe
5
5
  SHA512:
6
- metadata.gz: d7e0f36ec559f8d5473f50050c2751b5ec4e3c91cbd0cd210ba1e65ab2342dc15e961ff3a2792baa346b2e249931a2601bdd96588e234e355cf875614b10a324
7
- data.tar.gz: 2afd21361071265d65f897c386dd83d845d835e45edb5be1e9e6ec283486ca1ec10e81764a3ff63a33ada828ec4ba86de2d0cb261a7a9d06861867337e45f731
6
+ metadata.gz: 870dfbbc6202b575235e02ba4a8902dea7bca317b70d2bd7a79fa6e563da3582071133a97b21ef1718556d0e8b4ef196430a7f68d1ff4dc3151dc042084c6264
7
+ data.tar.gz: bb6fe469ff5993c9e12bcb33444548402bda97112a3ff44fc632e9ba7810bfa2784f4cbd923fd3d500b6d265eac9987547a49b1c9923a36665652185f467c5c7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.1
4
+
5
+ - Add ID to email, website, address and phone models to fix bug where they were
6
+ being duplicated every time a contactable model was saved
7
+
3
8
  ## 1.5.0
4
9
 
5
10
  - Add TaskCategory
@@ -6,13 +6,15 @@ module CapsuleCRM
6
6
 
7
7
  serializable_config do |config|
8
8
  config.include_root = false
9
+ config.exclude_id = false
9
10
  end
10
11
 
11
- attribute :type
12
- attribute :street
13
- attribute :city
14
- attribute :state
15
- attribute :zip
16
- attribute :country
12
+ attribute :id, Integer
13
+ attribute :type, String
14
+ attribute :street, String
15
+ attribute :city, String
16
+ attribute :state, String
17
+ attribute :zip, String
18
+ attribute :country, String
17
19
  end
18
20
  end
@@ -6,8 +6,10 @@ module CapsuleCRM
6
6
 
7
7
  serializable_config do |config|
8
8
  config.include_root = false
9
+ config.exclude_id = false
9
10
  end
10
11
 
12
+ attribute :id, Integer
11
13
  attribute :type
12
14
  attribute :email_address
13
15
 
@@ -6,10 +6,12 @@ module CapsuleCRM
6
6
 
7
7
  serializable_config do |config|
8
8
  config.include_root = false
9
+ config.exclude_id = false
9
10
  end
10
11
 
11
- attribute :type
12
- attribute :phone_number
12
+ attribute :id, Integer
13
+ attribute :type, String
14
+ attribute :phone_number, String
13
15
 
14
16
  def initialize(attributes = {})
15
17
  CapsuleCRM::HashHelper.underscore_keys!(attributes)
@@ -73,11 +73,16 @@ module CapsuleCRM
73
73
 
74
74
  def cleaned_attributes
75
75
  attributes.delete_if do |key, value|
76
- value.blank? || key.to_s == 'id' || excluded_keys.include?(key) ||
76
+ value.blank? || (key.to_s == 'id' && exclude_id?) ||
77
+ excluded_keys.include?(key) ||
77
78
  excluded_association_keys.include?(key.to_s)
78
79
  end
79
80
  end
80
81
 
82
+ def exclude_id?
83
+ @exclude_id ||= true unless options[:exclude_id] == false
84
+ end
85
+
81
86
  # TODO OMG, clean this up!
82
87
  def attributes
83
88
  object.attributes.dup.tap do |attrs|
@@ -1,3 +1,3 @@
1
1
  module CapsuleCrm
2
- VERSION = '1.5.0'
2
+ VERSION = '1.5.1'
3
3
  end
@@ -8,11 +8,13 @@ module CapsuleCRM
8
8
 
9
9
  serializable_config do |config|
10
10
  config.include_root = false
11
+ config.exclude_id = false
11
12
  end
12
13
 
13
- attribute :type
14
- attribute :web_service
15
- attribute :web_address
14
+ attribute :id, Integer
15
+ attribute :type, String
16
+ attribute :web_service, String
17
+ attribute :web_address, String
16
18
 
17
19
  validates :web_service, :web_address, presence: true
18
20
 
@@ -1,4 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CapsuleCRM::Address do
4
+ it_behaves_like 'capsule jsonable' do
5
+ let(:object) do
6
+ CapsuleCRM::Address.new(street: Faker::Address.street_address)
7
+ end
8
+ end
4
9
  end
@@ -1,4 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CapsuleCRM::Email do
4
+ it_behaves_like 'capsule jsonable' do
5
+ let(:object) { CapsuleCRM::Email.new(email_address: Faker::Internet.email) }
6
+ end
4
7
  end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe CapsuleCRM::Phone do
4
+ it_behaves_like 'capsule jsonable' do
5
+ let(:object) { CapsuleCRM::Phone.new(phone_number: '1234') }
6
+ end
7
+ end
@@ -35,6 +35,14 @@ describe CapsuleCRM::Serializer do
35
35
  end
36
36
  end
37
37
 
38
+ context 'when exclude_id is false' do
39
+ before { options.merge!(exclude_id: false) }
40
+
41
+ it 'should include the ID' do
42
+ expect(subject['serializabletest'].keys).to include('id')
43
+ end
44
+ end
45
+
38
46
  context 'when include_root is false' do
39
47
  before do
40
48
  options.merge!(include_root: false)
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe CapsuleCRM::Website do
4
+ it_behaves_like 'capsule jsonable' do
5
+ let(:object) do
6
+ CapsuleCRM::Website.new(web_address: Faker::Internet.domain_name)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ shared_examples 'capsule jsonable' do
2
+ subject { object.to_capsule_json }
3
+ let(:attributes) do
4
+ object.attributes.delete_if { |key, value| value.blank? }
5
+ end
6
+
7
+ if described_class.serializable_options.exclude_id == false
8
+ context 'when exclude_id is false' do
9
+ context "when the #{described_class} has an ID" do
10
+ before { object.id = Random.rand(1..100) }
11
+
12
+ it 'should include the ID' do
13
+ expect(subject.keys).to include('id')
14
+ end
15
+ end
16
+
17
+ context "when the #{described_class} has no ID" do
18
+ it 'should return a capsule compatible hash' do
19
+ expect(subject).
20
+ to eql(CapsuleCRM::HashHelper.camelize_keys(attributes))
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capsule_crm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Beedle
@@ -339,6 +339,7 @@ files:
339
339
  - spec/lib/capsule_crm/organization_spec.rb
340
340
  - spec/lib/capsule_crm/party_spec.rb
341
341
  - spec/lib/capsule_crm/person_spec.rb
342
+ - spec/lib/capsule_crm/phone_spec.rb
342
343
  - spec/lib/capsule_crm/serializer_spec.rb
343
344
  - spec/lib/capsule_crm/tag_spec.rb
344
345
  - spec/lib/capsule_crm/taggable_spec.rb
@@ -346,6 +347,7 @@ files:
346
347
  - spec/lib/capsule_crm/task_spec.rb
347
348
  - spec/lib/capsule_crm/track_spec.rb
348
349
  - spec/lib/capsule_crm/user_spec.rb
350
+ - spec/lib/capsule_crm/website_spec.rb
349
351
  - spec/spec_helper.rb
350
352
  - spec/support/all_cases.json
351
353
  - spec/support/all_categories.json
@@ -381,6 +383,7 @@ files:
381
383
  - spec/support/opportunity.json
382
384
  - spec/support/organisation.json
383
385
  - spec/support/person.json
386
+ - spec/support/shared_examples/capsule_json.rb
384
387
  - spec/support/shared_examples/contactable.rb
385
388
  - spec/support/shared_examples/deletable.rb
386
389
  - spec/support/shared_examples/find_all.rb
@@ -407,7 +410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
407
410
  version: '0'
408
411
  requirements: []
409
412
  rubyforge_project:
410
- rubygems_version: 2.2.0.rc.1
413
+ rubygems_version: 2.2.0
411
414
  signing_key:
412
415
  specification_version: 4
413
416
  summary: Gem to communicate with CapsuleCRM
@@ -444,6 +447,7 @@ test_files:
444
447
  - spec/lib/capsule_crm/organization_spec.rb
445
448
  - spec/lib/capsule_crm/party_spec.rb
446
449
  - spec/lib/capsule_crm/person_spec.rb
450
+ - spec/lib/capsule_crm/phone_spec.rb
447
451
  - spec/lib/capsule_crm/serializer_spec.rb
448
452
  - spec/lib/capsule_crm/tag_spec.rb
449
453
  - spec/lib/capsule_crm/taggable_spec.rb
@@ -451,6 +455,7 @@ test_files:
451
455
  - spec/lib/capsule_crm/task_spec.rb
452
456
  - spec/lib/capsule_crm/track_spec.rb
453
457
  - spec/lib/capsule_crm/user_spec.rb
458
+ - spec/lib/capsule_crm/website_spec.rb
454
459
  - spec/spec_helper.rb
455
460
  - spec/support/all_cases.json
456
461
  - spec/support/all_categories.json
@@ -486,6 +491,7 @@ test_files:
486
491
  - spec/support/opportunity.json
487
492
  - spec/support/organisation.json
488
493
  - spec/support/person.json
494
+ - spec/support/shared_examples/capsule_json.rb
489
495
  - spec/support/shared_examples/contactable.rb
490
496
  - spec/support/shared_examples/deletable.rb
491
497
  - spec/support/shared_examples/find_all.rb