enju_circulation 0.2.0 → 0.2.1

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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/items_helper.rb +1 -1
  3. data/app/models/checked_item.rb +2 -1
  4. data/app/views/carrier_types/_carrier_type_has_checkout_type_fields.html.erb +1 -1
  5. data/lib/enju_circulation/version.rb +1 -1
  6. data/lib/tasks/enju_circulation_tasks.rake +3 -2
  7. data/spec/controllers/carrier_type_has_checkout_types_controller_spec.rb +152 -152
  8. data/spec/controllers/checked_items_controller_spec.rb +135 -135
  9. data/spec/controllers/checkins_controller_spec.rb +161 -161
  10. data/spec/controllers/checkout_types_controller_spec.rb +152 -152
  11. data/spec/controllers/checkouts_controller_spec.rb +103 -103
  12. data/spec/controllers/circulation_statuses_controller_spec.rb +152 -152
  13. data/spec/controllers/item_has_use_restrictions_controller_spec.rb +152 -152
  14. data/spec/controllers/lending_policies_controller_spec.rb +150 -150
  15. data/spec/controllers/manifestation_checkout_stats_controller_spec.rb +152 -152
  16. data/spec/controllers/manifestation_reserve_stats_controller_spec.rb +152 -152
  17. data/spec/controllers/profiles_controller_spec.rb +4 -4
  18. data/spec/controllers/reserves_controller_spec.rb +249 -249
  19. data/spec/controllers/use_restrictions_controller_spec.rb +153 -153
  20. data/spec/controllers/user_checkout_stats_controller_spec.rb +152 -152
  21. data/spec/controllers/user_group_has_checkout_types_controller_spec.rb +150 -150
  22. data/spec/controllers/user_reserve_stats_controller_spec.rb +152 -152
  23. data/spec/dummy/db/schema.rb +12 -2
  24. data/spec/fixtures/checked_items.yml +2 -1
  25. data/spec/helpers/items_helper_spec.rb +0 -1
  26. data/spec/models/checked_item_spec.rb +2 -1
  27. metadata +3 -17
@@ -3,134 +3,134 @@ require 'rails_helper'
3
3
  describe ReservesController 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
  Reserve.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 "assigns all reserves as @reserves" do
14
+ it 'assigns all reserves as @reserves' do
15
15
  get :index
16
16
  assigns(:reserves).should eq(Reserve.order('reserves.id DESC').includes(:manifestation).page(1))
17
17
  end
18
18
 
19
19
  it "should get other user's reservation" do
20
- get :index, :user_id => users(:user1).username
20
+ get :index, user_id: users(:user1).username
21
21
  response.should be_success
22
22
  assigns(:reserves).should eq(users(:user1).reserves.order('reserves.id DESC').includes(:manifestation).page(1))
23
23
  end
24
24
  end
25
25
 
26
- describe "When logged in as Librarian" do
26
+ describe 'When logged in as Librarian' do
27
27
  login_fixture_librarian
28
28
 
29
- it "assigns all reserves as @reserves" do
29
+ it 'assigns all reserves as @reserves' do
30
30
  get :index
31
31
  assigns(:reserves).should eq(Reserve.order('reserves.id DESC').includes(:manifestation).page(1))
32
32
  end
33
33
 
34
- it "should get index feed without user_id" do
34
+ it 'should get index feed without user_id' do
35
35
  get :index, format: 'rss'
36
36
  response.should be_success
37
37
  assigns(:reserves).count.should eq assigns(:reserves).total_entries
38
38
  assigns(:reserves).should eq(Reserve.order('reserves.id DESC').includes(:manifestation))
39
39
  end
40
40
 
41
- it "should get index txt without user_id" do
41
+ it 'should get index txt without user_id' do
42
42
  get :index, format: 'txt'
43
43
  response.should be_success
44
44
  assigns(:reserves).count.should eq assigns(:reserves).total_entries
45
45
  assigns(:reserves).should eq(Reserve.order('reserves.id DESC').includes(:manifestation))
46
46
  end
47
47
 
48
- it "should get index feed with user_id" do
49
- get :index, :user_id => users(:user1).username, format: 'rss'
48
+ it 'should get index feed with user_id' do
49
+ get :index, user_id: users(:user1).username, format: 'rss'
50
50
  response.should be_success
51
51
  assigns(:reserves).should eq(users(:user1).reserves.order('reserves.id DESC').includes(:manifestation).page(1))
52
52
  end
53
53
 
54
- it "should get index txt with user_id" do
55
- get :index, :user_id => users(:user1).username, format: 'txt'
54
+ it 'should get index txt with user_id' do
55
+ get :index, user_id: users(:user1).username, format: 'txt'
56
56
  response.should be_success
57
57
  assigns(:reserves).should eq(users(:user1).reserves.order('reserves.id DESC').includes(:manifestation))
58
58
  end
59
59
 
60
60
  it "should get other user's index" do
61
- get :index, :user_id => users(:user1).username
61
+ get :index, user_id: users(:user1).username
62
62
  response.should be_success
63
63
  assigns(:reserves).should eq(users(:user1).reserves.order('reserves.id DESC').includes(:manifestation).page(1))
64
64
  end
65
65
 
66
66
  it "should get other user's index feed" do
67
- get :index, :user_id => users(:user1).username, format: :rss
67
+ get :index, user_id: users(:user1).username, format: :rss
68
68
  response.should be_success
69
69
  assigns(:reserves).should eq(users(:user1).reserves.order('reserves.id DESC').includes(:manifestation).page(1))
