capsule_crm 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capsule_crm.rb +1 -0
- data/lib/capsule_crm/case.rb +258 -0
- data/lib/capsule_crm/version.rb +1 -1
- data/spec/lib/capsule_crm/case_spec.rb +317 -0
- data/spec/support/all_cases.json +14 -0
- data/spec/support/case.json +12 -0
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27fbb70234eb3c2f46340bb621531d44ef172089
|
4
|
+
data.tar.gz: 545a7d2b1f2dba314ed4e399fff534e56a549a54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a8948dc7c1ca6c64a084b31e371f1b51ddff6e15ef991878a2b3985a84ae3a004021883a0d32603c5050cf9753d03ad96a5560f0e287cdb2c4c73bc50c21453
|
7
|
+
data.tar.gz: 925f7f147a537fef527ecce482a9b8975fb5ca2a230ea70c0dab2bc87997963b15faee4408b8b193584aa4e3601848600a0b2cea3e439a458cc5474bd3f5cbac
|
data/lib/capsule_crm.rb
CHANGED
@@ -0,0 +1,258 @@
|
|
1
|
+
module CapsuleCRM
|
2
|
+
class Case
|
3
|
+
include Virtus
|
4
|
+
|
5
|
+
extend ActiveModel::Naming
|
6
|
+
include ActiveModel::Conversion
|
7
|
+
include ActiveModel::Validations
|
8
|
+
|
9
|
+
include CapsuleCRM::Associations::BelongsTo
|
10
|
+
|
11
|
+
attribute :id, Integer
|
12
|
+
attribute :name, String
|
13
|
+
attribute :description, String
|
14
|
+
attribute :status, String
|
15
|
+
attribute :close_date, Date
|
16
|
+
attribute :owner, String
|
17
|
+
|
18
|
+
validates :name, presence: true
|
19
|
+
validates :party, presence: true
|
20
|
+
|
21
|
+
belongs_to :party, class_name: 'CapsuleCRM::Party'
|
22
|
+
|
23
|
+
# Public: Search and retrieve all cases in CapsuleCRM
|
24
|
+
#
|
25
|
+
# options - the Hash of query options (default: {}):
|
26
|
+
# :tag - the String tag to search for
|
27
|
+
# :lastmodified - the Date after which the case was last
|
28
|
+
# modified by
|
29
|
+
# :start - the Integer index of the first record to
|
30
|
+
# return.
|
31
|
+
# :limit - the Integer number of records to return
|
32
|
+
#
|
33
|
+
# Examples
|
34
|
+
#
|
35
|
+
# CapsuleCRM::Case.all(tag: 'Some Tag')
|
36
|
+
#
|
37
|
+
# Returns a CapsuleCRM::ResultsProxy of CapsuleCRM::Case objects
|
38
|
+
def self.all(options = {})
|
39
|
+
init_collection(
|
40
|
+
CapsuleCRM::Connection.get('/api/kase', options)['kases']['kase']
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Public: Search for a single case by ID
|
45
|
+
#
|
46
|
+
# id - the Integer ID of the record to search for
|
47
|
+
#
|
48
|
+
# Examples
|
49
|
+
#
|
50
|
+
# CapsuleCRM::Case.find(1)
|
51
|
+
#
|
52
|
+
# Returns a CapsuleCRM::Case object
|
53
|
+
def self.find(id)
|
54
|
+
new CapsuleCRM::Connection.get("/api/kase/#{id}")['kase']
|
55
|
+
end
|
56
|
+
|
57
|
+
# Public: Create a CapsuleCRM::Case
|
58
|
+
#
|
59
|
+
# attributes - the Hash of attributes (default: {}):
|
60
|
+
# :name - the String name of the case (required)
|
61
|
+
# :description - the String description
|
62
|
+
# :status - the String status (OPEN or CLOSED), default
|
63
|
+
# is OPEN
|
64
|
+
# :owner - the String username of the owner
|
65
|
+
# :close_date - the Date when the case was/will be closed.
|
66
|
+
# Ignored if the status is set to CLOSED
|
67
|
+
#
|
68
|
+
# Examples
|
69
|
+
#
|
70
|
+
# CapsuleCRM::Case.create name: "Matt's test case"
|
71
|
+
#
|
72
|
+
# Returns a CapsuleCRM::Case
|
73
|
+
def self.create(attributes = {})
|
74
|
+
new(attributes).tap(&:save)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Public: Create a CapsuleCRM::Case or raise a error
|
78
|
+
#
|
79
|
+
# attributes - the Hash of attributes (default: {}):
|
80
|
+
# :name - the String name of the case (required)
|
81
|
+
# :description - the String description
|
82
|
+
# :status - the String status (OPEN or CLOSED), default
|
83
|
+
# is OPEN
|
84
|
+
# :owner - the String username of the owner
|
85
|
+
# :close_date - the Date when the case was/will be closed.
|
86
|
+
# Ignored if the status is set to CLOSED
|
87
|
+
#
|
88
|
+
# Examples
|
89
|
+
#
|
90
|
+
# CapsuleCRM::Case.create! name: "Matt's test case"
|
91
|
+
# => CapsuleCRM::Case object
|
92
|
+
#
|
93
|
+
# CapsuleCRM::Case.create! name: nil
|
94
|
+
# => CapsuleCRM::Errors::RecordInvalid
|
95
|
+
#
|
96
|
+
# Returns a CapsuleCRM::Case
|
97
|
+
def self.create!(attributes = {})
|
98
|
+
new(attributes).tap(&:save!)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Public: Updates an existing CapsuleCRM::Case with the supplied attributes
|
102
|
+
#
|
103
|
+
# attributes - the Hash of attributes (default: {}):
|
104
|
+
# :name - the String name of the case (required)
|
105
|
+
# :description - the String description
|
106
|
+
# :status - the String status (OPEN or CLOSED), default
|
107
|
+
# is OPEN
|
108
|
+
# :owner - the String username of the owner
|
109
|
+
# :close_date - the Date when the case was/will be closed.
|
110
|
+
# Ignored if the status is set to CLOSED
|
111
|
+
#
|
112
|
+
# Examples
|
113
|
+
#
|
114
|
+
# kase = CapsuleCRM::Case.find(1)
|
115
|
+
# kase.update_attributes name: 'A new name'
|
116
|
+
#
|
117
|
+
# Returns a CapsuleCRM::Case
|
118
|
+
def update_attributes(attributes = {})
|
119
|
+
self.attributes = attributes
|
120
|
+
save
|
121
|
+
end
|
122
|
+
|
123
|
+
# Public: Updates an existing CapsuleCRM::Case with the supplied attributes
|
124
|
+
# or raises an error
|
125
|
+
#
|
126
|
+
# attributes - the Hash of attributes (default: {}):
|
127
|
+
# :name - the String name of the case (required)
|
128
|
+
# :description - the String description
|
129
|
+
# :status - the String status (OPEN or CLOSED), default
|
130
|
+
# is OPEN
|
131
|
+
# :owner - the String username of the owner
|
132
|
+
# :close_date - the Date when the case was/will be closed.
|
133
|
+
# Ignored if the status is set to CLOSED
|
134
|
+
#
|
135
|
+
# Examples
|
136
|
+
#
|
137
|
+
# kase = CapsuleCRM::Case.find(1)
|
138
|
+
# kase.update_attributes! name: 'A new name'
|
139
|
+
# => CapsuleCRM::Case object
|
140
|
+
#
|
141
|
+
# kase.update_attributes! name: nil
|
142
|
+
# => CapsuleCRM::Errors::RecordInvalid
|
143
|
+
#
|
144
|
+
# Returns a CapsuleCRM::Case
|
145
|
+
def update_attributes!(attributes = {})
|
146
|
+
self.attributes = attributes
|
147
|
+
save!
|
148
|
+
end
|
149
|
+
|
150
|
+
# Public: Saves this CapsuleCRM::Case
|
151
|
+
#
|
152
|
+
# Examples:
|
153
|
+
#
|
154
|
+
# kase = CapsuleCRM::Case.new(
|
155
|
+
# name: 'Case Name', party: person_or_organization
|
156
|
+
# )
|
157
|
+
# kase.save
|
158
|
+
# => CapsuleCRM::Case object
|
159
|
+
#
|
160
|
+
# Returns the CapsuleCRM::Case or false
|
161
|
+
def save
|
162
|
+
if valid?
|
163
|
+
new_record? ? create_record : update_record
|
164
|
+
else
|
165
|
+
false
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Public: Saves this CapsuleCRM::Case or raises an error
|
170
|
+
#
|
171
|
+
# Examples
|
172
|
+
#
|
173
|
+
# kase = CapsuleCRM::Case.find(1)
|
174
|
+
# kase.name = 'Changed name'
|
175
|
+
# kase.save!
|
176
|
+
# => CapsuleCRM::Case object
|
177
|
+
#
|
178
|
+
# kase.name = nil
|
179
|
+
# kase.save!
|
180
|
+
# => CapsuleCRM::Errors::RecordInvalid
|
181
|
+
#
|
182
|
+
# Returns a CapsuleCRM::Case
|
183
|
+
def save!
|
184
|
+
if valid?
|
185
|
+
new_record? ? create_record : update_record
|
186
|
+
else
|
187
|
+
raise CapsuleCRM::Errors::RecordInvalid.new(self)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Public: Deletes this CapsuleCRM::Case from CapsuleCRM
|
192
|
+
#
|
193
|
+
# Examples
|
194
|
+
#
|
195
|
+
# CapsuleCRM::Case.find(1).destroy
|
196
|
+
#
|
197
|
+
# Returns the CapsuleCRM::Case object
|
198
|
+
def destroy
|
199
|
+
self.id = nil if CapsuleCRM::Connection.delete("/api/kase/#{id}")
|
200
|
+
self
|
201
|
+
end
|
202
|
+
|
203
|
+
# Public: Is this case a new record?
|
204
|
+
#
|
205
|
+
# Examples
|
206
|
+
#
|
207
|
+
# CapsuleCRM::Case.find(1).new_record?
|
208
|
+
# => false
|
209
|
+
#
|
210
|
+
# CapsuleCRM::Case.new.new_record?
|
211
|
+
# => true
|
212
|
+
#
|
213
|
+
# Returns a Boolean
|
214
|
+
def new_record?
|
215
|
+
!id
|
216
|
+
end
|
217
|
+
|
218
|
+
# Public: Is this case persisted to CapsuleCRM?
|
219
|
+
#
|
220
|
+
# Examples
|
221
|
+
#
|
222
|
+
# CapsuleCRM::Case.find(1).persisted?
|
223
|
+
# => true
|
224
|
+
#
|
225
|
+
# CapsuleCRM::Case.new.persisted?
|
226
|
+
# => false
|
227
|
+
#
|
228
|
+
# Returns a Boolean
|
229
|
+
def persisted?
|
230
|
+
!new_record?
|
231
|
+
end
|
232
|
+
|
233
|
+
def to_capsule_json
|
234
|
+
{
|
235
|
+
kase: CapsuleCRM::HashHelper.camelize_keys(
|
236
|
+
attributes.dup.delete_if { |key, value| value.blank? }
|
237
|
+
)
|
238
|
+
}
|
239
|
+
end
|
240
|
+
|
241
|
+
private
|
242
|
+
|
243
|
+
def create_record
|
244
|
+
self.attributes = CapsuleCRM::Connection.post(
|
245
|
+
"/api/party/#{party_id}/kase", to_capsule_json
|
246
|
+
)
|
247
|
+
self
|
248
|
+
end
|
249
|
+
|
250
|
+
def update_record
|
251
|
+
CapsuleCRM::Connection.put("/api/kase/#{id}", to_capsule_json)
|
252
|
+
end
|
253
|
+
|
254
|
+
def self.init_collection(results)
|
255
|
+
CapsuleCRM::ResultsProxy.new(results.map { |item| new item })
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
data/lib/capsule_crm/version.rb
CHANGED
@@ -0,0 +1,317 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CapsuleCRM::Case do
|
4
|
+
before { configure }
|
5
|
+
|
6
|
+
it { should validate_presence_of(:name) }
|
7
|
+
|
8
|
+
it { should validate_presence_of(:party) }
|
9
|
+
|
10
|
+
describe '.all' do
|
11
|
+
before do
|
12
|
+
stub_request(:get, 'https://1234:@company.capsulecrm.com/api/kase').
|
13
|
+
to_return(body: File.read('spec/support/all_cases.json'))
|
14
|
+
end
|
15
|
+
|
16
|
+
subject { CapsuleCRM::Case.all }
|
17
|
+
|
18
|
+
it { should be_a(Array) }
|
19
|
+
|
20
|
+
it { subject.length.should eql(1) }
|
21
|
+
|
22
|
+
it { subject.all? { |item| item.is_a?(CapsuleCRM::Case) }.should be_true }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.find' do
|
26
|
+
before do
|
27
|
+
stub_request(:get, 'https://1234:@company.capsulecrm.com/api/kase/43').
|
28
|
+
to_return(body: File.read('spec/support/case.json'))
|
29
|
+
end
|
30
|
+
|
31
|
+
subject { CapsuleCRM::Case.find(43) }
|
32
|
+
|
33
|
+
it { should be_a(CapsuleCRM::Case) }
|
34
|
+
|
35
|
+
it { subject.name.should eql('Consulting') }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '.create' do
|
39
|
+
context 'when the case is valid' do
|
40
|
+
before do
|
41
|
+
stub_request(
|
42
|
+
:post, 'https://1234:@company.capsulecrm.com/api/party/1/kase'
|
43
|
+
).to_return(
|
44
|
+
headers: { 'Location' => 'https://sample.capsulecrm.com/api/kase/59' }
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:party) { CapsuleCRM::Person.new(id: 1, first_name: 'Matt') }
|
49
|
+
|
50
|
+
subject { CapsuleCRM::Case.create name: 'Test Case', party: party }
|
51
|
+
|
52
|
+
it { should be_a(CapsuleCRM::Case) }
|
53
|
+
|
54
|
+
it { subject.id.should eql(59) }
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when the case is invalid' do
|
58
|
+
let(:kase) { CapsuleCRM::Case.create name: 'Test Case' }
|
59
|
+
|
60
|
+
it { kase.errors.should_not be_blank }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '.create!' do
|
65
|
+
context 'when the case is valid' do
|
66
|
+
before do
|
67
|
+
stub_request(
|
68
|
+
:post, 'https://1234:@company.capsulecrm.com/api/party/1/kase'
|
69
|
+
).to_return(
|
70
|
+
headers: { 'Location' => 'https://sample.capsulecrm.com/api/kase/61' }
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
let(:party) { CapsuleCRM::Person.new(id: 1, first_name: 'Matt') }
|
75
|
+
|
76
|
+
subject { CapsuleCRM::Case.create! name: 'Test Case', party: party }
|
77
|
+
|
78
|
+
it { should be_a(CapsuleCRM::Case) }
|
79
|
+
|
80
|
+
it { subject.id.should eql(61) }
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when the case is invalid' do
|
84
|
+
let(:kase) { CapsuleCRM::Case.create! name: 'Test Case' }
|
85
|
+
|
86
|
+
it 'should raise an error' do
|
87
|
+
expect { kase }.to raise_error(CapsuleCRM::Errors::RecordInvalid)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#update_attributes' do
|
93
|
+
context 'when the case is valid' do
|
94
|
+
let(:party) { CapsuleCRM::Person.new(id: 10) }
|
95
|
+
|
96
|
+
let(:kase) do
|
97
|
+
CapsuleCRM::Case.new(id: 1, name: 'Test Case', party: party)
|
98
|
+
end
|
99
|
+
|
100
|
+
before do
|
101
|
+
stub_request(
|
102
|
+
:put, 'https://1234:@company.capsulecrm.com/api/kase/1'
|
103
|
+
).to_return(status: 200)
|
104
|
+
kase.update_attributes name: 'changed name'
|
105
|
+
end
|
106
|
+
|
107
|
+
it { kase.name.should eql('changed name') }
|
108
|
+
|
109
|
+
it { kase.id.should eql(1) }
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'when the case is not valid' do
|
113
|
+
let(:kase) { CapsuleCRM::Case.new(id: 2, name: 'Test Case') }
|
114
|
+
|
115
|
+
before do
|
116
|
+
kase.update_attributes name: 'changed name'
|
117
|
+
end
|
118
|
+
|
119
|
+
it { kase.errors.should_not be_blank }
|
120
|
+
|
121
|
+
it { kase.name.should eql('changed name') }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#update_attributes!' do
|
126
|
+
context 'when the case is valid' do
|
127
|
+
let(:party) { CapsuleCRM::Person.new(id: 1, first_name: 'Matt') }
|
128
|
+
|
129
|
+
let(:kase) do
|
130
|
+
CapsuleCRM::Case.new(id: 1, name: 'Test Case', party: party)
|
131
|
+
end
|
132
|
+
|
133
|
+
before do
|
134
|
+
stub_request(
|
135
|
+
:put, 'https://1234:@company.capsulecrm.com/api/kase/1'
|
136
|
+
).to_return(status: 200)
|
137
|
+
kase.update_attributes! name: 'changed name'
|
138
|
+
end
|
139
|
+
|
140
|
+
it { kase.name.should eql('changed name') }
|
141
|
+
|
142
|
+
it { kase.id.should eql(1) }
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'when the case is invalid' do
|
146
|
+
let(:kase) { CapsuleCRM::Case.new(id: 1, name: 'Test Case') }
|
147
|
+
|
148
|
+
subject { kase.update_attributes! name: 'changed name' }
|
149
|
+
|
150
|
+
it do
|
151
|
+
expect { subject }.to raise_error(CapsuleCRM::Errors::RecordInvalid)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '#save' do
|
157
|
+
let(:party) { CapsuleCRM::Person.new(id: 1) }
|
158
|
+
|
159
|
+
context 'when it is a new record' do
|
160
|
+
context 'when it is valid' do
|
161
|
+
let(:kase) { CapsuleCRM::Case.new(name: 'Test', party: party) }
|
162
|
+
|
163
|
+
before do
|
164
|
+
stub_request(
|
165
|
+
:post, 'https://1234:@company.capsulecrm.com/api/party/1/kase'
|
166
|
+
).to_return(
|
167
|
+
headers: { 'Location' => 'https://sample.capsulecrm.com/api/kase/2' }
|
168
|
+
)
|
169
|
+
kase.save
|
170
|
+
end
|
171
|
+
|
172
|
+
subject { kase }
|
173
|
+
|
174
|
+
it { should be_persisted }
|
175
|
+
|
176
|
+
it { kase.id.should eql(2) }
|
177
|
+
end
|
178
|
+
|
179
|
+
context 'when it is invalid' do
|
180
|
+
let(:kase) { CapsuleCRM::Case.new(name: 'Test') }
|
181
|
+
|
182
|
+
before { kase.save }
|
183
|
+
|
184
|
+
it { kase.errors.should_not be_blank }
|
185
|
+
|
186
|
+
it { kase.should_not be_persisted }
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context 'when it is an existing record' do
|
191
|
+
let(:party) { CapsuleCRM::Person.new(id: 1) }
|
192
|
+
|
193
|
+
context 'when it is valid' do
|
194
|
+
let(:kase) { CapsuleCRM::Case.new(id: 2, name: 'Test', party: party) }
|
195
|
+
|
196
|
+
before do
|
197
|
+
stub_request(
|
198
|
+
:put, 'https://1234:@company.capsulecrm.com/api/kase/2'
|
199
|
+
).to_return(status: 200)
|
200
|
+
kase.name = 'changed name'
|
201
|
+
kase.save
|
202
|
+
end
|
203
|
+
|
204
|
+
it { kase.should be_persisted }
|
205
|
+
|
206
|
+
it { kase.name.should eql('changed name') }
|
207
|
+
end
|
208
|
+
|
209
|
+
context 'when it is invalid' do
|
210
|
+
let(:kase) { CapsuleCRM::Case.new(id: 2, name: 'Test') }
|
211
|
+
|
212
|
+
before { kase.save }
|
213
|
+
|
214
|
+
it { kase.should be_persisted }
|
215
|
+
|
216
|
+
it { kase.errors.should_not be_blank }
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe '#save!' do
|
222
|
+
let(:party) { CapsuleCRM::Person.new(id: 1) }
|
223
|
+
|
224
|
+
context 'when it is a new record' do
|
225
|
+
context 'when it is valid' do
|
226
|
+
let(:kase) { CapsuleCRM::Case.new(name: 'Test Case', party: party) }
|
227
|
+
|
228
|
+
before do
|
229
|
+
stub_request(:post, /^https.*\/api\/party\/1\/kase$/).
|
230
|
+
to_return(headers: {
|
231
|
+
'Location' => 'https://sample.capsulecrm.com/api/kase/59'
|
232
|
+
})
|
233
|
+
kase.save!
|
234
|
+
end
|
235
|
+
|
236
|
+
it { kase.should be_persisted }
|
237
|
+
end
|
238
|
+
|
239
|
+
context 'when it is invalid' do
|
240
|
+
let(:kase) { CapsuleCRM::Case.new(name: 'Test Case') }
|
241
|
+
|
242
|
+
it do
|
243
|
+
expect { kase.save! }.
|
244
|
+
to raise_error(CapsuleCRM::Errors::RecordInvalid)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
context 'when it is not a new record' do
|
250
|
+
context 'when it is valid' do
|
251
|
+
let(:kase) do
|
252
|
+
CapsuleCRM::Case.new(id: 1, name: 'Test Case', party: party)
|
253
|
+
end
|
254
|
+
|
255
|
+
before do
|
256
|
+
stub_request(:put, /^.*\/api\/kase\/1$/).to_return(status: 200)
|
257
|
+
kase.save!
|
258
|
+
end
|
259
|
+
|
260
|
+
it { kase.should be_persisted }
|
261
|
+
end
|
262
|
+
|
263
|
+
context 'when it is invalid' do
|
264
|
+
let(:kase) do
|
265
|
+
CapsuleCRM::Case.new(id: 1, name: 'Test Case')
|
266
|
+
end
|
267
|
+
|
268
|
+
it do
|
269
|
+
expect { kase.save! }.
|
270
|
+
to raise_error(CapsuleCRM::Errors::RecordInvalid)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
describe '#destroy' do
|
277
|
+
let(:party) { CapsuleCRM::Person.new(id: 2) }
|
278
|
+
|
279
|
+
let(:kase) { CapsuleCRM::Case.new(id: 1, party: party, name: 'Test Case') }
|
280
|
+
|
281
|
+
before do
|
282
|
+
stub_request(:delete, /^.*\/api\/kase\/1$/).to_return(status: 200)
|
283
|
+
kase.destroy
|
284
|
+
end
|
285
|
+
|
286
|
+
it { kase.should_not be_persisted }
|
287
|
+
end
|
288
|
+
|
289
|
+
describe '#new_record?' do
|
290
|
+
describe 'when it is a new record' do
|
291
|
+
|
292
|
+
subject { CapsuleCRM::Case.new }
|
293
|
+
|
294
|
+
it { should be_new_record }
|
295
|
+
end
|
296
|
+
|
297
|
+
describe 'when it is not a new record' do
|
298
|
+
subject { CapsuleCRM::Case.new(id: 1) }
|
299
|
+
|
300
|
+
it { should_not be_new_record }
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
describe '#persisted?' do
|
305
|
+
context 'when it is persisted' do
|
306
|
+
subject { CapsuleCRM::Case.new(id: 1) }
|
307
|
+
|
308
|
+
it { should be_persisted }
|
309
|
+
end
|
310
|
+
|
311
|
+
context 'when it is not persisted' do
|
312
|
+
subject { CapsuleCRM::Case.new }
|
313
|
+
|
314
|
+
it { should_not be_persisted }
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"kases": {
|
3
|
+
"kase": [{
|
4
|
+
"id": "43",
|
5
|
+
"createdOn": "2011-04-16T13:59:58Z",
|
6
|
+
"description": "Scope and design web site shopping cart",
|
7
|
+
"name": "Consulting",
|
8
|
+
"status": "OPEN",
|
9
|
+
"owner": "a.user",
|
10
|
+
"updatedOn": "2011-05-11T16:54:23Z",
|
11
|
+
"partyId": "2"
|
12
|
+
}]
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"kase": {
|
3
|
+
"id": "43",
|
4
|
+
"createdOn": "2011-04-16T13:59:58Z",
|
5
|
+
"description": "Scope and design web site shopping cart",
|
6
|
+
"name": "Consulting",
|
7
|
+
"status": "OPEN",
|
8
|
+
"owner": "a.user",
|
9
|
+
"updatedOn": "2011-05-11T16:54:23Z",
|
10
|
+
"partyId": "2"
|
11
|
+
}
|
12
|
+
}
|
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: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Beedle
|
@@ -230,6 +230,7 @@ files:
|
|
230
230
|
- lib/capsule_crm/associations/has_many.rb
|
231
231
|
- lib/capsule_crm/associations/has_many_proxy.rb
|
232
232
|
- lib/capsule_crm/capsule_jsonable.rb
|
233
|
+
- lib/capsule_crm/case.rb
|
233
234
|
- lib/capsule_crm/configuration.rb
|
234
235
|
- lib/capsule_crm/connection.rb
|
235
236
|
- lib/capsule_crm/contactable.rb
|
@@ -250,15 +251,18 @@ files:
|
|
250
251
|
- spec/lib/capsule_crm/address_spec.rb
|
251
252
|
- spec/lib/capsule_crm/associations/has_many_proxy_spec.rb
|
252
253
|
- spec/lib/capsule_crm/associations/has_many_spec.rb
|
254
|
+
- spec/lib/capsule_crm/case_spec.rb
|
253
255
|
- spec/lib/capsule_crm/contacts_spec.rb
|
254
256
|
- spec/lib/capsule_crm/email_spec.rb
|
255
257
|
- spec/lib/capsule_crm/opportunity_spec.rb
|
256
258
|
- spec/lib/capsule_crm/organization_spec.rb
|
257
259
|
- spec/lib/capsule_crm/person_spec.rb
|
258
260
|
- spec/spec_helper.rb
|
261
|
+
- spec/support/all_cases.json
|
259
262
|
- spec/support/all_opportunities.json
|
260
263
|
- spec/support/all_parties.json
|
261
264
|
- spec/support/all_people.json
|
265
|
+
- spec/support/case.json
|
262
266
|
- spec/support/deleted_opportunities.json
|
263
267
|
- spec/support/helpers.rb
|
264
268
|
- spec/support/opportunity.json
|
@@ -294,15 +298,18 @@ test_files:
|
|
294
298
|
- spec/lib/capsule_crm/address_spec.rb
|
295
299
|
- spec/lib/capsule_crm/associations/has_many_proxy_spec.rb
|
296
300
|
- spec/lib/capsule_crm/associations/has_many_spec.rb
|
301
|
+
- spec/lib/capsule_crm/case_spec.rb
|
297
302
|
- spec/lib/capsule_crm/contacts_spec.rb
|
298
303
|
- spec/lib/capsule_crm/email_spec.rb
|
299
304
|
- spec/lib/capsule_crm/opportunity_spec.rb
|
300
305
|
- spec/lib/capsule_crm/organization_spec.rb
|
301
306
|
- spec/lib/capsule_crm/person_spec.rb
|
302
307
|
- spec/spec_helper.rb
|
308
|
+
- spec/support/all_cases.json
|
303
309
|
- spec/support/all_opportunities.json
|
304
310
|
- spec/support/all_parties.json
|
305
311
|
- spec/support/all_people.json
|
312
|
+
- spec/support/case.json
|
306
313
|
- spec/support/deleted_opportunities.json
|
307
314
|
- spec/support/helpers.rb
|
308
315
|
- spec/support/opportunity.json
|