enju_message 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,70 +3,70 @@ require 'rails_helper'
3
3
  describe MessagesController do
4
4
  fixtures :all
5
5
 
6
- describe "GET index", :solr => true do
6
+ describe 'GET index', solr: true do
7
7
  before do
8
8
  Message.reindex
9
9
  end
10
10
 
11
- describe "When logged in as Administrator" do
11
+ describe 'When logged in as Administrator' do
12
12
  login_fixture_admin
13
13
 
14
- it "should get its own messages" do
14
+ it 'should get its own messages' do
15
15
  get :index
16
16
  assigns(:messages).should_not be_nil
17
17
  response.should be_success
18
18
  end
19
19
 
20
- describe "When user_id is specified" do
21
- it "assigns all messages as @messages" do
22
- get :index, :user_id => @user.username
20
+ describe 'When user_id is specified' do
21
+ it 'assigns all messages as @messages' do
22
+ get :index, user_id: @user.username
23
23
  assigns(:messages).should_not be_nil
24
24
  end
25
25
  end
26
26
  end
27
27
 
28
- describe "When logged in as Librarian" do
28
+ describe 'When logged in as Librarian' do
29
29
  login_fixture_librarian
30
30
 
31
- it "should get its own messages" do
31
+ it 'should get its own messages' do
32
32
  get :index
33
33
  assigns(:messages).should_not be_nil
34
34
  response.should be_success
35
35
  end
36
36
 
37
- describe "When user_id is specified" do
38
- it "assigns all messages as @messages" do
39
- get :index, :user_id => @user.username
37
+ describe 'When user_id is specified' do
38
+ it 'assigns all messages as @messages' do
39
+ get :index, user_id: @user.username
40
40
  assigns(:messages).should_not be_nil
41
41
  end
42
42
  end
43
43
  end
44
44
 
45
- describe "When logged in as User" do
45
+ describe 'When logged in as User' do
46
46
  login_fixture_user
47
47
 
48
- describe "When user_id is specified" do
49
- it "assigns all messages as @messages" do
48
+ describe 'When user_id is specified' do
49
+ it 'assigns all messages as @messages' do
50
50
  get :index
51
51
  assigns(:messages).should_not be_nil
52
52
  end
53
53
  end
54
54
 
55
- it "should get its own messages" do
55
+ it 'should get its own messages' do
56
56
  get :index
57
57
  assigns(:messages).should_not be_nil
58
58
  response.should be_success
59
59
  end
60
60
 
61
- it "should get index with query" do
62
- get :index, :query => 'you'
61
+ it 'should get index with query' do
62
+ get :index, query: 'you'
63
63
  assigns(:messages).first.receiver.should eq users(:user1)
64
64
  response.should be_success
65
65
  end
66
66
  end
67
67
 
68
- describe "When not logged in" do
69
- it "assigns all messages as @messages" do
68
+ describe 'When not logged in' do
69
+ it 'assigns all messages as @messages' do
70
70
  get :index
71
71
  assigns(:messages).should be_nil
72
72
  response.should redirect_to(new_user_session_url)
@@ -74,104 +74,104 @@ describe MessagesController do
74
74
  end
75
75
  end
76
76
 
77
- describe "GET show" do
78
- describe "When logged in as Administrator" do
77
+ describe 'GET show' do
78
+ describe 'When logged in as Administrator' do
79
79
  login_fixture_admin
80
80
 
81
- it "assigns the requested message as @message" do
81
+ it 'assigns the requested message as @message' do
82
82
  message = messages(:user1_to_user2_1)
83
- lambda{
84
- get :show, :id => message.id
85
- }.should raise_error(ActiveRecord::RecordNotFound)
83
+ lambda do
84
+ get :show, id: message.id
85
+ end.should raise_error(ActiveRecord::RecordNotFound)
86
86
  assigns(:message).should be_nil
87
- #response.should be_missing
87
+ # response.should be_missing
88
88
  end
89
89
  end
90
90
 
91
- describe "When logged in as Librarian" do
91
+ describe 'When logged in as Librarian' do
92
92
  login_fixture_librarian