70
70
  end
71
71
  end
72
72
 
73
- describe "When logged in as User" do
73
+ describe 'When logged in as User' do
74
74
  login_fixture_user
75
75
 
76
- it "assigns my reserves as @reserves" do
76
+ it 'assigns my reserves as @reserves' do
77
77
  get :index
78
78
  assigns(:reserves).should eq(users(:user1).reserves.order('reserves.id DESC').includes(:manifestation).page(1))
79
79
  end
80
80
 
81
- it "should be redirected to my index" do
81
+ it 'should be redirected to my index' do
82
82
  get :index
83
83
  response.should be_success
84
84
  end
85
85
 
86
- it "should get my index feed" do
86
+ it 'should get my index feed' do
87
87
  get :index, format: :rss
88
88
  response.should be_success
89
- response.should render_template("index")
89
+ response.should render_template('index')
90
90
  end
91
91
 
92
- it "should get my index txt" do
92
+ it 'should get my index txt' do
93
93
  get :index, format: :txt
94
94
  response.should be_success
95
- response.should render_template("index")
95
+ response.should render_template('index')
96
96
  end
97
97
 
98
- describe "When my user_id is specified" do
99
- it "should redirect to my reservation" do
100
- get :index, :user_id => users(:user1).username
98
+ describe 'When my user_id is specified' do
99
+ it 'should redirect to my reservation' do
100
+ get :index, user_id: users(:user1).username
101
101
  response.should redirect_to reserves_url
102
102
  end
103
103
 
104
- it "should redirect to my reservation feed" do
105
- get :index, :user_id => users(:user1).username, format: 'rss'
104
+ it 'should redirect to my reservation feed' do
105
+ get :index, user_id: users(:user1).username, format: 'rss'
106
106
  response.should redirect_to reserves_url(format: :rss)
107
107
  end
108
108
 
109
- it "should redirect to my reservation txt" do
110
- get :index, :user_id => users(:user1).username, format: 'txt'
109
+ it 'should redirect to my reservation txt' do
110
+ get :index, user_id: users(:user1).username, format: 'txt'
111
111
  response.should redirect_to reserves_url(format: :txt)
112
112
  end
113
113
  end
114
114
 
115
- describe "When other user_id is specified" do
115
+ describe 'When other user_id is specified' do
116
116
  before(:each) do
117
117
  @user = users(:user3)
118
118
  end
119
119
 
120
- it "should not get any reserve as @reserves" do
121
- get :index, :user_id => @user.username
120
+ it 'should not get any reserve as @reserves' do
121
+ get :index, user_id: @user.username
122
122
  response.should be_forbidden
123
123
  end
124
124
  end
125
125
 
126
126
  it "should not get other user's index" do
127
- get :index, :user_id => users(:user2).username
127
+ get :index, user_id: users(:user2).username
128
128
  response.should be_forbidden
129
129
  end
130
130
  end
131
131
 
132
- describe "When not logged in" do
133
- it "assigns empty as @reserves" do
132
+ describe 'When not logged in' do
133
+ it 'assigns empty as @reserves' do
134
134
  get :index
135
135
  assigns(:reserves).should be_nil
136
136
  response.should redirect_to(new_user_session_url)
@@ -138,138 +138,138 @@ describe ReservesController do
138
138
  end
139
139
  end
140
140
 
141
- describe "GET show" do
142
- describe "When logged in as Administrator" do
141
+ describe 'GET show' do
142
+ describe 'When logged in as Administrator' do
143
143
  login_fixture_admin
144
144
 
145
- it "assigns the requested reserve as @reserve" do
145
+ it 'assigns the requested reserve as @reserve' do
146
146
  reserve = FactoryGirl.create(:reserve)
147
- get :show, :id => reserve.id
147
+ get :show, id: reserve.id
148
148
  assigns(:reserve).should eq(reserve)
149
149
  end
150
150
 
151
151
  it "should show other user's reservation" do
152
- get :show, :id => 3
152
+ get :show, id: 3
153
153
  response.should be_success
154
154
  end
155
155
  end
156
156
 
157
- describe "When logged in as Librarian" do
157
+ describe 'When logged in as Librarian' do
158
158
  login_fixture_librarian
159
159
 
160
- it "assigns the requested reserve as @reserve" do
160
+ it 'assigns the requested reserve as @reserve' do
161
161
  reserve = FactoryGirl.create(:reserve)
162
- get :show, :id => reserve.id
162
+ get :show, id: reserve.id
163
163
  assigns(:reserve).should eq(reserve)
164
164
  end
165
165
 
166
166
  it "should show other user's reservation" do
167
- get :show, :id => 3
167
+ get :show, id: 3
168
168
  response.should be_success
169
169
  end
170
170
  end
171
171
 
172
- describe "When logged in as User" do
172
+ describe 'When logged in as User' do
173
173
  login_fixture_user
174
174
 
175
- it "assigns the requested reserve as @reserve" do
175
+ it 'assigns the requested reserve as @reserve' do
176
176
  reserve = FactoryGirl.create(:reserve)
177
- get :show, :id => reserve.id
177
+ get :show, id: reserve.id
178
178
  assigns(:reserve).should eq(reserve)
179
179
  end
180
180
 
181
- it "should show my reservation" do
182
- get :show, :id => 3
181
+ it 'should show my reservation' do
182
+ get :show, id: 3
183
183
  response.should be_success
184
184
  end
185
-
185
+
186
186
  it "should not show other user's reservation" do
187
- get :show, :id => 5
187
+ get :show, id: 5
188
188
  response.should be_forbidden
