capsule_crm 1.10.3 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/capsule_crm.gemspec +1 -1
- data/lib/capsule_crm/serializer.rb +1 -1
- data/lib/capsule_crm/taggable.rb +4 -2
- data/lib/capsule_crm/version.rb +1 -1
- data/spec/lib/capsule_crm/associations/has_many_association_spec.rb +1 -1
- data/spec/lib/capsule_crm/contacts_spec.rb +4 -4
- data/spec/lib/capsule_crm/custom_field_spec.rb +1 -1
- data/spec/lib/capsule_crm/history_spec.rb +91 -29
- data/spec/lib/capsule_crm/normalizer_spec.rb +2 -2
- data/spec/lib/capsule_crm/organization_spec.rb +1 -1
- data/spec/lib/capsule_crm/person_spec.rb +4 -4
- data/spec/lib/capsule_crm/serializer_spec.rb +12 -0
- data/spec/lib/capsule_crm/taggable_spec.rb +16 -3
- data/spec/support/one_tag.json +7 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 865ee033f500a769892f7e7483eeec3f4cd8b832
|
4
|
+
data.tar.gz: 2ede88b29d161c31525dc7fef8899c7cd2793240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed1b78da61e615596e3ab5be572ac9d90917a3d31ae672c709aaa954c363e03f9e7df543f2b6da8747a1eeef1a3b2d0544e0f853fd2704fbcdfb4434de139079
|
7
|
+
data.tar.gz: 3d73c58f3fcc18e162cf28ef0f9b096dd4b6d5844fa2f949341d7b93208737685f31052bca6a1e47e8e54f38ae120d21bd2bdbd22290d7da24ff129ce3bc113c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.10.4
|
4
|
+
|
5
|
+
- Use UTC when serializing times.
|
6
|
+
[#97](https://github.com/mattbeedle/capsule_crm/pull/97)
|
7
|
+
- Upgraded to RSpec ~> 2.99.0 and fixed deprecations in preparation for RSpec
|
8
|
+
3 upgrade
|
9
|
+
|
3
10
|
## 1.10.3
|
4
11
|
|
5
12
|
- Fix regression introduced in 1.10.1 where any records that do not respond
|
data/capsule_crm.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |gem|
|
|
34
34
|
gem.add_development_dependency('guard-bundler')
|
35
35
|
gem.add_development_dependency('guard-rspec')
|
36
36
|
gem.add_development_dependency('rb-fsevent')
|
37
|
-
gem.add_development_dependency('rspec', '~> 2.
|
37
|
+
gem.add_development_dependency('rspec', '~> 2.99.0')
|
38
38
|
gem.add_development_dependency('shoulda-matchers')
|
39
39
|
gem.add_development_dependency('webmock')
|
40
40
|
end
|
@@ -84,7 +84,7 @@ module CapsuleCRM
|
|
84
84
|
attrs.each do |key, value|
|
85
85
|
attrs[key] = value.to_s(:db) if value.is_a?(Date)
|
86
86
|
if value.is_a?(DateTime)
|
87
|
-
attrs[key] = value.strftime(
|
87
|
+
attrs[key] = value.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
88
88
|
end
|
89
89
|
end
|
90
90
|
additional_methods.each do |method|
|
data/lib/capsule_crm/taggable.rb
CHANGED
@@ -3,9 +3,11 @@ module CapsuleCRM
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
def tags
|
6
|
-
CapsuleCRM::Connection.get(
|
6
|
+
tags = CapsuleCRM::Connection.get(
|
7
7
|
"/api/#{api_singular_name}/#{id}/tag"
|
8
|
-
)['tags']['tag']
|
8
|
+
)['tags']['tag']
|
9
|
+
tags = [tags] if tags.is_a? Hash
|
10
|
+
tags.map { |item| CapsuleCRM::Tag.new(item) }
|
9
11
|
end
|
10
12
|
|
11
13
|
def add_tag(tag_name)
|
data/lib/capsule_crm/version.rb
CHANGED
@@ -81,7 +81,7 @@ describe CapsuleCRM::Contacts do
|
|
81
81
|
|
82
82
|
it do
|
83
83
|
subject.addresses.
|
84
|
-
all? { |address| address.is_a?(CapsuleCRM::Address) }.should
|
84
|
+
all? { |address| address.is_a?(CapsuleCRM::Address) }.should eql(true)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -92,7 +92,7 @@ describe CapsuleCRM::Contacts do
|
|
92
92
|
|
93
93
|
it do
|
94
94
|
subject.emails.
|
95
|
-
all? { |email| email.is_a?(CapsuleCRM::Email) }.should
|
95
|
+
all? { |email| email.is_a?(CapsuleCRM::Email) }.should eql(true)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -103,7 +103,7 @@ describe CapsuleCRM::Contacts do
|
|
103
103
|
|
104
104
|
it do
|
105
105
|
subject.phones.
|
106
|
-
all? { |phone| phone.is_a?(CapsuleCRM::Phone) }.should
|
106
|
+
all? { |phone| phone.is_a?(CapsuleCRM::Phone) }.should eql(true)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -114,7 +114,7 @@ describe CapsuleCRM::Contacts do
|
|
114
114
|
|
115
115
|
it do
|
116
116
|
subject.websites.
|
117
|
-
all? { |website| website.is_a?(CapsuleCRM::Website) }.should
|
117
|
+
all? { |website| website.is_a?(CapsuleCRM::Website) }.should eql(true)
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
@@ -69,7 +69,7 @@ describe CapsuleCRM::History do
|
|
69
69
|
it { should be_a(Array) }
|
70
70
|
|
71
71
|
it do
|
72
|
-
subject.all? { |item| item.is_a?(CapsuleCRM::History) }.should
|
72
|
+
subject.all? { |item| item.is_a?(CapsuleCRM::History) }.should eql(true)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -97,7 +97,7 @@ describe CapsuleCRM::History do
|
|
97
97
|
it { should be_a(Array) }
|
98
98
|
|
99
99
|
it do
|
100
|
-
subject.all? { |item| item.is_a?(CapsuleCRM::History) }.should
|
100
|
+
subject.all? { |item| item.is_a?(CapsuleCRM::History) }.should eql(true)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -125,7 +125,7 @@ describe CapsuleCRM::History do
|
|
125
125
|
it { should be_a(Array) }
|
126
126
|
|
127
127
|
it do
|
128
|
-
subject.all? { |item| item.is_a?(CapsuleCRM::History) }.should
|
128
|
+
subject.all? { |item| item.is_a?(CapsuleCRM::History) }.should eql(true)
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -150,25 +150,63 @@ describe CapsuleCRM::History do
|
|
150
150
|
end
|
151
151
|
subject { CapsuleCRM::History.find(100) }
|
152
152
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
153
|
+
it 'type is note' do
|
154
|
+
expect(subject.type).to eql('Note')
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'creator is a CapsuleCRM::User' do
|
158
|
+
expect(subject.creator).to be_a(CapsuleCRM::User)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'entry date is not blank' do
|
162
|
+
expect(subject.entry_date).not_to be_blank
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'subject is not blank' do
|
166
|
+
expect(subject.subject).not_to be_blank
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'note is not blank' do
|
170
|
+
expect(subject.note).not_to be_blank
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'attachments is an array' do
|
174
|
+
expect(subject.attachments).to be_a(Array)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'attachments array contains CapsuleCRM::Attachment objects' do
|
178
|
+
expect(first_attachment).to be_a(CapsuleCRM::Attachment)
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'has the correct attachment filename' do
|
182
|
+
expect(first_attachment.filename).to eql('latin.doc')
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'has an array of participants' do
|
186
|
+
expect(subject.participants).to be_a(Array)
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'has CapsuleCRM::Participant objects inside the participants array' do
|
190
|
+
expect(first_participant).to be_a(CapsuleCRM::Participant)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'has the correct participant names' do
|
194
|
+
expect(first_participant.name).to eql('Matt Beedle')
|
195
|
+
end
|
164
196
|
|
165
197
|
context 'when it belongs to a party' do
|
166
198
|
before do
|
167
199
|
stub_request(:get, /\/api\/party\/1$/).
|
168
200
|
to_return(body: File.read('spec/support/person.json'))
|
169
201
|
end
|
170
|
-
|
171
|
-
|
202
|
+
|
203
|
+
it 'has a party_id' do
|
204
|
+
expect(subject.party_id).not_to be_blank
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'has a party' do
|
208
|
+
expect(subject.party).not_to be_blank
|
209
|
+
end
|
172
210
|
end
|
173
211
|
|
174
212
|
context 'when it belongs to a case' do
|
@@ -177,8 +215,13 @@ describe CapsuleCRM::History do
|
|
177
215
|
to_return(body: File.read('spec/support/case.json'))
|
178
216
|
end
|
179
217
|
|
180
|
-
|
181
|
-
|
218
|
+
it 'has a case_id' do
|
219
|
+
expect(subject.case_id).not_to be_blank
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'has a case' do
|
223
|
+
expect(subject.case).not_to be_blank
|
224
|
+
end
|
182
225
|
end
|
183
226
|
|
184
227
|
context 'when it belongs to an opportunity' do
|
@@ -187,8 +230,13 @@ describe CapsuleCRM::History do
|
|
187
230
|
to_return(body: File.read('spec/support/opportunity.json'))
|
188
231
|
end
|
189
232
|
|
190
|
-
|
191
|
-
|
233
|
+
it 'has an opportunity_id' do
|
234
|
+
expect(subject.opportunity_id).not_to be_blank
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'has an opportunity' do
|
238
|
+
expect(subject.opportunity).not_to be_blank
|
239
|
+
end
|
192
240
|
end
|
193
241
|
end
|
194
242
|
|
@@ -205,13 +253,17 @@ describe CapsuleCRM::History do
|
|
205
253
|
context 'when the user exists' do
|
206
254
|
before { history.creator = 'a.user' }
|
207
255
|
|
208
|
-
|
256
|
+
it 'has a creator' do
|
257
|
+
expect(subject.creator).to be_a(CapsuleCRM::User)
|
258
|
+
end
|
209
259
|
end
|
210
260
|
|
211
261
|
context 'when the user does not exist' do
|
212
262
|
before { history.creator = 'asdfadsfdsaf' }
|
213
263
|
|
214
|
-
|
264
|
+
it 'has no creator' do
|
265
|
+
expect(subject.creator).to be_blank
|
266
|
+
end
|
215
267
|
end
|
216
268
|
end
|
217
269
|
|
@@ -219,7 +271,9 @@ describe CapsuleCRM::History do
|
|
219
271
|
let(:user) { CapsuleCRM::User.new }
|
220
272
|
before { history.creator = user }
|
221
273
|
|
222
|
-
|
274
|
+
it 'has a creator' do
|
275
|
+
expect(subject.creator).to eql(user)
|
276
|
+
end
|
223
277
|
end
|
224
278
|
end
|
225
279
|
|
@@ -241,13 +295,21 @@ describe CapsuleCRM::History do
|
|
241
295
|
let(:participants_json) { subject[:historyItem]['participants'] }
|
242
296
|
subject { history.to_capsule_json }
|
243
297
|
|
244
|
-
it
|
245
|
-
|
298
|
+
it 'has historyItem as the first key' do
|
299
|
+
expect(subject.keys.first).to eql('historyItem')
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'has the correct history item entry date' do
|
246
303
|
expect(subject['historyItem']['entryDate']).
|
247
|
-
to eql(history.entry_date.strftime(
|
304
|
+
to eql(history.entry_date.utc.strftime('%Y-%m-%dT%H:%M:%SZ'))
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'has the correct history item creator' do
|
308
|
+
expect(subject['historyItem']['creator']).to eql(creator.username)
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'has the correct history item note' do
|
312
|
+
expect(subject['historyItem']['note']).to eql(history.note)
|
248
313
|
end
|
249
|
-
it { expect(subject['historyItem']['creator']).to eql(creator.username) }
|
250
|
-
it { expect(subject['historyItem']['note']).to eql(history.note) }
|
251
|
-
it { expect(subject['historyItem']).to have_key('note') }
|
252
314
|
end
|
253
315
|
end
|
@@ -155,13 +155,13 @@ describe CapsuleCRM::Person do
|
|
155
155
|
subject { person.send(:first_name_required?) }
|
156
156
|
|
157
157
|
context 'when there is no last name' do
|
158
|
-
it { should
|
158
|
+
it { should eql(true) }
|
159
159
|
end
|
160
160
|
|
161
161
|
context 'when there is a last name' do
|
162
162
|
before { person.last_name = 'Beedle' }
|
163
163
|
|
164
|
-
it { should
|
164
|
+
it { should eql(false) }
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
@@ -171,13 +171,13 @@ describe CapsuleCRM::Person do
|
|
171
171
|
subject { person.send(:last_name_required?) }
|
172
172
|
|
173
173
|
context 'when there is no first name' do
|
174
|
-
it { should
|
174
|
+
it { should eql(true) }
|
175
175
|
end
|
176
176
|
|
177
177
|
context 'when there is a first name' do
|
178
178
|
before { person.first_name = 'Matt' }
|
179
179
|
|
180
|
-
it { should
|
180
|
+
it { should eql(false) }
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
@@ -8,6 +8,7 @@ class SerializableTest
|
|
8
8
|
attribute :name
|
9
9
|
attribute :description
|
10
10
|
attribute :something, Date
|
11
|
+
attribute :a_timestamp, DateTime
|
11
12
|
end
|
12
13
|
|
13
14
|
class SerializableInverse
|
@@ -130,5 +131,16 @@ describe CapsuleCRM::Serializer do
|
|
130
131
|
to eql(Date.today.to_s(:db))
|
131
132
|
end
|
132
133
|
end
|
134
|
+
|
135
|
+
context 'when there are datetimes' do
|
136
|
+
let(:time) { Time.now }
|
137
|
+
|
138
|
+
before { object.a_timestamp = time }
|
139
|
+
|
140
|
+
it 'uses the UTC time' do
|
141
|
+
expect(subject['serializabletest']['aTimestamp'])
|
142
|
+
.to eql(time.utc.strftime('%Y-%m-%dT%H:%M:%SZ'))
|
143
|
+
end
|
144
|
+
end
|
133
145
|
end
|
134
146
|
end
|
@@ -28,12 +28,25 @@ describe CapsuleCRM::Taggable do
|
|
28
28
|
it { subject.length.should eql(2) }
|
29
29
|
|
30
30
|
it do
|
31
|
-
subject.all? { |item| item.is_a?(CapsuleCRM::Tag) }.should
|
31
|
+
subject.all? { |item| item.is_a?(CapsuleCRM::Tag) }.should eql(true)
|
32
32
|
end
|
33
33
|
|
34
34
|
it { subject.first.name.should eql('Customer') }
|
35
35
|
|
36
36
|
it { subject.last.name.should eql('VIP') }
|
37
|
+
|
38
|
+
context 'when taggable item has one tag' do
|
39
|
+
before do
|
40
|
+
stub_request(:get, /\/api\/taggableitem\/2\/tag$/).
|
41
|
+
to_return(body: File.read('spec/support/one_tag.json'))
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:taggable_item) { TaggableItem.new(id: 2) }
|
45
|
+
|
46
|
+
subject { taggable_item.tags }
|
47
|
+
|
48
|
+
it { should be_a(Array) }
|
49
|
+
end
|
37
50
|
end
|
38
51
|
|
39
52
|
describe '#add_tag' do
|
@@ -48,7 +61,7 @@ describe CapsuleCRM::Taggable do
|
|
48
61
|
|
49
62
|
subject { taggable_item.add_tag 'A Test Tag' }
|
50
63
|
|
51
|
-
it { subject.should
|
64
|
+
it { subject.should eql(true) }
|
52
65
|
end
|
53
66
|
|
54
67
|
context 'when the taggable item has no id' do
|
@@ -73,7 +86,7 @@ describe CapsuleCRM::Taggable do
|
|
73
86
|
to_return(headers: { 'Location' => loc })
|
74
87
|
end
|
75
88
|
|
76
|
-
it { subject.should
|
89
|
+
it { subject.should eql(true) }
|
77
90
|
end
|
78
91
|
|
79
92
|
context 'when the taggable item has no id' do
|
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: 1.10.
|
4
|
+
version: 1.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Beedle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -212,14 +212,14 @@ dependencies:
|
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: 2.
|
215
|
+
version: 2.99.0
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: 2.
|
222
|
+
version: 2.99.0
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: shoulda-matchers
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -401,6 +401,7 @@ files:
|
|
401
401
|
- spec/support/no_tasks.json
|
402
402
|
- spec/support/no_tracks.json
|
403
403
|
- spec/support/no_users.json
|
404
|
+
- spec/support/one_tag.json
|
404
405
|
- spec/support/opportunity.json
|
405
406
|
- spec/support/organisation.json
|
406
407
|
- spec/support/person.json
|
@@ -514,6 +515,7 @@ test_files:
|
|
514
515
|
- spec/support/no_tasks.json
|
515
516
|
- spec/support/no_tracks.json
|
516
517
|
- spec/support/no_users.json
|
518
|
+
- spec/support/one_tag.json
|
517
519
|
- spec/support/opportunity.json
|
518
520
|
- spec/support/organisation.json
|
519
521
|
- spec/support/person.json
|