93
93
 
94
- it "assigns the requested message as @message" do
94
+ it 'assigns the requested message as @message' do
95
95
  message = messages(:user1_to_user2_1)
96
- lambda{
97
- get :show, :id => message.id
98
- }.should raise_error(ActiveRecord::RecordNotFound)
96
+ lambda do
97
+ get :show, id: message.id
98
+ end.should raise_error(ActiveRecord::RecordNotFound)
99
99
  assigns(:message).should be_nil
100
- #response.should be_forbidden
100
+ # response.should be_forbidden
101
101
  end
102
102
  end
103
103
 
104
- describe "When logged in as Librarian" do
104
+ describe 'When logged in as Librarian' do
105
105
  login_fixture_user
106
106
 
107
- it "should show my message" do
108
- get :show, :id => messages(:user2_to_user1_1).id
107
+ it 'should show my message' do
108
+ get :show, id: messages(:user2_to_user1_1).id
109
109
  response.should be_success
110
110
  end
111
111
 
112
112
  it "should should not show other user's message" do
113
- lambda{
114
- get :show, :id => messages(:user1_to_user2_1).id
115
- }.should raise_error(ActiveRecord::RecordNotFound)
116
- #response.should be_missing
113
+ lambda do
114
+ get :show, id: messages(:user1_to_user2_1).id
115
+ end.should raise_error(ActiveRecord::RecordNotFound)
116
+ # response.should be_missing
117
117
  end
118
118
  end
119
119
 
120
- describe "When not logged in" do
121
- it "assigns the requested message as @message" do
122
- get :show, :id => messages(:user1_to_user2_1).id
120
+ describe 'When not logged in' do
121
+ it 'assigns the requested message as @message' do
122
+ get :show, id: messages(:user1_to_user2_1).id
123
123
  response.should redirect_to new_user_session_url
124
124
  end
125
125
  end
126
126
  end
127
-
128
- describe "GET new" do
129
- describe "When logged in as Administrator" do
127
+
128
+ describe 'GET new' do
129
+ describe 'When logged in as Administrator' do
130
130
  login_fixture_admin
131
131
 
132
- it "assigns the requested message as @message" do
132
+ it 'assigns the requested message as @message' do
133
133
  get :new
134
134
  assigns(:message).should_not be_valid
135
135
  end
136
136
  end
137
137
 
138
- describe "When logged in as Librarian" do
138
+ describe 'When logged in as Librarian' do
139
139
  login_fixture_librarian
140
140
 
141
- it "should not assign the requested message as @message" do
141
+ it 'should not assign the requested message as @message' do
142
142
  get :new
143
143
  assigns(:message).should_not be_valid
144
144
  response.should be_success
145
145
  end
146
146
  end
147
147
 
148
- describe "When logged in as User" do
148
+ describe 'When logged in as User' do
149
149
  login_fixture_user
150
150
 
151
- it "should not assign the requested message as @message" do
151
+ it 'should not assign the requested message as @message' do
152
152
  get :new
153
153
  assigns(:message).should be_nil
154
154
  response.should be_forbidden
155
155
  end
156
156
 
157
- it "should not get new template without parent_id" do
157
+ it 'should not get new template without parent_id' do
158
158
  get :new
159
159
  response.should be_forbidden
160
160
  end
161
-
162
- it "should not get new template with invalid parent_id" do
163
- get :new, :parent_id => 1
161
+
162
+ it 'should not get new template with invalid parent_id' do
163
+ get :new, parent_id: 1
164
164
  response.should be_forbidden
165
165
  end
166
-
167
- it "should not get new template with valid parent_id" do
168
- get :new, :parent_id => 2
166
+
167
+ it 'should not get new template with valid parent_id' do
168
+ get :new, parent_id: 2
169
169
  response.should be_forbidden
170
170
  end
171
171
  end
172
172
 
173
- describe "When not logged in" do
174
- it "should not assign the requested message as @message" do
173
+ describe 'When not logged in' do
174
+ it 'should not assign the requested message as @message' do
175
175
  get :new