189
189
  end
190
190
  end
191
191
 
192
- describe "When not logged in" do
192
+ describe 'When not logged in' do
193
193
  before(:each) do
194
194
  @reserve = FactoryGirl.create(:reserve)
195
195
  end
196
196
 
197
- it "assigns the requested reserve as @reserve" do
198
- get :show, :id => @reserve.id
197
+ it 'assigns the requested reserve as @reserve' do
198
+ get :show, id: @reserve.id
199
199
  assigns(:reserve).should eq(@reserve)
200
200
  end
201
201
 
202
- it "should be redirected to new_user_session_url" do
203
- get :show, :id => @reserve.id
202
+ it 'should be redirected to new_user_session_url' do
203
+ get :show, id: @reserve.id
204
204
  response.should redirect_to new_user_session_url
205
205
  end
206
206
  end
207
207
  end
208
208
 
209
- describe "GET new" do
210
- describe "When logged in as Administrator" do
209
+ describe 'GET new' do
210
+ describe 'When logged in as Administrator' do
211
211
  login_fixture_admin
212
212
 
213
- it "assigns the requested reserve as @reserve" do
213
+ it 'assigns the requested reserve as @reserve' do
214
214
  get :new
215
215
  assigns(:reserve).should_not be_valid
216
216
  end
217
217
 
218
218
  it "should get other user's reservation" do
219
- get :new, :user_id => users(:user1).username, :manifestation_id => 3
219
+ get :new, user_id: users(:user1).username, manifestation_id: 3
220
220
  assigns(:reserve).user.should eq users(:user1)
221
221
  response.should be_success
222
222
  end
223
223
  end
224
-
225
- describe "When logged in as Librarian" do
224
+
225
+ describe 'When logged in as Librarian' do
226
226
  login_fixture_librarian
227
227
 
228
- it "should not assign the requested reserve as @reserve" do
228
+ it 'should not assign the requested reserve as @reserve' do
229
229
  get :new
230
230
  assigns(:reserve).should_not be_valid
231
231
  end
232
232
 
233
- it "should get new template without user_id" do
234
- get :new, :manifestation_id => 3
233
+ it 'should get new template without user_id' do
234
+ get :new, manifestation_id: 3
235
235
  response.should be_success
236
236
  end
237
-
237
+
238
238
  it "should get other user's reservation" do
239
- get :new, :user_id => users(:user1).username, :manifestation_id => 3
239
+ get :new, user_id: users(:user1).username, manifestation_id: 3
240
240
  assigns(:reserve).user.should eq users(:user1)
241
241
  response.should be_success
242
242
  end
243
243
  end
244
244
 
245
- describe "When logged in as User" do
245
+ describe 'When logged in as User' do
246
246
  login_fixture_user
247
247
 
248
- it "should not assign the requested reserve as @reserve" do
248
+ it 'should not assign the requested reserve as @reserve' do
249
249
  get :new
250
250
  assigns(:reserve).should_not be_valid
251
251
  response.should be_success
252
252
  end
253
253
 
254
- it "should get my new reservation" do
255
- get :new, :manifestation_id => 3
254
+ it 'should get my new reservation' do
255
+ get :new, manifestation_id: 3
256
256
  response.should be_success
257
257
  end
258
-
258
+
259
259
  it "should not get other user's new reservation" do
260
- get :new, :user_id => users(:user2).username, :manifestation_id => 5
260
+ get :new, user_id: users(:user2).username, manifestation_id: 5
261
261
  response.should be_forbidden
262
262
  end
263
263
 
264
- it "should not get new reservation when user_number is not set" do
264
+ it 'should not get new reservation when user_number is not set' do
265
265
  sign_in users(:user2)
266
- get :new, :user_id => users(:user2).username, :manifestation_id => 3
266
+ get :new, user_id: users(:user2).username, manifestation_id: 3
267
267
  response.should be_forbidden
268
268
  end
269
269
  end
270
270
 
271
- describe "When not logged in" do
272
- it "should not assign the requested reserve as @reserve" do
271
+ describe 'When not logged in' do
272
+ it 'should not assign the requested reserve as @reserve' do
273
273
  get :new
274
274
  assigns(:reserve).should be_nil
275
275
  response.should redirect_to(new_user_session_url)
@@ -277,233 +277,233 @@ describe ReservesController do
277
277
  end
278
278
  end
279
279
 
280
- describe "GET edit" do
281
- describe "When logged in as Administrator" do
280
+ describe 'GET edit' do
281
+ describe 'When logged in as Administrator' do
282
282
  login_fixture_admin
283
283
 
284
- it "assigns the requested reserve as @reserve" do
284
+ it 'assigns the requested reserve as @reserve' do
285
285
  reserve = FactoryGirl.create(:reserve)
286
- get :edit, :id => reserve.id
286
+ get :edit, id: reserve.id
287
287
  assigns(:reserve).should eq(reserve)
288
288
  end
289
-
289
+
290
290
  it "should edit other user's reservation" do
291
- get :edit, :id => 3
291
+ get :edit, id: 3
292
292
  response.should be_success
293
293
  end
294
294
  end
295
295
 
296
- describe "When logged in as Librarian" do
296
+ describe 'When logged in as Librarian' do
297
297
  login_fixture_librarian
298
298
 
299
- it "assigns the requested reserve as @reserve" do
299
+ it 'assigns the requested reserve as @reserve' do
300
300
  reserve = FactoryGirl.create(:reserve)
