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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/capsule_crm/address.rb +8 -6
- data/lib/capsule_crm/email.rb +2 -0
- data/lib/capsule_crm/phone.rb +4 -2
- data/lib/capsule_crm/serializer.rb +6 -1
- data/lib/capsule_crm/version.rb +1 -1
- data/lib/capsule_crm/website.rb +5 -3
- data/spec/lib/capsule_crm/address_spec.rb +5 -0
- data/spec/lib/capsule_crm/email_spec.rb +3 -0
- data/spec/lib/capsule_crm/phone_spec.rb +7 -0
- data/spec/lib/capsule_crm/serializer_spec.rb +8 -0
- data/spec/lib/capsule_crm/website_spec.rb +9 -0
- data/spec/support/shared_examples/capsule_json.rb +25 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a971137b1c0c66a676abb680757dd95d181483a
|
4
|
+
data.tar.gz: 9df7cb48de8496c48b9201afa44558e786433ffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 870dfbbc6202b575235e02ba4a8902dea7bca317b70d2bd7a79fa6e563da3582071133a97b21ef1718556d0e8b4ef196430a7f68d1ff4dc3151dc042084c6264
|
7
|
+
data.tar.gz: bb6fe469ff5993c9e12bcb33444548402bda97112a3ff44fc632e9ba7810bfa2784f4cbd923fd3d500b6d265eac9987547a49b1c9923a36665652185f467c5c7
|
data/CHANGELOG.md
CHANGED
data/lib/capsule_crm/address.rb
CHANGED
@@ -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 :
|
12
|
-
attribute :
|
13
|
-
attribute :
|
14
|
-
attribute :
|
15
|
-
attribute :
|
16
|
-
attribute :
|
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
|
data/lib/capsule_crm/email.rb
CHANGED
data/lib/capsule_crm/phone.rb
CHANGED
@@ -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 :
|
12
|
-
attribute :
|
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'
|
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|
|
data/lib/capsule_crm/version.rb
CHANGED
data/lib/capsule_crm/website.rb
CHANGED
@@ -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 :
|
14
|
-
attribute :
|
15
|
-
attribute :
|
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
|
|
@@ -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,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.
|
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
|
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
|