176
176
  assigns(:message).should be_nil
177
177
  response.should redirect_to(new_user_session_url)
@@ -179,349 +179,349 @@ describe MessagesController do
179
179
  end
180
180
  end
181
181
 
182
- describe "GET edit" do
183
- describe "When logged in as Administrator" do
182
+ describe 'GET edit' do
183
+ describe 'When logged in as Administrator' do
184
184
  login_fixture_admin
185
185
 
186
- it "assigns the requested message as @message" do
186
+ it 'assigns the requested message as @message' do
187
187
  message = messages(:user1_to_user2_1)
188
- lambda{
189
- get :edit, :id => message.id
190
- }.should raise_error(ActiveRecord::RecordNotFound)
188
+ lambda do
189
+ get :edit, id: message.id
190
+ end.should raise_error(ActiveRecord::RecordNotFound)
191
191
  assigns(:message).should be_nil
192
192
  response.should be_success
193
193
  end
194
194
  end
195
195
 
196
- describe "When logged in as Librarian" do
196
+ describe 'When logged in as Librarian' do
197
197
  login_fixture_librarian
198
198
 
199
- it "assigns the requested message as @message" do
199
+ it 'assigns the requested message as @message' do
200
200
  message = messages(:user1_to_user2_1)
201
- lambda{
202
- get :edit, :id => message.id
203
- }.should raise_error(ActiveRecord::RecordNotFound)
201
+ lambda do
202
+ get :edit, id: message.id
203
+ end.should raise_error(ActiveRecord::RecordNotFound)
204
204
  assigns(:message).should be_nil
205
205
  response.should be_success
206
206
  end
207
207
  end
208
208
 
209
- describe "When logged in as User" do
209
+ describe 'When logged in as User' do
210
210
  login_fixture_user
211
211
 
212
- it "assigns the requested message as @message" do
212
+ it 'assigns the requested message as @message' do
213
213
  message = messages(:user1_to_user2_1)
214
- lambda{
215
- get :edit, :id => message.id
216
- }.should raise_error(ActiveRecord::RecordNotFound)
214
+ lambda do
215
+ get :edit, id: message.id
216
+ end.should raise_error(ActiveRecord::RecordNotFound)
217
217
  assigns(:message).should be_nil
218
218
  response.should be_success
219
219
  end
220
220
  end
221
221
 
222
- describe "When not logged in" do
223
- it "assigns the requested message as @message" do
222
+ describe 'When not logged in' do
223
+ it 'assigns the requested message as @message' do
224
224
  message = FactoryGirl.create(:message)
225
- get :edit, :id => message.id
225
+ get :edit, id: message.id
226
226
  assigns(:message).should be_nil
227
227
  response.should redirect_to new_user_session_url
228
228
  end
229
229
  end
230
230
  end
231
231
 
232
- describe "POST create" do
232
+ describe 'POST create' do
233
233
  before(:each) do
234
- @attrs = {:recipient => users(:user1).username, :subject => 'test',:body => 'test'}
235
- @invalid_attrs = {:recipient => users(:user1).username, :subject => 'test', :body => ''}
236
- @invalid_user_attrs = {:recipient => "invalid_user", :subject => 'test', :body => 'test'}
237
- @blank_user_attrs = {:recipient => "", :subject => 'test', :body => 'test'}
234
+ @attrs = { recipient: users(:user1).username, subject: 'test', body: 'test' }
235
+ @invalid_attrs = { recipient: users(:user1).username, subject: 'test', body: '' }
236
+ @invalid_user_attrs = { recipient: 'invalid_user', subject: 'test', body: 'test' }
237
+ @blank_user_attrs = { recipient: '', subject: 'test', body: 'test' }
238
238
  end
239
239
 
240
- describe "When logged in as Administrator" do
240
+ describe 'When logged in as Administrator' do
241
241
  login_fixture_admin
242
242
 