301
- get :edit, :id => reserve.id
301
+ get :edit, id: reserve.id
302
302
  assigns(:reserve).should eq(reserve)
303
303
  end
304
304
 
305
- it "should edit reserve without user_id" do
306
- get :edit, :id => 3
305
+ it 'should edit reserve without user_id' do
306
+ get :edit, id: 3
307
307
  response.should be_success
308
308
  end
309
309
  end
310
310
 
311
- describe "When logged in as User" do
311
+ describe 'When logged in as User' do
312
312
  login_fixture_user
313
313
 
314
- it "assigns the requested reserve as @reserve" do
314
+ it 'assigns the requested reserve as @reserve' do
315
315
  reserve = FactoryGirl.create(:reserve)
316
- get :edit, :id => reserve.id
316
+ get :edit, id: reserve.id
317
317
  assigns(:reserve).should eq(reserve)
318
318
  end
319
319
 
320
- it "should edit my reservation" do
321
- get :edit, :id => 3
320
+ it 'should edit my reservation' do
321
+ get :edit, id: 3
322
322
  response.should be_success
323
323
  end
324
-
324
+
325
325
  it "should not edit other user's reservation" do
326
- get :edit, :id => 5
326
+ get :edit, id: 5
327
327
  response.should be_forbidden
328
328
  end
329
329
  end
330
330
 
331
- describe "When not logged in" do
332
- it "should not assign the requested reserve as @reserve" do
331
+ describe 'When not logged in' do
332
+ it 'should not assign the requested reserve as @reserve' do
333
333
  reserve = FactoryGirl.create(:reserve)
334
- get :edit, :id => reserve.id
334
+ get :edit, id: reserve.id
335
335
  response.should redirect_to(new_user_session_url)
336
336
  end
337
337
  end
338
338
  end
339
339
 
340
- describe "POST create" do
340
+ describe 'POST create' do
341
341
  before(:each) do
342
- @attrs = {:user_number => users(:user1).profile.user_number, :manifestation_id => 5}
343
- @invalid_attrs = {:user_number => users(:user1).profile.user_number, :manifestation_id => 'invalid'}
342
+ @attrs = { user_number: users(:user1).profile.user_number, manifestation_id: 5 }
343
+ @invalid_attrs = { user_number: users(:user1).profile.user_number, manifestation_id: 'invalid' }
344
344
  end
345
345
 
346
- describe "When logged in as Administrator" do
346
+ describe 'When logged in as Administrator' do
347
347
  login_fixture_admin
348
348
 
349
- describe "with valid params" do
350
- it "assigns a newly created reserve as @reserve" do
351
- post :create, :reserve => @attrs
349
+ describe 'with valid params' do
350
+ it 'assigns a newly created reserve as @reserve' do
351
+ post :create, reserve: @attrs
352
352
  assigns(:reserve).should be_valid
353
353
  end
354
354
 
355
- it "redirects to the created reserve" do
356
- post :create, :reserve => @attrs
355
+ it 'redirects to the created reserve' do
356
+ post :create, reserve: @attrs
357
357
  response.should redirect_to(assigns(:reserve))
358
358
  assigns(:reserve).expired_at.should be_nil
359
359
  end
360
360
  end
361
361
 
362
- describe "with invalid params" do
363
- it "assigns a newly created but unsaved reserve as @reserve" do
364
- post :create, :reserve => @invalid_attrs
362
+ describe 'with invalid params' do
363
+ it 'assigns a newly created but unsaved reserve as @reserve' do
364
+ post :create, reserve: @invalid_attrs
365
365
  assigns(:reserve).should_not be_valid
366
366
  end
367
367
 
368
- it "redirects to the list" do
369
- post :create, :reserve => @invalid_attrs
368
+ it 'redirects to the list' do
369
+ post :create, reserve: @invalid_attrs
370
370
  assigns(:reserve).expired_at.should be_nil
371
- response.should render_template("new")
371
+ response.should render_template('new')
372
372
  response.should be_success
373
373
  end
374
374
  end
375
375
 
376
- it "should not create reservation with past date" do
377
- post :create, :reserve => {:user_number => users(:user1).profile.user_number, :manifestation_id => 5, :expired_at => '1901-01-01'}
376
+ it 'should not create reservation with past date' do
377
+ post :create, reserve: { user_number: users(:user1).profile.user_number, manifestation_id: 5, expired_at: '1901-01-01' }
378
378
  assigns(:reserve).should_not be_valid
379
379
  response.should be_success
380
380
  end
381
381
 
382
382
  it "should create other user's reserve" do
383
- post :create, :reserve => {:user_number => users(:user1).profile.user_number, :manifestation_id => 5}
383
+ post :create, reserve: { user_number: users(:user1).profile.user_number, manifestation_id: 5 }
384
384
  assigns(:reserve).expired_at.should be_nil
385
385
  response.should redirect_to reserve_url(assigns(:reserve))
386
386
  end
387
387
 
388
- it "should not create reserve without manifestation_id" do
389
- post :create, :reserve => {:user_number => users(:admin).profile.user_number}
388
+ it 'should not create reserve without manifestation_id' do
389
+ post :create, reserve: { user_number: users(:admin).profile.user_number }
390
390
  response.should be_success
391
391
  end
392
392
 
393
- it "should not create reserve with missing user_number" do
394
- post :create, :reserve => {:user_number => 'missing', :manifestation_id => 5}
395
- response.should render_template("new")
393
+ it 'should not create reserve with missing user_number' do
394
+ post :create, reserve: { user_number: 'missing', manifestation_id: 5 }
395
+ response.should render_template('new')
396
396
  response.should be_success
