capsule_crm 0.10.4 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/README.md +7 -1
- data/capsule_crm.gemspec +1 -1
- data/lib/capsule_crm.rb +1 -0
- data/lib/capsule_crm/connection.rb +22 -22
- data/lib/capsule_crm/errors/unauthorized.rb +11 -0
- data/lib/capsule_crm/version.rb +1 -1
- data/spec/lib/capsule_crm/connection_spec.rb +13 -0
- data/spec/lib/capsule_crm/history_spec.rb +60 -121
- metadata +43 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e6a15562202d4d1a360a5beeb9d8918c7eb5e7e
|
4
|
+
data.tar.gz: 63a2206a1f4c450e50df285cbec99514648a9829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68511e44926bb512b68e06419975305a3e1e940b4805b37b6cc4b3b378cee42dc44da112935e5d22bf83136055ce3fb1fa8c1a18179742c0299fa2ddf33461bb
|
7
|
+
data.tar.gz: c0aec7b22bc4ab680edaf83a5e52f67cbf81af988680b1e8c072012f936fc9275076eaf60fda178801f465114cc93c2e3ef658f9eb71669339c650027e8e05b9
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -15,6 +15,12 @@ Ready](http://badge.waffle.io/mattbeedle/capsule_crm.png)](http://waffle.io/matt
|
|
15
15
|
|
16
16
|
CapsuleCRM provides an ActiveModel compliant interface to the capsulecrm API
|
17
17
|
|
18
|
+
## Versioning
|
19
|
+
|
20
|
+
This project follows [semver](http://semver.org/spec/v2.0.0.html) so there will
|
21
|
+
be no breaking changes in minor/patch version changes. It is pre 1.0
|
22
|
+
though, so it's not finished and expect to find bugs.
|
23
|
+
|
18
24
|
## Installation
|
19
25
|
|
20
26
|
Add this line to your application's Gemfile:
|
@@ -304,7 +310,7 @@ CapsuleCRM::Currency.all
|
|
304
310
|
|
305
311
|
## Supported Rubies
|
306
312
|
|
307
|
-
1.9.
|
313
|
+
1.9.3, 2.0, jruby-19mode
|
308
314
|
|
309
315
|
## Feedback
|
310
316
|
|
data/capsule_crm.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |gem|
|
|
33
33
|
gem.add_development_dependency('guard-bundler')
|
34
34
|
gem.add_development_dependency('guard-rspec')
|
35
35
|
gem.add_development_dependency('rb-fsevent')
|
36
|
-
gem.add_development_dependency('rspec')
|
36
|
+
gem.add_development_dependency('rspec', '~> 2.14.0')
|
37
37
|
gem.add_development_dependency('shoulda-matchers')
|
38
38
|
gem.add_development_dependency('webmock')
|
39
39
|
end
|
data/lib/capsule_crm.rb
CHANGED
@@ -25,6 +25,7 @@ require 'capsule_crm/website'
|
|
25
25
|
require 'capsule_crm/hash_helper'
|
26
26
|
require 'capsule_crm/results_proxy'
|
27
27
|
require 'capsule_crm/errors/record_invalid'
|
28
|
+
require 'capsule_crm/errors/unauthorized'
|
28
29
|
require 'capsule_crm/contacts'
|
29
30
|
require 'capsule_crm/contactable'
|
30
31
|
require 'capsule_crm/configuration'
|
@@ -9,33 +9,37 @@ module CapsuleCRM
|
|
9
9
|
# Returns a Hash from the JSON response
|
10
10
|
def self.get(path, params = {})
|
11
11
|
preprocess_params(params)
|
12
|
-
|
13
|
-
req.headers.update default_request_headers
|
14
|
-
end
|
15
|
-
JSON.parse response.body
|
12
|
+
JSON.parse request(:get, path, params).body
|
16
13
|
end
|
17
14
|
|
18
15
|
def self.post(path, params = {})
|
19
|
-
|
20
|
-
request.headers.update default_request_headers
|
21
|
-
end
|
22
|
-
process_post_response(response)
|
16
|
+
process_post_response request(:post, path, params)
|
23
17
|
end
|
24
18
|
|
25
19
|
def self.put(path, params)
|
26
|
-
|
27
|
-
request.headers.update default_request_headers
|
28
|
-
end.success?
|
20
|
+
request(:put, path, params.to_json).success?
|
29
21
|
end
|
30
22
|
|
31
23
|
def self.delete(path)
|
32
|
-
|
33
|
-
request.headers.update default_request_headers
|
34
|
-
end.success?
|
24
|
+
request(:delete, path, {}).success?
|
35
25
|
end
|
36
26
|
|
37
27
|
private
|
38
28
|
|
29
|
+
def self.request(method, path, params)
|
30
|
+
faraday.send(method, path, params) do |req|
|
31
|
+
req.headers.update default_request_headers
|
32
|
+
end.tap do |response|
|
33
|
+
check_response_status(response)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.check_response_status(response)
|
38
|
+
if response.status == 401
|
39
|
+
raise CapsuleCRM::Errors::Unauthorized.new(response)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
39
43
|
def self.preprocess_params(params)
|
40
44
|
params.symbolize_keys!
|
41
45
|
if params_contains_lastmodified(params)
|
@@ -50,15 +54,11 @@ module CapsuleCRM
|
|
50
54
|
|
51
55
|
# TODO clean this shit up
|
52
56
|
def self.process_post_response(response)
|
53
|
-
if response.
|
54
|
-
|
55
|
-
|
56
|
-
{ id: match[:id] }
|
57
|
-
else
|
58
|
-
true
|
59
|
-
end
|
57
|
+
if response.headers['Location'] &&
|
58
|
+
match = response.headers['Location'].match(/\/(?<id>\d+)$/)
|
59
|
+
{ id: match[:id] }
|
60
60
|
else
|
61
|
-
|
61
|
+
true
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/lib/capsule_crm/version.rb
CHANGED
@@ -17,5 +17,18 @@ describe CapsuleCRM::Connection do
|
|
17
17
|
).with(query: { lastmodified: "20131001T133156" })
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
context 'when the request is not authorized' do
|
22
|
+
before do
|
23
|
+
stub_request(:get, /\/api\/v1\/foo/).
|
24
|
+
to_return(status: 401, body: '<html></html>')
|
25
|
+
end
|
26
|
+
subject { CapsuleCRM::Connection.get('/api/v1/food') }
|
27
|
+
|
28
|
+
it 'should raise an Unauthorized error' do
|
29
|
+
expect { CapsuleCRM::Connection.get('/api/v1/foo') }.
|
30
|
+
to raise_error(CapsuleCRM::Errors::Unauthorized)
|
31
|
+
end
|
32
|
+
end
|
20
33
|
end
|
21
34
|
end
|
@@ -97,46 +97,35 @@ describe CapsuleCRM::History do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
describe 'find' do
|
100
|
+
let(:first_attachment) { subject.attachments.first }
|
101
|
+
let(:first_participant) { subject.participants.first }
|
100
102
|
before do
|
101
103
|
stub_request(:get, /\/api\/history\/100$/).
|
102
104
|
to_return(body: File.read('spec/support/history.json'))
|
103
105
|
stub_request(:get, /\/api\/users$/).
|
104
106
|
to_return(body: File.read('spec/support/all_users.json'))
|
105
107
|
end
|
106
|
-
|
107
108
|
subject { CapsuleCRM::History.find(100) }
|
108
109
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
it {
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
it {
|
120
|
-
|
121
|
-
it { subject.attachments.first.should be_a(CapsuleCRM::Attachment) }
|
122
|
-
|
123
|
-
it { subject.attachments.first.filename.should eql('latin.doc') }
|
124
|
-
|
125
|
-
it { subject.participants.should be_a(Array) }
|
126
|
-
|
127
|
-
it { subject.participants.first.should be_a(CapsuleCRM::Participant) }
|
128
|
-
|
129
|
-
it { subject.participants.first.name.should eql('Matt Beedle') }
|
110
|
+
its(:type) { should eql('Note') }
|
111
|
+
its(:creator) { should be_a(CapsuleCRM::User) }
|
112
|
+
its(:entry_date) { should_not be_blank }
|
113
|
+
its(:subject) { should_not be_blank }
|
114
|
+
its(:note) { should_not be_blank }
|
115
|
+
its(:attachments) { should be_a(Array) }
|
116
|
+
it { expect(first_attachment).to be_a(CapsuleCRM::Attachment) }
|
117
|
+
it { expect(first_attachment.filename).to eql('latin.doc') }
|
118
|
+
its(:participants) { should be_a(Array) }
|
119
|
+
it { expect(first_participant).to be_a(CapsuleCRM::Participant) }
|
120
|
+
it { expect(first_participant.name).to eql('Matt Beedle') }
|
130
121
|
|
131
122
|
context 'when it belongs to a party' do
|
132
123
|
before do
|
133
124
|
stub_request(:get, /\/api\/party\/1$/).
|
134
125
|
to_return(body: File.read('spec/support/person.json'))
|
135
126
|
end
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
it { subject.party.should_not be_blank }
|
127
|
+
its(:party_id) { should_not be_blank }
|
128
|
+
its(:party) { should_not be_blank }
|
140
129
|
end
|
141
130
|
|
142
131
|
context 'when it belongs to a case' do
|
@@ -145,9 +134,8 @@ describe CapsuleCRM::History do
|
|
145
134
|
to_return(body: File.read('spec/support/case.json'))
|
146
135
|
end
|
147
136
|
|
148
|
-
|
149
|
-
|
150
|
-
it { subject.kase.should_not be_blank }
|
137
|
+
its(:case_id) { should_not be_blank }
|
138
|
+
its(:kase) { should_not be_blank }
|
151
139
|
end
|
152
140
|
|
153
141
|
context 'when it belongs to an opportunity' do
|
@@ -156,14 +144,14 @@ describe CapsuleCRM::History do
|
|
156
144
|
to_return(body: File.read('spec/support/opportunity.json'))
|
157
145
|
end
|
158
146
|
|
159
|
-
|
160
|
-
|
161
|
-
it { subject.opportunity.should_not be_blank }
|
147
|
+
its(:opportunity_id) { should_not be_blank }
|
148
|
+
its(:opportunity) { should_not be_blank }
|
162
149
|
end
|
163
150
|
end
|
164
151
|
|
165
152
|
describe '#creator=' do
|
166
153
|
let(:history) { CapsuleCRM::History.new }
|
154
|
+
subject { history }
|
167
155
|
|
168
156
|
context 'when a String is supplied' do
|
169
157
|
before do
|
@@ -174,88 +162,78 @@ describe CapsuleCRM::History do
|
|
174
162
|
context 'when the user exists' do
|
175
163
|
before { history.creator = 'a.user' }
|
176
164
|
|
177
|
-
|
165
|
+
its(:creator) { should be_a(CapsuleCRM::User) }
|
178
166
|
end
|
179
167
|
|
180
168
|
context 'when the user does not exist' do
|
181
169
|
before { history.creator = 'asdfadsfdsaf' }
|
182
170
|
|
183
|
-
|
171
|
+
its(:creator) { should be_blank }
|
184
172
|
end
|
185
173
|
end
|
186
174
|
|
187
175
|
context 'when a CapsuleCRM::Person is supplied' do
|
188
176
|
let(:user) { CapsuleCRM::User.new }
|
189
|
-
|
190
177
|
before { history.creator = user }
|
191
178
|
|
192
|
-
|
179
|
+
its(:creator) { should eql(user) }
|
193
180
|
end
|
194
181
|
end
|
195
182
|
|
196
183
|
describe '.create' do
|
197
184
|
context 'when it belongs to a party' do
|
198
185
|
let(:person) { Fabricate.build(:person, id: 1) }
|
199
|
-
|
200
186
|
subject do
|
201
187
|
CapsuleCRM::History.create(
|
202
188
|
note: Faker::Lorem.paragraph, party: person
|
203
189
|
)
|
204
190
|
end
|
205
|
-
|
206
191
|
let(:location) do
|
207
192
|
"https://sample.capsulecrm.com/api/party/#{person.id}/history/101"
|
208
193
|
end
|
209
|
-
|
210
194
|
before do
|
211
195
|
stub_request(:post, /\/api\/party\/#{person.id}\/history$/).
|
212
196
|
to_return(headers: { 'Location' => location})
|
213
197
|
end
|
214
198
|
|
215
|
-
|
199
|
+
its(:id) { should eql(101) }
|
216
200
|
end
|
217
201
|
|
218
202
|
context 'when it belongs to a kase' do
|
219
203
|
let(:kase) { Fabricate.build(:case, id: 2) }
|
220
|
-
|
221
204
|
let(:location) do
|
222
205
|
"https://sample.capsulecrm.com/api/kase/#{kase.id}/history/10"
|
223
206
|
end
|
224
|
-
|
225
207
|
subject do
|
226
208
|
CapsuleCRM::History.create(note: Faker::Lorem.paragraph, kase: kase)
|
227
209
|
end
|
228
|
-
|
229
210
|
before do
|
230
211
|
stub_request(:post, /\/api\/kase\/#{kase.id}\/history$/).
|
231
212
|
to_return(headers: { 'Location' => location })
|
232
213
|
end
|
233
214
|
|
234
|
-
|
215
|
+
its(:id) { should eql(10) }
|
235
216
|
end
|
236
217
|
|
237
218
|
context 'when it belongs to an opportunity' do
|
238
219
|
let(:opportunity) { Fabricate.build(:opportunity, id: 1) }
|
239
|
-
|
240
220
|
subject do
|
241
221
|
CapsuleCRM::History.create(
|
242
222
|
note: Faker::Lorem.paragraph, opportunity: opportunity
|
243
223
|
)
|
244
224
|
end
|
245
|
-
|
246
225
|
let(:location) do
|
247
226
|
[
|
248
227
|
'https://sample.capsulecrm.com/api/opportunity/',
|
249
228
|
opportunity.id, '/history/9'
|
250
229
|
].join
|
251
230
|
end
|
252
|
-
|
253
231
|
before do
|
254
232
|
stub_request(:post, /\/api\/opportunity\/#{opportunity.id}\/history$/).
|
255
233
|
to_return(headers: { 'Location' => location })
|
256
234
|
end
|
257
235
|
|
258
|
-
|
236
|
+
its(:id) { should eql(9) }
|
259
237
|
end
|
260
238
|
|
261
239
|
context 'when it is invalid' do
|
@@ -268,66 +246,57 @@ describe CapsuleCRM::History do
|
|
268
246
|
describe '.create!' do
|
269
247
|
context 'when it belongs to a party' do
|
270
248
|
let(:person) { Fabricate.build(:person, id: 1) }
|
271
|
-
|
272
249
|
subject do
|
273
250
|
CapsuleCRM::History.create!(
|
274
251
|
note: Faker::Lorem.paragraph, party: person
|
275
252
|
)
|
276
253
|
end
|
277
|
-
|
278
254
|
let(:location) do
|
279
255
|
"https://sample.capsulecrm.com/api/party/#{person.id}/history/101"
|
280
256
|
end
|
281
|
-
|
282
257
|
before do
|
283
258
|
stub_request(:post, /\/api\/party\/#{person.id}\/history$/).
|
284
259
|
to_return(headers: { 'Location' => location})
|
285
260
|
end
|
286
261
|
|
287
|
-
|
262
|
+
its(:id) { should eql(101) }
|
288
263
|
end
|
289
264
|
|
290
265
|
context 'when it belongs to a kase' do
|
291
266
|
let(:kase) { Fabricate.build(:case, id: 2) }
|
292
|
-
|
293
267
|
let(:location) do
|
294
268
|
"https://sample.capsulecrm.com/api/kase/#{kase.id}/history/10"
|
295
269
|
end
|
296
|
-
|
297
270
|
subject do
|
298
271
|
CapsuleCRM::History.create!(note: Faker::Lorem.paragraph, kase: kase)
|
299
272
|
end
|
300
|
-
|
301
273
|
before do
|
302
274
|
stub_request(:post, /\/api\/kase\/#{kase.id}\/history$/).
|
303
275
|
to_return(headers: { 'Location' => location })
|
304
276
|
end
|
305
277
|
|
306
|
-
|
278
|
+
its(:id) { should eql(10) }
|
307
279
|
end
|
308
280
|
|
309
281
|
context 'when it belongs to an opportunity' do
|
310
282
|
let(:opportunity) { Fabricate.build(:opportunity, id: 1) }
|
311
|
-
|
312
283
|
subject do
|
313
284
|
CapsuleCRM::History.create!(
|
314
285
|
note: Faker::Lorem.paragraph, opportunity: opportunity
|
315
286
|
)
|
316
287
|
end
|
317
|
-
|
318
288
|
let(:location) do
|
319
289
|
[
|
320
290
|
'https://sample.capsulecrm.com/api/opportunity/',
|
321
291
|
opportunity.id, '/history/9'
|
322
292
|
].join
|
323
293
|
end
|
324
|
-
|
325
294
|
before do
|
326
295
|
stub_request(:post, /\/api\/opportunity\/#{opportunity.id}\/history$/).
|
327
296
|
to_return(headers: { 'Location' => location })
|
328
297
|
end
|
329
298
|
|
330
|
-
|
299
|
+
its(:id) { should eql(9) }
|
331
300
|
end
|
332
301
|
|
333
302
|
context 'when it is invalid' do
|
@@ -341,39 +310,32 @@ describe CapsuleCRM::History do
|
|
341
310
|
describe '#update_attributes' do
|
342
311
|
context 'when the history is valid' do
|
343
312
|
subject { Fabricate(:history, id: 2, party: Fabricate.build(:person)) }
|
344
|
-
|
345
313
|
before do
|
346
314
|
stub_request(:put, /api\/history\/2$/).to_return(status: 200)
|
347
315
|
subject.update_attributes note: 'changed note text'
|
348
316
|
end
|
349
317
|
|
350
|
-
|
351
|
-
|
318
|
+
its(:note) { should eql('changed note text') }
|
352
319
|
it { should be_persisted }
|
353
320
|
end
|
354
321
|
|
355
322
|
context 'when the history is not valid' do
|
356
|
-
subject
|
357
|
-
CapsuleCRM::History.new(id: 2)
|
358
|
-
end
|
359
|
-
|
323
|
+
subject { CapsuleCRM::History.new(id: 2) }
|
360
324
|
before { subject.update_attributes subject: Faker::Lorem.sentence }
|
361
325
|
|
362
|
-
it {
|
326
|
+
it { should_not be_valid }
|
363
327
|
end
|
364
328
|
end
|
365
329
|
|
366
330
|
describe '#update_attributes!' do
|
367
331
|
context 'when it is valid' do
|
368
332
|
subject { Fabricate(:history, id: 3, party: Fabricate.build(:case)) }
|
369
|
-
|
370
333
|
before do
|
371
334
|
stub_request(:put, /api\/history\/3$/).to_return(status: 200)
|
372
335
|
subject.update_attributes! note: 'some new note'
|
373
336
|
end
|
374
337
|
|
375
|
-
|
376
|
-
|
338
|
+
its(:note) { should eql('some new note') }
|
377
339
|
it { should be_persisted }
|
378
340
|
end
|
379
341
|
|
@@ -393,52 +355,46 @@ describe CapsuleCRM::History do
|
|
393
355
|
|
394
356
|
context 'when it belongs to a party' do
|
395
357
|
let(:party) { Fabricate.build(:organization, id: 2) }
|
396
|
-
|
397
358
|
let(:location) do
|
398
359
|
"https://sample.capsulecrm.com/api/party/#{party.id}/history/101"
|
399
360
|
end
|
400
|
-
|
401
361
|
before do
|
402
362
|
history.party = party
|
403
363
|
stub_request(:post, /\/api\/party\/#{party.id}\/history$/).
|
404
364
|
to_return(headers: { 'Location' => location })
|
405
365
|
history.save
|
406
366
|
end
|
367
|
+
subject { history }
|
407
368
|
|
408
|
-
|
409
|
-
|
369
|
+
its(:id) { should eql(101) }
|
410
370
|
it { history.should be_persisted }
|
411
371
|
end
|
412
372
|
|
413
373
|
context 'when it belongs to a kase' do
|
414
374
|
let(:kase) { Fabricate.build(:case, id: 5) }
|
415
|
-
|
416
375
|
let(:location) do
|
417
376
|
"https://sample.capsulecrm.com/api/kase/#{kase.id}/history/10005"
|
418
377
|
end
|
419
|
-
|
420
378
|
before do
|
421
379
|
history.kase = kase
|
422
380
|
stub_request(:post, /\/api\/kase\/#{kase.id}\/history$/).
|
423
381
|
to_return(headers: { 'Location' => location })
|
424
382
|
history.save
|
425
383
|
end
|
384
|
+
subject { history }
|
426
385
|
|
427
|
-
|
428
|
-
|
429
|
-
it { history.should be_persisted }
|
386
|
+
its(:id) { should eql(10005) }
|
387
|
+
it { should be_persisted }
|
430
388
|
end
|
431
389
|
|
432
390
|
context 'when it belongs to an opportunity' do
|
433
391
|
let(:opportunity) { Fabricate.build(:opportunity, id: 3) }
|
434
|
-
|
435
392
|
let(:location) do
|
436
393
|
[
|
437
394
|
'https://sample.capsulecrm.com/api/opportunity/',
|
438
395
|
opportunity.id, '/history/101'
|
439
396
|
].join
|
440
397
|
end
|
441
|
-
|
442
398
|
before do
|
443
399
|
history.opportunity = opportunity
|
444
400
|
stub_request(
|
@@ -446,10 +402,10 @@ describe CapsuleCRM::History do
|
|
446
402
|
).to_return(headers: { 'Location' => location })
|
447
403
|
history.save
|
448
404
|
end
|
405
|
+
subject { history }
|
449
406
|
|
450
|
-
|
451
|
-
|
452
|
-
it { history.should be_persisted }
|
407
|
+
its(:id) { should eql(101) }
|
408
|
+
it { should be_persisted }
|
453
409
|
end
|
454
410
|
end
|
455
411
|
|
@@ -457,14 +413,14 @@ describe CapsuleCRM::History do
|
|
457
413
|
let(:history) do
|
458
414
|
Fabricate.build(:history, party: Fabricate.build(:person), id: 10)
|
459
415
|
end
|
460
|
-
|
461
416
|
before do
|
462
417
|
stub_request(:put, /\/api\/history\/#{history.id}$/).
|
463
418
|
to_return(status: 200)
|
464
419
|
history.save
|
465
420
|
end
|
421
|
+
subject { history }
|
466
422
|
|
467
|
-
it {
|
423
|
+
it { should be_persisted }
|
468
424
|
end
|
469
425
|
end
|
470
426
|
|
@@ -478,57 +434,50 @@ describe CapsuleCRM::History do
|
|
478
434
|
to raise_error(CapsuleCRM::Errors::RecordInvalid)
|
479
435
|
end
|
480
436
|
end
|
481
|
-
|
482
437
|
let(:history) { Fabricate.build(:history) }
|
483
438
|
|
484
439
|
context 'when it belongs to a party' do
|
485
440
|
let(:party) { Fabricate.build(:organization, id: 2) }
|
486
|
-
|
487
441
|
let(:location) do
|
488
442
|
"https://sample.capsulecrm.com/api/party/#{party.id}/history/101"
|
489
443
|
end
|
490
|
-
|
491
444
|
before do
|
492
445
|
history.party = party
|
493
446
|
stub_request(:post, /\/api\/party\/#{party.id}\/history$/).
|
494
447
|
to_return(headers: { 'Location' => location })
|
495
448
|
history.save!
|
496
449
|
end
|
450
|
+
subject { history }
|
497
451
|
|
498
|
-
|
499
|
-
|
500
|
-
it { history.should be_persisted }
|
452
|
+
its(:id) { should eql(101) }
|
453
|
+
it { should be_persisted }
|
501
454
|
end
|
502
455
|
|
503
456
|
context 'when it belongs to a kase' do
|
504
457
|
let(:kase) { Fabricate.build(:case, id: 5) }
|
505
|
-
|
506
458
|
let(:location) do
|
507
459
|
"https://sample.capsulecrm.com/api/kase/#{kase.id}/history/10005"
|
508
460
|
end
|
509
|
-
|
510
461
|
before do
|
511
462
|
history.kase = kase
|
512
463
|
stub_request(:post, /\/api\/kase\/#{kase.id}\/history$/).
|
513
464
|
to_return(headers: { 'Location' => location })
|
514
465
|
history.save!
|
515
466
|
end
|
467
|
+
subject { history }
|
516
468
|
|
517
|
-
|
518
|
-
|
519
|
-
it { history.should be_persisted }
|
469
|
+
its(:id) { should eql(10005) }
|
470
|
+
it { should be_persisted }
|
520
471
|
end
|
521
472
|
|
522
473
|
context 'when it belongs to an opportunity' do
|
523
474
|
let(:opportunity) { Fabricate.build(:opportunity, id: 3) }
|
524
|
-
|
525
475
|
let(:location) do
|
526
476
|
[
|
527
477
|
'https://sample.capsulecrm.com/api/opportunity/',
|
528
478
|
opportunity.id, '/history/101'
|
529
479
|
].join
|
530
480
|
end
|
531
|
-
|
532
481
|
before do
|
533
482
|
history.opportunity = opportunity
|
534
483
|
stub_request(
|
@@ -536,10 +485,10 @@ describe CapsuleCRM::History do
|
|
536
485
|
).to_return(headers: { 'Location' => location })
|
537
486
|
history.save!
|
538
487
|
end
|
488
|
+
subject { history }
|
539
489
|
|
540
|
-
|
541
|
-
|
542
|
-
it { history.should be_persisted }
|
490
|
+
its(:id) { should eql(101) }
|
491
|
+
it { should be_persisted }
|
543
492
|
end
|
544
493
|
end
|
545
494
|
|
@@ -548,14 +497,14 @@ describe CapsuleCRM::History do
|
|
548
497
|
let(:history) do
|
549
498
|
Fabricate.build(:history, party: Fabricate.build(:person), id: 10)
|
550
499
|
end
|
551
|
-
|
552
500
|
before do
|
553
501
|
stub_request(:put, /\/api\/history\/#{history.id}$/).
|
554
502
|
to_return(status: 200)
|
555
503
|
history.save!
|
556
504
|
end
|
505
|
+
subject { history }
|
557
506
|
|
558
|
-
it {
|
507
|
+
it { should be_persisted }
|
559
508
|
end
|
560
509
|
|
561
510
|
context 'when it is not valid' do
|
@@ -571,13 +520,11 @@ describe CapsuleCRM::History do
|
|
571
520
|
|
572
521
|
describe '#destroy' do
|
573
522
|
let(:history) { Fabricate.build(:history, id: 19) }
|
574
|
-
|
575
523
|
before do
|
576
524
|
stub_request(:delete, /\/api\/history\/#{history.id}$/).
|
577
525
|
to_return(status: 200)
|
578
526
|
history.destroy
|
579
527
|
end
|
580
|
-
|
581
528
|
subject { history }
|
582
529
|
|
583
530
|
it { should_not be_persisted }
|
@@ -586,7 +533,6 @@ describe CapsuleCRM::History do
|
|
586
533
|
describe '#new_record?' do
|
587
534
|
context 'when the history item is a new record' do
|
588
535
|
let(:history) { CapsuleCRM::History.new }
|
589
|
-
|
590
536
|
subject { history.new_record? }
|
591
537
|
|
592
538
|
it { should be_true }
|
@@ -594,7 +540,6 @@ describe CapsuleCRM::History do
|
|
594
540
|
|
595
541
|
context 'when the history item is not a new record' do
|
596
542
|
let(:history) { CapsuleCRM::History.new(id: 1) }
|
597
|
-
|
598
543
|
subject { history.new_record? }
|
599
544
|
|
600
545
|
it { should be_false }
|
@@ -604,7 +549,6 @@ describe CapsuleCRM::History do
|
|
604
549
|
describe '#persisted?' do
|
605
550
|
context 'when the history item is persisted' do
|
606
551
|
let(:history) { CapsuleCRM::History.new(id: 1) }
|
607
|
-
|
608
552
|
subject { history.persisted? }
|
609
553
|
|
610
554
|
it { should be_true }
|
@@ -612,7 +556,6 @@ describe CapsuleCRM::History do
|
|
612
556
|
|
613
557
|
context 'when the hitory item is not persisted' do
|
614
558
|
let(:history) { CapsuleCRM::History.new }
|
615
|
-
|
616
559
|
subject { history.persisted? }
|
617
560
|
|
618
561
|
it { should be_false }
|
@@ -621,7 +564,6 @@ describe CapsuleCRM::History do
|
|
621
564
|
|
622
565
|
describe '#to_capsule_json' do
|
623
566
|
let(:creator) { CapsuleCRM::User.new(username: Faker::Name.name) }
|
624
|
-
|
625
567
|
let(:history) do
|
626
568
|
CapsuleCRM::History.new(
|
627
569
|
type: 'Note', entry_date: Time.now, creator: creator,
|
@@ -629,26 +571,23 @@ describe CapsuleCRM::History do
|
|
629
571
|
participants: [participant]
|
630
572
|
)
|
631
573
|
end
|
632
|
-
|
633
574
|
let(:participant) do
|
634
575
|
CapsuleCRM::Participant.new(
|
635
576
|
name: Faker::Name.name, email_address: Faker::Internet.email,
|
636
577
|
role: 'TO'
|
637
578
|
)
|
638
579
|
end
|
639
|
-
|
640
|
-
subject { history.to_capsule_json }
|
641
|
-
|
642
580
|
let(:participants_json) { subject[:historyItem]['participants'] }
|
581
|
+
subject { history.to_capsule_json }
|
643
582
|
|
644
|
-
it { subject.keys.first.
|
583
|
+
it { expect(subject.keys.first).to eql(:historyItem) }
|
645
584
|
|
646
|
-
it { subject[:historyItem]['entryDate'].
|
585
|
+
it { expect(subject[:historyItem]['entryDate']).to eql(history.entry_date) }
|
647
586
|
|
648
|
-
it { subject[:historyItem]['creator'].
|
587
|
+
it { expect(subject[:historyItem]['creator']).to eql(creator.username) }
|
649
588
|
|
650
|
-
it { subject[:historyItem]['note'].
|
589
|
+
it { expect(subject[:historyItem]['note']).to eql(history.note) }
|
651
590
|
|
652
|
-
it { subject[:historyItem].
|
591
|
+
it { expect(subject[:historyItem]).to have_key('note') }
|
653
592
|
end
|
654
593
|
end
|
metadata
CHANGED
@@ -1,237 +1,237 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capsule_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Beedle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: faraday
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: faraday_middleware
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: virtus
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.5.4
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.5.4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: coveralls
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: cucumber
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: fabrication
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: faker
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: guard
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: guard-bundler
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: guard-rspec
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- -
|
178
|
+
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: rb-fsevent
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
192
|
+
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: rspec
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- -
|
199
|
+
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
201
|
+
version: 2.14.0
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- -
|
206
|
+
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
208
|
+
version: 2.14.0
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: shoulda-matchers
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
|
-
- -
|
213
|
+
- - ">="
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '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
222
|
version: '0'
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: webmock
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
|
-
- -
|
227
|
+
- - ">="
|
228
228
|
- !ruby/object:Gem::Version
|
229
229
|
version: '0'
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
|
-
- -
|
234
|
+
- - ">="
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '0'
|
237
237
|
description: Gem to communicate with CapsuleCRM
|
@@ -241,9 +241,9 @@ executables: []
|
|
241
241
|
extensions: []
|
242
242
|
extra_rdoc_files: []
|
243
243
|
files:
|
244
|
-
- .gitignore
|
245
|
-
- .rspec
|
246
|
-
- .travis.yml
|
244
|
+
- ".gitignore"
|
245
|
+
- ".rspec"
|
246
|
+
- ".travis.yml"
|
247
247
|
- CHANGELOG.md
|
248
248
|
- Gemfile
|
249
249
|
- Guardfile
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- lib/capsule_crm/custom_field.rb
|
273
273
|
- lib/capsule_crm/email.rb
|
274
274
|
- lib/capsule_crm/errors/record_invalid.rb
|
275
|
+
- lib/capsule_crm/errors/unauthorized.rb
|
275
276
|
- lib/capsule_crm/hash_helper.rb
|
276
277
|
- lib/capsule_crm/history.rb
|
277
278
|
- lib/capsule_crm/milestone.rb
|
@@ -353,17 +354,17 @@ require_paths:
|
|
353
354
|
- lib
|
354
355
|
required_ruby_version: !ruby/object:Gem::Requirement
|
355
356
|
requirements:
|
356
|
-
- -
|
357
|
+
- - ">="
|
357
358
|
- !ruby/object:Gem::Version
|
358
359
|
version: 1.9.3
|
359
360
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
360
361
|
requirements:
|
361
|
-
- -
|
362
|
+
- - ">="
|
362
363
|
- !ruby/object:Gem::Version
|
363
364
|
version: '0'
|
364
365
|
requirements: []
|
365
366
|
rubyforge_project:
|
366
|
-
rubygems_version: 2.1
|
367
|
+
rubygems_version: 2.2.0.rc.1
|
367
368
|
signing_key:
|
368
369
|
specification_version: 4
|
369
370
|
summary: Gem to communicate with CapsuleCRM
|
@@ -424,4 +425,3 @@ test_files:
|
|
424
425
|
- spec/support/task.json
|
425
426
|
- spec/support/task_categories.json
|
426
427
|
- spec/support/tracks.json
|
427
|
-
has_rdoc:
|