243
- describe "with valid params" do
244
- it "assigns a newly created message as @message" do
245
- post :create, :message => @attrs, :user_id => users(:user1).username
243
+ describe 'with valid params' do
244
+ it 'assigns a newly created message as @message' do
245
+ post :create, message: @attrs, user_id: users(:user1).username
246
246
  assigns(:message).should be_valid
247
247
  end
248
248
 
249
- it "redirects to the created message" do
250
- post :create, :message => @attrs, :user_id => users(:user1).username
249
+ it 'redirects to the created message' do
250
+ post :create, message: @attrs, user_id: users(:user1).username
251
251
  response.should redirect_to(messages_url)
252
252
  end
253
253
  end
254
254
 
255
- describe "with invalid params" do
256
- it "assigns a newly created but unsaved message as @message" do
257
- post :create, :message => @invalid_attrs, :user_id => users(:user1).username
255
+ describe 'with invalid params' do
256
+ it 'assigns a newly created but unsaved message as @message' do
257
+ post :create, message: @invalid_attrs, user_id: users(:user1).username
258
258
  assigns(:message).should_not be_valid
259
259
  end
260
260
 
261
261
  it "re-renders the 'new' template" do
262
- post :create, :message => @invalid_attrs, :user_id => users(:user1).username
263
- response.should render_template("new")
262
+ post :create, message: @invalid_attrs, user_id: users(:user1).username
263
+ response.should render_template('new')
264
264
  response.should be_success
265
265
  end
266
266
  end
267
- describe "with invalid recipient" do
267
+ describe 'with invalid recipient' do
268
268
  it "re-renders the 'new' template" do
269
- post :create, :message => @invalid_user_attrs
269
+ post :create, message: @invalid_user_attrs
270
270
  message = assigns(:message)
271
271
  message.should_not be_valid
272
272
  message.errors.should have_key :receiver
273
273
  message.errors.added?(:receiver, :invalid).should be_truthy
274
- response.should render_template("new")
274
+ response.should render_template('new')
275
275
  end
276
276
  it "re-renders the 'new' template" do
277
- post :create, :message => @blank_user_attrs
277
+ post :create, message: @blank_user_attrs
278
278
  message = assigns(:message)
279
279
  message.should_not be_valid
280
280
  message.errors.should have_key :recipient
281
281
  message.errors.added?(:recipient, :blank).should be_truthy
282
- response.should render_template("new")
282
+ response.should render_template('new')
283
283
  end
284
284
  end
285
285
  end
286
286
 
287
- describe "When logged in as Librarian" do
287
+ describe 'When logged in as Librarian' do
288
288
  login_fixture_librarian
289
289
 
290
- it "should create message without parent_id" do
291
- post :create, :message => {:recipient => 'user2', :subject => "test", :body => "test", :parent_id => 2}
290
+ it 'should create message without parent_id' do
291
+ post :create, message: { recipient: 'user2', subject: 'test', body: 'test' }
292
292
  response.should redirect_to messages_url
293
293
  end
294
294
  end
295
295
 
296
- describe "When logged in as User" do
296
+ describe 'When logged in as User' do
297
297
  login_fixture_user
298
298
 
299
- it "should not create message without parent_id" do
300
- post :create, :message => {:recipient => 'user2', :subject => "test", :body => "test"}
299
+ it 'should not create message without parent_id' do
300
+ post :create, message: { recipient: 'user2', subject: 'test', body: 'test' }
301
301
  response.should be_forbidden
302
302
  end
303
-
304
- it "should not create message with parent_id" do
305
- post :create, :message => {:recipient => 'user2', :subject => "test", :body => "test", :parent_id => 2}
303
+
304
+ it 'should not create message with parent_id' do
305
+ post :create, message: { recipient: 'user2', subject: 'test', body: 'test', parent_id: 2 }
306
306
  response.should be_forbidden
307
307
  end
308
308
  end
309
309
 
310
- describe "When not logged in" do
311
- describe "with valid params" do
312
- it "assigns a newly created message as @message" do
313
- post :create, :message => @attrs
310
+ describe 'When not logged in' do
311
+ describe 'with valid params' do
312
+ it 'assigns a newly created message as @message' do
313
+ post :create, message: @attrs
314
314
  assigns(:message).should be_nil