397
397
  end
398
398
  end
399
399
 
400
- describe "When logged in as Librarian" do
400
+ describe 'When logged in as Librarian' do
401
401
  login_fixture_librarian
402
402
 
403
- describe "with valid params" do
404
- it "assigns a newly created reserve as @reserve" do
405
- post :create, :reserve => @attrs
403
+ describe 'with valid params' do
404
+ it 'assigns a newly created reserve as @reserve' do
405
+ post :create, reserve: @attrs
406
406
  assigns(:reserve).should be_valid
407
407
  end
408
408
 
409
- it "redirects to the created reserve" do
410
- post :create, :reserve => @attrs
409
+ it 'redirects to the created reserve' do
410
+ post :create, reserve: @attrs
411
411
  response.should redirect_to(assigns(:reserve))
412
412
  assigns(:reserve).expired_at.should be_nil
413
413
  end
414
414
 
415
- it "should send accepted messages" do
415
+ it 'should send accepted messages' do
416
416
  old_count = Message.count
417
- post :create, :reserve => @attrs
417
+ post :create, reserve: @attrs
418
418
  Message.count.should eq old_count + 2
419
419
  end
420
420
  end
421
421
 
422
- describe "with invalid params" do
423
- it "assigns a newly created but unsaved reserve as @reserve" do
424
- post :create, :reserve => @invalid_attrs
422
+ describe 'with invalid params' do
423
+ it 'assigns a newly created but unsaved reserve as @reserve' do
424
+ post :create, reserve: @invalid_attrs
425
425
  assigns(:reserve).should_not be_valid
426
426
  end
427
427
 
428
428
  it "re-renders the 'new' template" do
429
- post :create, :reserve => @invalid_attrs
429
+ post :create, reserve: @invalid_attrs
430
430
  assigns(:reserve).expired_at.should be_nil
431
- response.should render_template("new")
431
+ response.should render_template('new')
432
432
  response.should be_success
433
433
  end
434
434
  end
435
435
 
436
436
  it "should create other user's reserve" do
437
- post :create, :reserve => {:user_number => users(:user1).profile.user_number, :manifestation_id => 5}
437
+ post :create, reserve: { user_number: users(:user1).profile.user_number, manifestation_id: 5 }
438
438
  assigns(:reserve).should be_valid
439
439
  assigns(:reserve).expired_at.should be_nil
440
440
  response.should redirect_to reserve_url(assigns(:reserve))
441
441
  end
442
442
 
443
- it "should not create reserve over reserve_limit" do
444
- post :create, :reserve => {:user_number => users(:admin).profile.user_number, :manifestation_id => 5}
443
+ it 'should not create reserve over reserve_limit' do
444
+ post :create, reserve: { user_number: users(:admin).profile.user_number, manifestation_id: 5 }
445
445
  assigns(:reserve).errors[:base].include?(I18n.t('reserve.excessed_reservation_limit')).should be_truthy
446
446
  end
447
447
  end
448
448
 
449
- describe "When logged in as User" do
449
+ describe 'When logged in as User' do
450
450
  login_fixture_user
451
451
 
452
- describe "with valid params" do
453
- it "assigns a newly created reserve as @reserve" do
454
- post :create, :reserve => @attrs
452
+ describe 'with valid params' do
453
+ it 'assigns a newly created reserve as @reserve' do
454
+ post :create, reserve: @attrs
455
455
  assigns(:reserve).should be_valid
456
456
  end
457
457
 
458
- it "redirects to the created reserve" do
459
- post :create, :reserve => @attrs
458
+ it 'redirects to the created reserve' do
459
+ post :create, reserve: @attrs
460
460
  response.should redirect_to(assigns(:reserve))
461
461
  assigns(:reserve).expired_at.should be_nil
462
462
  end
463
463
  end
464
464
 
465
- describe "with invalid params" do
466
- it "assigns a newly created but unsaved reserve as @reserve" do
467
- post :create, :reserve => @invalid_attrs
465
+ describe 'with invalid params' do
466
+ it 'assigns a newly created but unsaved reserve as @reserve' do
467
+ post :create, reserve: @invalid_attrs
468
468
  assigns(:reserve).should_not be_valid
469
469
  end
470
470
 
471
471
  it "re-renders the 'new' template" do
472
- post :create, :reserve => @invalid_attrs
472
+ post :create, reserve: @invalid_attrs
473
473
  assigns(:reserve).expired_at.should be_nil
474
- response.should render_template("new")
474
+ response.should render_template('new')
475
475
  response.should be_success
476
476
  end
477
477
  end
478
478
 
479
479
  it "should not create other user's reservation" do
480
- post :create, :reserve => {:user_number => users(:user2).profile.user_number, :manifestation_id => 6}
480
+ post :create, reserve: { user_number: users(:user2).profile.user_number, manifestation_id: 6 }
481
481
  assigns(:reserve).expired_at.should be_nil
482
482
  response.should be_forbidden
483
483
  end
484
484
  end
485
485
 
486
- describe "When not logged in" do
487
- describe "with valid params" do
488
- it "assigns a newly created reserve as @reserve" do
489
- post :create, :reserve => @attrs
486
+ describe 'When not logged in' do
487
+ describe 'with valid params' do
488
+ it 'assigns a newly created reserve as @reserve' do
489
+ post :create, reserve: @attrs
490
490
  assigns(:reserve).should be_nil
491
491
  end
492
492
 
