capsule_crm 0.10.0 → 0.10.2

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: 8f08b4e0897c37f8539c3dc0fcde24c91c374d7f
4
- data.tar.gz: 810a9aa84d4c3a2b8fd2fd855c68b65d9315dfc5
3
+ metadata.gz: fe0200eaa38f56d70ebe6aac7a0753b881cd57d5
4
+ data.tar.gz: 3fddf33fe50156ea8949b456dd072544e01d2b59
5
5
  SHA512:
6
- metadata.gz: 6c2ded3a643e2d174a0bc0b03c0a238434734f8320f85855994af9374abc86cb1a9d59358bb949c70b7830fec342c5f89aa9540bd97b9b2188b55e77a15c9067
7
- data.tar.gz: ba7401ac676e2ae7130929c30522b448374d37b6f2be8c5f9133e8590cae2170468680f77c1b21a24c2df2ba6b91de4ffa9f265938a9aa5c81440c053715696e
6
+ metadata.gz: 186db3ab34a48f0417c7a50e31b7f77952a12a39c7e1053c1889c9a0e83b3299308899d308d8357e4fcd6dafdb23b5092267a98f90df01ef9bf95f06398bfc90
7
+ data.tar.gz: 0def9e908692cad017f50a03c8d8d88abdc9362e79ae7f1f4c5fa3d2413e18ffc0a019ad9c6b621b2675dbb48e22e8a124116125274fa353b18c83fb2c11484e
@@ -20,7 +20,8 @@ module CapsuleCRM
20
20
  validates :name, presence: true
21
21
 
22
22
  has_many :people, class_name: 'CapsuleCRM::Person', source: :organization
23
- has_many :custom_fields, class_name: 'CapsuleCRM::CustomField', source: :organization
23
+ has_many :custom_fields, class_name: 'CapsuleCRM::CustomField',
24
+ source: :organization
24
25
 
25
26
  # Public: Get all people from Capsule. The list can be restricted
26
27
  # and/or paginated with various query parameters sent through the options
@@ -44,10 +45,8 @@ module CapsuleCRM
44
45
  #
45
46
  # Returns a ResultsProxy of organisations
46
47
  def self.all(options = {})
47
- init_collection(
48
- CapsuleCRM::Connection.
49
- get('/api/party', options)['parties']['organisation']
50
- )
48
+ CapsuleCRM::Party.all(options).
49
+ delete_if { |item| !item.is_a?(CapsuleCRM::Organization) }
51
50
  end
52
51
 
53
52
  # Public: Get an organization by ID
@@ -9,7 +9,9 @@ class CapsuleCRM::Party
9
9
  has_many :tasks, class_name: 'CapsuleCRM::Task', source: :party
10
10
 
11
11
  def self.all(options = {})
12
+ process_options(options)
12
13
  attributes = CapsuleCRM::Connection.get('/api/party', options)
14
+
13
15
  init_collection(attributes['parties'])
14
16
  end
15
17
 
@@ -25,6 +27,7 @@ class CapsuleCRM::Party
25
27
  def self.init_collection(collection)
26
28
  CapsuleCRM::ResultsProxy.new(
27
29
  collection.map do |key, value|
30
+ next unless %w(organisation person).include?(key)
28
31
  [collection[key]].flatten.map do |attrs|
29
32
  party_classes[key].constantize.new(attrs)
30
33
  end.flatten
@@ -33,9 +36,14 @@ class CapsuleCRM::Party
33
36
  end
34
37
 
35
38
  def self.party_classes
36
- {
37
- person: 'CapsuleCRM::Person',
38
- organisation: 'CapsuleCRM::Organization'
39
- }.stringify_keys
39
+ { person: 'CapsuleCRM::Person', organisation: 'CapsuleCRM::Organization' }.
40
+ stringify_keys
41
+ end
42
+
43
+ def self.process_options(options)
44
+ if options[:lastmodified] && options[:lastmodified].respond_to?(:strftime)
45
+ options[:lastmodified] = options[:lastmodified].
46
+ strftime("%Y%m%dT%H%M%SZ")
47
+ end
40
48
  end
41
49
  end
@@ -54,10 +54,8 @@ module CapsuleCRM
54
54
  #
55
55
  # Returns a ResultsProxy of organisations
56
56
  def self.all(options = {})
57
- init_collection(
58
- CapsuleCRM::Connection.
59
- get('/api/party', options)['parties']['person']
60
- )
57
+ CapsuleCRM::Party.all(options).
58
+ delete_if { |item| !item.is_a?(CapsuleCRM::Person) }
61
59
  end
62
60
 
63
61
  # Public: Create a new person in capsulecrm
@@ -1,3 +1,3 @@
1
1
  module CapsuleCrm
2
- VERSION = '0.10.0'
2
+ VERSION = '0.10.2'
3
3
  end
@@ -110,7 +110,7 @@ describe CapsuleCRM::Case do
110
110
 
111
111
  it { expect(subject).to be_persisted }
112
112
 
113
- it do
113
+ it 'should add the trackId to the URI' do
114
114
  subject
115
115
  expect(WebMock).
116
116
  to have_requested(:post, "#{request_uri}?trackId=#{track.id}")
@@ -11,6 +11,36 @@ describe CapsuleCRM::Organization do
11
11
  to_return(body: File.read('spec/support/all_users.json'))
12
12
  end
13
13
 
14
+ describe '.all' do
15
+ context 'when some parties exist' do
16
+ before do
17
+ stub_request(:get, /\/api\/party$/).
18
+ to_return(body: File.read('spec/support/all_parties.json'))
19
+ end
20
+
21
+ subject { CapsuleCRM::Organization.all }
22
+
23
+ it { expect(subject).to be_a(Array) }
24
+
25
+ it { expect(subject.length).to eql(1) }
26
+
27
+ it { expect(subject.first).to be_a(CapsuleCRM::Organization) }
28
+ end
29
+
30
+ context 'when no parties exist' do
31
+ before do
32
+ stub_request(:get, /\/api\/party$/).
33
+ to_return(body: File.read('spec/support/no_parties.json'))
34
+ end
35
+
36
+ subject { CapsuleCRM::Organization.all }
37
+
38
+ it { expect(subject).to be_a(Array) }
39
+
40
+ it { expect(subject.length).to eql(0) }
41
+ end
42
+ end
43
+
14
44
  describe '#people' do
15
45
  let(:organization) { Fabricate.build(:organization, id: 1) }
16
46
 
@@ -0,0 +1,3 @@
1
+ {
2
+ "parties": { "@size": "0" }
3
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capsule_crm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Beedle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-24 00:00:00.000000000 Z
11
+ date: 2013-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -334,6 +334,7 @@ files:
334
334
  - spec/support/milestones.json
335
335
  - spec/support/no_customfields.json
336
336
  - spec/support/no_history.json
337
+ - spec/support/no_parties.json
337
338
  - spec/support/opportunity.json
338
339
  - spec/support/organisation.json
339
340
  - spec/support/person.json
@@ -412,6 +413,7 @@ test_files:
412
413
  - spec/support/milestones.json
413
414
  - spec/support/no_customfields.json
414
415
  - spec/support/no_history.json
416
+ - spec/support/no_parties.json
415
417
  - spec/support/opportunity.json
416
418
  - spec/support/organisation.json
417
419
  - spec/support/person.json