315
315
  end
316
316
 
317
- it "should redirect to new_user_session_url" do
318
- post :create, :message => @attrs
317
+ it 'should redirect to new_user_session_url' do
318
+ post :create, message: @attrs
319
319
  response.should redirect_to(new_user_session_url)
320
320
  end
321
321
  end
322
322
 
323
- describe "with invalid params" do
324
- it "assigns a newly created but unsaved message as @message" do
325
- post :create, :message => @invalid_attrs
323
+ describe 'with invalid params' do
324
+ it 'assigns a newly created but unsaved message as @message' do
325
+ post :create, message: @invalid_attrs
326
326
  assigns(:message).should be_nil
327
327
  end
328
328
 
329
- it "should redirect to new_user_session_url" do
330
- post :create, :message => @invalid_attrs
329
+ it 'should redirect to new_user_session_url' do
330
+ post :create, message: @invalid_attrs
331
331
  response.should redirect_to(new_user_session_url)
332
332
  end
333
333
  end
334
334
  end
335
335
  end
336
336
 
337
- describe "PUT update" do
337
+ describe 'PUT update' do
338
338
  before(:each) do
339
339
  @message = messages(:user1_to_user2_1)
340
340
  @attrs = FactoryGirl.attributes_for(:message)
341
- @invalid_attrs = {:sender_id => ''}
341
+ @invalid_attrs = { sender_id: '' }
342
342
  end
343
343
 
344
- describe "When logged in as Administrator" do
344
+ describe 'When logged in as Administrator' do
345
345
  login_fixture_admin
346
346
 
347
- describe "with valid params" do
348
- it "updates the requested message" do
349
- lambda{
350
- put :update, :id => @message.id, :message => @attrs
351
- }.should raise_error(ActiveRecord::RecordNotFound)
347
+ describe 'with valid params' do
348
+ it 'updates the requested message' do
349
+ lambda do
350
+ put :update, id: @message.id, message: @attrs
351
+ end.should raise_error(ActiveRecord::RecordNotFound)
352
352
  end
353
353
 
354
- it "assigns the requested message as @message" do
355
- lambda{
356
- put :update, :id => @message.id, :message => @attrs
357
- }.should raise_error(ActiveRecord::RecordNotFound)
354
+ it 'assigns the requested message as @message' do
355
+ lambda do
356
+ put :update, id: @message.id, message: @attrs
357
+ end.should raise_error(ActiveRecord::RecordNotFound)
358
358
  assigns(:message).should be_nil
359
- #response.should be_missing
359
+ # response.should be_missing
360
360
  end
361
361
  end
362
362
 
363
- describe "with invalid params" do
364
- it "assigns the requested message as @message" do
365
- lambda{
366
- put :update, :id => @message.id, :message => @invalid_attrs
367
- }.should raise_error(ActiveRecord::RecordNotFound)
363
+ describe 'with invalid params' do
364
+ it 'assigns the requested message as @message' do
365
+ lambda do
366
+ put :update, id: @message.id, message: @invalid_attrs
367
+ end.should raise_error(ActiveRecord::RecordNotFound)
368
368
  end
369
369
 
370
370
  it "re-renders the 'edit' template" do
371
- lambda{
372
- put :update, :id => @message.id, :message => @invalid_attrs
373
- }.should raise_error(ActiveRecord::RecordNotFound)
371
+ lambda do
372
+ put :update, id: @message.id, message: @invalid_attrs
373
+ end.should raise_error(ActiveRecord::RecordNotFound)
374
374
  response.should be_success
375
375
  end
376
376
  end
377
377
  end
378
378
 
379
- describe "When logged in as Librarian" do
379
+ describe 'When logged in as Librarian' do
380
380
  login_fixture_librarian
381
381
 