493
- it "redirects to the login page" do
494
- post :create, :reserve => @attrs
493
+ it 'redirects to the login page' do
494
+ post :create, reserve: @attrs
495
495
  response.should redirect_to new_user_session_url
496
496
  end
497
497
  end
498
498
 
499
- describe "with invalid params" do
500
- it "assigns a newly created but unsaved reserve as @reserve" do
501
- post :create, :reserve => @invalid_attrs
499
+ describe 'with invalid params' do
500
+ it 'assigns a newly created but unsaved reserve as @reserve' do
501
+ post :create, reserve: @invalid_attrs
502
502
  assigns(:reserve).should be_nil
503
503
  end
504
504
 
505
- it "redirects to the login page" do
506
- post :create, :reserve => @invalid_attrs
505
+ it 'redirects to the login page' do
506
+ post :create, reserve: @invalid_attrs
507
507
  assigns(:reserve).should be_nil
508
508
  response.should redirect_to new_user_session_url
509
509
  end
@@ -511,67 +511,67 @@ describe ReservesController do
511
511
  end
512
512
  end
513
513
 
514
- describe "PUT update" do
514
+ describe 'PUT update' do
515
515
  before(:each) do
516
516
  @reserve = FactoryGirl.create(:reserve)
517
517
  @attrs = FactoryGirl.attributes_for(:reserve)
518
- @invalid_attrs = {:manifestation_id => 'invalid'}
518
+ @invalid_attrs = { manifestation_id: 'invalid' }
519
519
  end
520
520
 
521
- describe "When logged in as Administrator" do
521
+ describe 'When logged in as Administrator' do
522
522
  login_fixture_admin
523
523
 
524
- describe "with valid params" do
525
- it "updates the requested reserve" do
526
- put :update, :id => @reserve.id, :reserve => @attrs
524
+ describe 'with valid params' do
525
+ it 'updates the requested reserve' do
526
+ put :update, id: @reserve.id, reserve: @attrs
527
527
  end
528
528
 
529
- it "assigns the requested reserve as @reserve" do
530
- put :update, :id => @reserve.id, :reserve => @attrs
529
+ it 'assigns the requested reserve as @reserve' do
530
+ put :update, id: @reserve.id, reserve: @attrs
531
531
  assigns(:reserve).should eq(@reserve)
532
532
  response.should redirect_to(assigns(:reserve))
533
533
  end
534
534
  end
535
535
 
536
- describe "with invalid params" do
537
- it "assigns the requested reserve as @reserve" do
538
- put :update, :id => @reserve.id, :reserve => @invalid_attrs
536
+ describe 'with invalid params' do
537
+ it 'assigns the requested reserve as @reserve' do
538
+ put :update, id: @reserve.id, reserve: @invalid_attrs
539
539
  end
540
540
 
541
541
  it "re-renders the 'edit' template" do
542
- put :update, :id => @reserve.id, :reserve => @invalid_attrs
543
- response.should render_template("edit")
542
+ put :update, id: @reserve.id, reserve: @invalid_attrs
543
+ response.should render_template('edit')
544
544
  end
545
545
  end
546
546
 
547
- it "should not update reserve without manifestation_id" do
548
- put :update, :id => 1, :reserve => {:user_number => users(:admin).profile.user_number, :manifestation_id => nil}
547
+ it 'should not update reserve without manifestation_id' do
548
+ put :update, id: 1, reserve: { user_number: users(:admin).profile.user_number, manifestation_id: nil }
549
549
  assigns(:reserve).should_not be_valid
550
550
  response.should be_success
551
551
  end
552
-
552
+
553
553
  it "should update other user's reservation without user_id" do
554
- put :update, :id => 3, :reserve => {:user_number => users(:user1).profile.user_number}
554
+ put :update, id: 3, reserve: { user_number: users(:user1).profile.user_number }
555
555
  assigns(:reserve).should be_valid
556
556
  response.should redirect_to reserve_url(assigns(:reserve))
557
557
  end
558
558
 
559
- it "should not update retained reservations if item_identifier is invalid" do
560
- put :update, :id => 14, :reserve => {:item_identifier => 'invalid'}
559
+ it 'should not update retained reservations if item_identifier is invalid' do
560
+ put :update, id: 14, reserve: { item_identifier: 'invalid' }
561
561
  assigns(:reserve).should_not be_valid
562
562
  response.should be_success
563
563
  end
564
564
 
565
- it "should not update retained reservations if force_retaining is disabled" do
566
- put :update, :id => 15, :reserve => {:item_identifier => '00021'}
565
+ it 'should not update retained reservations if force_retaining is disabled' do
566
+ put :update, id: 15, reserve: { item_identifier: '00021' }
567
567
  assigns(:reserve).should_not be_valid
568
568
  response.should be_success
569
569
  assigns(:reserve).current_state.should eq 'requested'
570
570
  reserves(:reserve_00014).current_state.should eq 'retained'
571
571
  end
572
572
 
573
- it "should update retained reservations if force_retaining is enabled" do
574
- put :update, :id => 15, :reserve => {:item_identifier => '00021', :force_retaining => '1'}
573
+ it 'should update retained reservations if force_retaining is enabled' do
574
+ put :update, id: 15, reserve: { item_identifier: '00021', force_retaining: '1' }
575
575
  assigns(:reserve).should be_valid
576
576
  assigns(:reserve).current_state.should eq 'retained'
577
577
  response.should redirect_to reserve_url(assigns(:reserve))
@@ -579,195 +579,195 @@ describe ReservesController do
579
579
  end
580
580
  end
581
581
 
