File tree Expand file tree Collapse file tree 2 files changed +55
-1
lines changed Expand file tree Collapse file tree 2 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,13 @@ def reinvite
34
34
render 'show.json.jb'
35
35
end
36
36
37
+ def destroy
38
+ @invitation = Invitation . find ( params [ :id ] )
39
+ @invitation . destroy!
40
+
41
+ render 'show.json.jb'
42
+ end
43
+
37
44
private
38
45
39
46
def create_invitation_params
Original file line number Diff line number Diff line change 207
207
end
208
208
209
209
describe 'DELETE /organization/:organization_id/invitations/:id' do
210
- pending "add some examples (or delete) #{ __FILE__ } "
210
+ let ( :invitation ) { create ( :invitation , organization : organization ) }
211
+
212
+ context 'when organization does not exist' do
213
+ it 'renders 401' do
214
+ delete :destroy , params : {
215
+ organization_id : 123 ,
216
+ id : invitation . id
217
+ }
218
+
219
+ expect ( response ) . to have_http_status ( 401 )
220
+ end
221
+ end
222
+
223
+ context 'when invitation does not exist' do
224
+ it 'renders 401' do
225
+ delete :destroy , params : {
226
+ organization_id : organization . id ,
227
+ id : 123
228
+ }
229
+
230
+ expect ( response ) . to have_http_status ( 401 )
231
+ end
232
+ end
233
+
234
+ context 'when invitation exists' do
235
+ before do
236
+ delete :destroy , params : {
237
+ organization_id : organization . id ,
238
+ id : invitation . id
239
+ }
240
+ end
241
+
242
+ it 'renders 200 with deleted invitation' do
243
+ expect ( response ) . to have_http_status ( 200 )
244
+ expect ( JSON . parse ( response . body ) . keys ) . to contain_exactly ( *invitation_fields )
245
+ expect ( JSON . parse ( response . body ) ) . to match (
246
+ a_hash_including (
247
+ 'id' => invitation . id
248
+ )
249
+ )
250
+ end
251
+
252
+ it 'deletes invitation' do
253
+ expect do
254
+ Invitation . find ( invitation . id )
255
+ end . to raise_error ( ActiveRecord ::RecordNotFound )
256
+ end
257
+ end
211
258
end
212
259
end
You can’t perform that action at this time.
0 commit comments