382
- describe "with valid params" do
383
- it "updates the requested message" do
384
- lambda{
385
- put :update, :id => @message.id, :message => @attrs
386
- }.should raise_error(ActiveRecord::RecordNotFound)
382
+ describe 'with valid params' do
383
+ it 'updates the requested message' do
384
+ lambda do
385
+ put :update, id: @message.id, message: @attrs
386
+ end.should raise_error(ActiveRecord::RecordNotFound)
387
387
  end
388
388
 
389
- it "assigns the requested message as @message" do
390
- lambda{
391
- put :update, :id => @message.id, :message => @attrs
392
- }.should raise_error(ActiveRecord::RecordNotFound)
389
+ it 'assigns the requested message as @message' do
390
+ lambda do
391
+ put :update, id: @message.id, message: @attrs
392
+ end.should raise_error(ActiveRecord::RecordNotFound)
393
393
  assigns(:message).should be_nil
394
394
  response.should be_success
395
395
  end
396
396
  end
397
397
 
398
- describe "with invalid params" do
399
- it "assigns the requested message as @message" do
400
- lambda{
401
- put :update, :id => @message.id, :message => @invalid_attrs
402
- }.should raise_error(ActiveRecord::RecordNotFound)
398
+ describe 'with invalid params' do
399
+ it 'assigns the requested message as @message' do
400
+ lambda do
401
+ put :update, id: @message.id, message: @invalid_attrs
402
+ end.should raise_error(ActiveRecord::RecordNotFound)
403
403
  end
404
404
 
405
405
  it "re-renders the 'edit' template" do
406
- lambda{
407
- put :update, :id => @message.id, :message => @invalid_attrs
408
- }.should raise_error(ActiveRecord::RecordNotFound)
406
+ lambda do
407
+ put :update, id: @message.id, message: @invalid_attrs
408
+ end.should raise_error(ActiveRecord::RecordNotFound)
409
409
  response.should be_success
410
410
  end
411
411
  end
412
412
  end
413
413
 
414
- describe "When logged in as User" do
414
+ describe 'When logged in as User' do
415
415
  login_fixture_user
416
416
 
417
- describe "with valid params" do
418
- it "updates the requested message" do
419
- lambda{
420
- put :update, :id => @message.id, :message => @attrs
421
- }.should raise_error(ActiveRecord::RecordNotFound)
417
+ describe 'with valid params' do
418
+ it 'updates the requested message' do
419
+ lambda do
420
+ put :update, id: @message.id, message: @attrs
421
+ end.should raise_error(ActiveRecord::RecordNotFound)
422
422
  end
423
423
 
424
- it "assigns the requested message as @message" do
425
- lambda{
426
- put :update, :id => @message.id, :message => @attrs
427
- }.should raise_error(ActiveRecord::RecordNotFound)
424
+ it 'assigns the requested message as @message' do
425
+ lambda do
426
+ put :update, id: @message.id, message: @attrs
427
+ end.should raise_error(ActiveRecord::RecordNotFound)
428
428
  assigns(:message).should be_nil
429
429
  response.should be_success
430
430
  end
431
431
  end
432
432
 
433
- describe "with invalid params" do
434
- it "assigns the requested message as @message" do
435
- lambda{
436
- put :update, :id => @message.id, :message => @invalid_attrs
437
- }.should raise_error(ActiveRecord::RecordNotFound)
433
+ describe 'with invalid params' do
434
+ it 'assigns the requested message as @message' do
435
+ lambda do
436
+ put :update, id: @message.id, message: @invalid_attrs
437
+ end.should raise_error(ActiveRecord::RecordNotFound)
438
438
  end
439
439
 
440
440
  it "re-renders the 'edit' template" do
441
- lambda{
442
- put :update, :id => @message.id, :message => @invalid_attrs
443
- }.should raise_error(ActiveRecord::RecordNotFound)
441
+ lambda do
442
+ put :update, id: @message.id, message: @invalid_attrs
443
+ end.should raise_error(ActiveRecord::RecordNotFound)
444
444
  response.should be_success
445
445
  end
446
446
  end
447
447
 
448
- it "should not update my message" do
449
- put :update, :id => 2, :message => { }
448
+ it 'should not update my message' do
449
+ put :update, id: 2, message: {}
450
450
  response.should be_forbidden