582
- describe "When logged in as Librarian" do
582
+ describe 'When logged in as Librarian' do
583
583
  login_fixture_librarian
584
584
 
585
- describe "with valid params" do
586
- it "updates the requested reserve" do
587
- put :update, :id => @reserve.id, :reserve => @attrs
585
+ describe 'with valid params' do
586
+ it 'updates the requested reserve' do
587
+ put :update, id: @reserve.id, reserve: @attrs
588
588
  end
589
589
 
590
- it "assigns the requested reserve as @reserve" do
591
- put :update, :id => @reserve.id, :reserve => @attrs
590
+ it 'assigns the requested reserve as @reserve' do
591
+ put :update, id: @reserve.id, reserve: @attrs
592
592
  assigns(:reserve).should eq(@reserve)
593
593
  response.should redirect_to(assigns(:reserve))
594
594
  end
595
595
  end
596
596
 
597
- describe "with invalid params" do
598
- it "assigns the reserve as @reserve" do
599
- put :update, :id => @reserve.id, :reserve => @invalid_attrs
597
+ describe 'with invalid params' do
598
+ it 'assigns the reserve as @reserve' do
599
+ put :update, id: @reserve.id, reserve: @invalid_attrs
600
600
  assigns(:reserve).should_not be_valid
601
601
  end
602
602
 
603
603
  it "re-renders the 'edit' template" do
604
- put :update, :id => @reserve.id, :reserve => @invalid_attrs
605
- response.should render_template("edit")
604
+ put :update, id: @reserve.id, reserve: @invalid_attrs
605
+ response.should render_template('edit')
606
606
  end
607
607
  end
608
608
 
609
609
  it "should cancel other user's reservation" do
610
610
  old_message_requests_count = MessageRequest.count
611
- put :update, :id => 3, :reserve => {:user_number => users(:user1).profile.user_number}, :mode => 'cancel'
611
+ put :update, id: 3, reserve: { user_number: users(:user1).profile.user_number }, mode: 'cancel'
612
612
  flash[:notice].should eq I18n.t('reserve.reservation_was_canceled')
613
613
  assigns(:reserve).current_state.should eq 'canceled'
614
614
  MessageRequest.count.should eq old_message_requests_count + 2
615
615
  response.should redirect_to reserve_url(assigns(:reserve))
616
616
  end
617
617
 
618
- it "should update reserve without user_id" do
619
- put :update, :id => 3, :reserve => {:user_number => users(:user1).profile.user_number}
618
+ it 'should update reserve without user_id' do
619
+ put :update, id: 3, reserve: { user_number: users(:user1).profile.user_number }
620
620
  assigns(:reserve).should be_valid
621
621
  response.should redirect_to reserve_url(assigns(:reserve))
622
622
  end
623
623
 
624
624
  it "should update other user's reservation" do
625
- put :update, :id => 3, :reserve => {:user_number => users(:user1).profile.user_number}
625
+ put :update, id: 3, reserve: { user_number: users(:user1).profile.user_number }
626
626
  assigns(:reserve).should be_valid
627
627
  response.should redirect_to reserve_url(assigns(:reserve))
628
628
  end
629
629
  end
630
630
 
631
- describe "When logged in as User" do
631
+ describe 'When logged in as User' do
632
632
  login_fixture_user
633
633
 
634
- describe "with valid params" do
635
- it "updates the requested reserve" do
636
- put :update, :id => @reserve.id, :reserve => @attrs
634
+ describe 'with valid params' do
635
+ it 'updates the requested reserve' do
636
+ put :update, id: @reserve.id, reserve: @attrs
637
637
  end
638
638
 
639
- it "assigns the requested reserve as @reserve" do
640
- put :update, :id => @reserve.id, :reserve => @attrs
639
+ it 'assigns the requested reserve as @reserve' do
640
+ put :update, id: @reserve.id, reserve: @attrs
641
641
  assigns(:reserve).should eq(@reserve)
642
642
  response.should be_forbidden
643
643
  end
644
644
  end
645
645
 
646
- describe "with invalid params" do
647
- it "assigns the requested reserve as @reserve" do
648
- put :update, :id => @reserve.id, :reserve => @invalid_attrs
646
+ describe 'with invalid params' do
647
+ it 'assigns the requested reserve as @reserve' do
648
+ put :update, id: @reserve.id, reserve: @invalid_attrs
649
649
  response.should be_forbidden
650
650
  end
651
651
  end
652
652
 
653
- it "should cancel my reservation" do
653
+ it 'should cancel my reservation' do
654
654
  old_message_requests_count = MessageRequest.count
655
- put :update, :id => 3, :mode => 'cancel'
655
+ put :update, id: 3, mode: 'cancel'
656
656
  flash[:notice].should eq I18n.t('reserve.reservation_was_canceled')
657
657
  assigns(:reserve).current_state.should eq 'canceled'
658
658
  MessageRequest.count.should eq old_message_requests_count + 2
659
659
  response.should redirect_to reserve_url(assigns(:reserve))
660
660
  end
661
661
 
662
- it "should update my reservation" do
663
- put :update, :id => 3, :reserve => {:user_number => users(:user1).profile.user_number}
664
- flash[:notice].should eq I18n.t('controller.successfully_updated', :model => I18n.t('activerecord.models.reserve'))
662
+ it 'should update my reservation' do
663
+ put :update, id: 3, reserve: { user_number: users(:user1).profile.user_number }
664
+ flash[:notice].should eq I18n.t('controller.successfully_updated', model: I18n.t('activerecord.models.reserve'))
665
665
  response.should redirect_to reserve_url(assigns(:reserve))