451
451
  end
452
452
 
453
453
  it "should not update other user's message" do
454
- lambda{
455
- put :update, :id => 1, :message => { }
456
- }.should raise_error(ActiveRecord::RecordNotFound)
454
+ lambda do
455
+ put :update, id: 1, message: {}
456
+ end.should raise_error(ActiveRecord::RecordNotFound)
457
457
  response.should be_success
458
458
  end
459
459
  end
460
460
 
461
- describe "When not logged in" do
462
- it "assigns the requested message as @message" do
463
- put :update, :id => 2, :message => { }
461
+ describe 'When not logged in' do
462
+ it 'assigns the requested message as @message' do
463
+ put :update, id: 2, message: {}
464
464
  response.should redirect_to new_user_session_url
465
465
  end
466
466
  end
467
467
  end
468
468
 
469
- describe "DELETE destroy" do
470
- describe "When logged in as Librarian" do
469
+ describe 'DELETE destroy' do
470
+ describe 'When logged in as Librarian' do
471
471
  login_fixture_librarian
472
472
 
473
- it "should destroy own message" do
473
+ it 'should destroy own message' do
474
474
  @message = FactoryGirl.create(:message, recipient: @user.username)
475
- delete :destroy, :id => @message.id
475
+ delete :destroy, id: @message.id
476
476
  response.should redirect_to messages_url
477
477
  end
478
478
  end
479
- describe "When logged in as User" do
479
+ describe 'When logged in as User' do
480
480
  login_fixture_user
481
481
 
482
- it "should destroy own message" do
483
- delete :destroy, :id => 2
482
+ it 'should destroy own message' do
483
+ delete :destroy, id: 2
484
484
  response.should redirect_to messages_url
485
485
  response.should_not be_forbidden
486
486
  end
487
487
 
488
488
  it "should not destroy other user's message" do
489
- lambda {
490
- delete :destroy, :id => 1
491
- }.should raise_error(ActiveRecord::RecordNotFound)
489
+ lambda do
490
+ delete :destroy, id: 1
491
+ end.should raise_error(ActiveRecord::RecordNotFound)
492
492
  response.should be_success
493
493
  end
494
494
  end
495
495
 
496
- describe "When not logged in" do
497
- it "destroys the requested message" do
498
- delete :destroy, :id => 1
496
+ describe 'When not logged in' do
497
+ it 'destroys the requested message' do
498
+ delete :destroy, id: 1
499
499
  response.should redirect_to(new_user_session_url)
500
500
  end
501
501
 
502
- it "should be redirected to new_user_session_url" do
503
- delete :destroy, :id => 1
502
+ it 'should be redirected to new_user_session_url' do
503
+ delete :destroy, id: 1
504
504
  response.should redirect_to(new_user_session_url)
505
505
  end
506
506
  end
507
507
  end
508
508
 
509
- describe "POST destroy_selected" do
510
- describe "When logged in as Librarian" do
509
+ describe 'POST destroy_selected' do
510
+ describe 'When logged in as Librarian' do
511
511
  login_fixture_librarian
512
- it "should destroy own message" do
512
+ it 'should destroy own message' do
513
513
  message = FactoryGirl.create(:message, recipient: @user.username)
514
- post :destroy_selected, delete: [ message.id ]
514
+ post :destroy_selected, delete: [message.id]
515
515
  response.should_not be_forbidden
516
516
  response.should redirect_to(messages_url)
517
517
  end
518
518
  end
519
519
 
520
- describe "When logged in as User" do
520
+ describe 'When logged in as User' do
521
521
  login_fixture_user
522
- it "should destroy own message" do
522
+ it 'should destroy own message' do
523
523
  message = FactoryGirl.create(:message, recipient: @user.username)
524
- post :destroy_selected, delete: [ message.id ]
524
+ post :destroy_selected, delete: [message.id]
525
525
  response.should_not be_forbidden
526
526
  response.should redirect_to(messages_url)
527
527
  end