666
666
  end
667
667
 
668
668
  it "should not update other user's reservation" do
669
- put :update, :id => 5, :reserve => {:user_number => users(:user2).profile.user_number}
669
+ put :update, id: 5, reserve: { user_number: users(:user2).profile.user_number }
670
670
  response.should be_forbidden
671
671
  end
672
-
672
+
673
673
  it "should not cancel other user's reservation" do
674
- put :update, :id => 5, :reserve => {:user_number => users(:user1).profile.user_number}, :mode => 'cancel'
674
+ put :update, id: 5, reserve: { user_number: users(:user1).profile.user_number }, mode: 'cancel'
675
675
  response.should be_forbidden
676
676
  end
677
677
  end
678
678
 
679
- describe "When not logged in" do
680
- describe "with valid params" do
681
- it "updates the requested reserve" do
682
- put :update, :id => @reserve.id, :reserve => @attrs
679
+ describe 'When not logged in' do
680
+ describe 'with valid params' do
681
+ it 'updates the requested reserve' do
682
+ put :update, id: @reserve.id, reserve: @attrs
683
683
  end
684
684
 
685
- it "should be forbidden" do
686
- put :update, :id => @reserve.id, :reserve => @attrs
685
+ it 'should be forbidden' do
686
+ put :update, id: @reserve.id, reserve: @attrs
687
687
  response.should redirect_to(new_user_session_url)
688
688
  end
689
689
  end
690
690
 
691
- describe "with invalid params" do
692
- it "assigns the requested reserve as @reserve" do
693
- put :update, :id => @reserve.id, :reserve => @invalid_attrs
691
+ describe 'with invalid params' do
692
+ it 'assigns the requested reserve as @reserve' do
693
+ put :update, id: @reserve.id, reserve: @invalid_attrs
694
694
  response.should redirect_to(new_user_session_url)
695
695
  end
696
696
  end
697
697
  end
698
698
  end
699
699
 
700
- describe "DELETE destroy" do
700
+ describe 'DELETE destroy' do
701
701
  before(:each) do
702
702
  @reserve = FactoryGirl.create(:reserve)
703
703
  end
704
704
 
705
- describe "When logged in as Administrator" do
705
+ describe 'When logged in as Administrator' do
706
706
  login_fixture_admin
707
707
 
708
- it "destroys the requested reserve" do
709
- delete :destroy, :id => @reserve.id
708
+ it 'destroys the requested reserve' do
709
+ delete :destroy, id: @reserve.id
710
710
  end
711
711
 
712
- it "redirects to the reserves list" do
713
- delete :destroy, :id => @reserve.id
712
+ it 'redirects to the reserves list' do
713
+ delete :destroy, id: @reserve.id
714
714
  response.should redirect_to(reserves_url)
715
715
  end
716
716
 
717
717
  it "should destroy other user's reservation" do
718
- delete :destroy, :id => 3
718
+ delete :destroy, id: 3
719
719
  response.should redirect_to reserves_url
720
720
  end
721
721
  end
722
722
 
723
- describe "When logged in as Librarian" do
723
+ describe 'When logged in as Librarian' do
724
724
  login_fixture_librarian
725
725
 
726
- it "destroys the requested reserve" do
727
- delete :destroy, :id => @reserve.id
726
+ it 'destroys the requested reserve' do
727
+ delete :destroy, id: @reserve.id
728
728
  end
729
729
 
730
- it "redirects to the reserves list" do
731
- delete :destroy, :id => @reserve.id
730
+ it 'redirects to the reserves list' do
731
+ delete :destroy, id: @reserve.id
732
732
  response.should redirect_to(reserves_url)
733
733
  end
734
734
 
735
735
  it "should destroy other user's reservation" do
736
- delete :destroy, :id => 3
736
+ delete :destroy, id: 3
737
737
  response.should redirect_to reserves_url
738
738
  end
739
739
  end
740
740
 
741
- describe "When logged in as User" do
741
+ describe 'When logged in as User' do
742
742
  login_fixture_user
743
743
 
744
- it "destroys the requested reserve" do
745
- delete :destroy, :id => @reserve.id
744
+ it 'destroys the requested reserve' do
745
+ delete :destroy, id: @reserve.id
746
746
  end
747
747
 
748
- it "should be forbidden" do
749
- delete :destroy, :id => @reserve.id
748
+ it 'should be forbidden' do
749
+ delete :destroy, id: @reserve.id
750
750
  response.should be_forbidden
751
751
  end
752
752
 
753
- it "should destroy my reservation" do
754
- delete :destroy, :id => 3
753
+ it 'should destroy my reservation' do
754
+ delete :destroy, id: 3
755
755
  response.should redirect_to reserves_url
756
756
  end
757
757
 
758
758
  it "should not destroy other user's reservation" do
759
- delete :destroy, :id => 5
759
+ delete :destroy, id: 5
760
760
  response.should be_forbidden
761
761
  end
762
762
  end
763
763
 
764
- describe "When not logged in" do
765
- it "destroys the requested reserve" do
766
- delete :destroy, :id => @reserve.id
764
+ describe 'When not logged in' do
765
+ it 'destroys the requested reserve' do
766
+ delete :destroy, id: @reserve.id
767
767
  end
768
768
 
769
- it "should be forbidden" do
770
- delete :destroy, :id => @reserve.id
769
+ it 'should be forbidden' do
770
+ delete :destroy, id: @reserve.id
771
771
  response.should redirect_to(new_user_session_url)
772
772
  end
773
773
  end