enju_circulation 0.1.2 → 0.2.0.beta.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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -3
  3. data/app/controllers/carrier_type_has_checkout_types_controller.rb +14 -4
  4. data/app/controllers/checked_items_controller.rb +13 -2
  5. data/app/controllers/checkins_controller.rb +13 -3
  6. data/app/controllers/checkout_types_controller.rb +12 -2
  7. data/app/controllers/checkouts_controller.rb +26 -25
  8. data/app/controllers/circulation_statuses_controller.rb +11 -1
  9. data/app/controllers/concerns/enju_circulation/controller.rb +12 -0
  10. data/app/controllers/demands_controller.rb +12 -2
  11. data/app/controllers/item_has_use_restrictions_controller.rb +13 -2
  12. data/app/controllers/lending_policies_controller.rb +18 -4
  13. data/app/controllers/manifestation_checkout_stats_controller.rb +14 -6
  14. data/app/controllers/manifestation_reserve_stats_controller.rb +15 -4
  15. data/app/controllers/reserves_controller.rb +17 -9
  16. data/app/controllers/use_restrictions_controller.rb +11 -1
  17. data/app/controllers/user_checkout_stats_controller.rb +14 -4
  18. data/app/controllers/user_group_has_checkout_types_controller.rb +12 -2
  19. data/app/controllers/user_reserve_stats_controller.rb +14 -4
  20. data/app/helpers/items_helper.rb +2 -2
  21. data/app/jobs/manifestation_checkout_stat_job.rb +7 -0
  22. data/app/jobs/manifestation_reserve_stat_job.rb +7 -0
  23. data/app/jobs/user_checkout_stat_job.rb +7 -0
  24. data/app/jobs/user_reserve_stat_job.rb +7 -0
  25. data/app/models/checked_item.rb +1 -1
  26. data/app/models/concerns/enju_circulation/enju_accept.rb +16 -0
  27. data/app/models/concerns/enju_circulation/enju_basket.rb +30 -0
  28. data/app/models/concerns/enju_circulation/enju_carrier_type.rb +11 -0
  29. data/app/models/concerns/enju_circulation/enju_item.rb +157 -0
  30. data/app/models/concerns/enju_circulation/enju_manifestation.rb +77 -0
  31. data/app/models/concerns/enju_circulation/enju_profile.rb +13 -0
  32. data/app/models/concerns/enju_circulation/enju_user.rb +50 -0
  33. data/app/models/concerns/enju_circulation/enju_user_group.rb +17 -0
  34. data/app/models/concerns/enju_circulation/enju_withdraw.rb +16 -0
  35. data/app/models/manifestation_checkout_stat_state_machine.rb +1 -1
  36. data/app/models/reserve.rb +7 -2
  37. data/app/policies/carrier_type_has_checkout_type_policy.rb +21 -0
  38. data/app/policies/checked_item_policy.rb +21 -0
  39. data/app/policies/checkin_policy.rb +21 -0
  40. data/app/policies/checkout_policy.rb +39 -0
  41. data/app/policies/checkout_type_policy.rb +23 -0
  42. data/app/policies/circulation_status_policy.rb +23 -0
  43. data/app/policies/demand_policy.rb +21 -0
  44. data/app/policies/item_has_use_restriction_policy.rb +21 -0
  45. data/app/policies/item_policy.rb +27 -0
  46. data/app/policies/lending_policy_policy.rb +21 -0
  47. data/app/policies/manifestation_checkout_stat_policy.rb +21 -0
  48. data/app/policies/manifestation_reserve_stat_policy.rb +21 -0
  49. data/app/policies/reserve_policy.rb +37 -0
  50. data/app/policies/use_restriction_policy.rb +23 -0
  51. data/app/policies/user_checkout_stat_policy.rb +21 -0
  52. data/app/policies/user_group_has_checkout_type_policy.rb +21 -0
  53. data/app/policies/user_reserve_stat_policy.rb +21 -0
  54. data/app/views/carrier_type_has_checkout_types/index.html.erb +3 -3
  55. data/app/views/carrier_type_has_checkout_types/show.html.erb +1 -1
  56. data/app/views/carrier_types/_carrier_type_has_checkout_type_fields.html.erb +5 -0
  57. data/app/views/carrier_types/_checkout_form.html.erb +2 -4
  58. data/app/views/checkout_types/index.html.erb +4 -4
  59. data/app/views/checkout_types/show.html.erb +2 -2
  60. data/app/views/checkouts/_index.html.erb +1 -1
  61. data/app/views/checkouts/_index_overdue.html.erb +4 -5
  62. data/app/views/checkouts/_index_user.html.erb +5 -5
  63. data/app/views/checkouts/_list.html.erb +2 -2
  64. data/app/views/checkouts/_reserved_facet.html.erb +2 -2
  65. data/app/views/checkouts/edit.html.erb +1 -1
  66. data/app/views/checkouts/index.html.erb +2 -2
  67. data/app/views/checkouts/index.rss.builder +2 -2
  68. data/app/views/checkouts/index.txt.erb +1 -1
  69. data/app/views/checkouts/show.html.erb +10 -6
  70. data/app/views/circulation_statuses/index.html.erb +4 -4
  71. data/app/views/circulation_statuses/show.html.erb +1 -1
  72. data/app/views/reserves/_state_facet.html.erb +2 -2
  73. data/app/views/reserves/index.html.erb +6 -4
  74. data/app/views/reserves/show.html.erb +1 -1
  75. data/app/views/use_restrictions/index.html.erb +4 -4
  76. data/app/views/use_restrictions/show.html.erb +1 -1
  77. data/app/views/user_group_has_checkout_types/index.html.erb +3 -3
  78. data/app/views/user_group_has_checkout_types/show.html.erb +1 -1
  79. data/app/views/user_groups/_checkout_form.html.erb +2 -16
  80. data/app/views/user_groups/_user_group_has_checkout_type_fields.html.erb +14 -0
  81. data/db/migrate/20160703184619_add_most_recent_to_reserve_transitions.rb +9 -0
  82. data/db/migrate/20160703184650_add_most_recent_to_manifestation_checkout_stat_transitions.rb +9 -0
  83. data/db/migrate/20160703184723_add_most_recent_to_manifestation_reserve_stat_transitions.rb +9 -0
  84. data/db/migrate/20160703184747_add_most_recent_to_user_checkout_stat_transitions.rb +9 -0
  85. data/db/migrate/20160703184805_add_most_recent_to_user_reserve_stat_transitions.rb +9 -0
  86. data/db/migrate/20160703190209_add_foreign_key_on_manifestation_id_to_reserve.rb +5 -0
  87. data/lib/enju_circulation/version.rb +1 -1
  88. data/lib/enju_circulation.rb +0 -20
  89. data/lib/generators/enju_circulation/setup/setup_generator.rb +16 -4
  90. data/lib/tasks/enju_circulation_tasks.rake +1 -1
  91. data/spec/controllers/carrier_type_has_checkout_types_controller_spec.rb +13 -13
  92. data/spec/controllers/checked_items_controller_spec.rb +6 -6
  93. data/spec/controllers/checkins_controller_spec.rb +6 -6
  94. data/spec/controllers/checkout_types_controller_spec.rb +11 -11
  95. data/spec/controllers/checkouts_controller_spec.rb +72 -71
  96. data/spec/controllers/circulation_statuses_controller_spec.rb +12 -12
  97. data/spec/controllers/item_has_use_restrictions_controller_spec.rb +11 -11
  98. data/spec/controllers/lending_policies_controller_spec.rb +14 -14
  99. data/spec/controllers/manifestation_checkout_stats_controller_spec.rb +6 -6
  100. data/spec/controllers/manifestation_reserve_stats_controller_spec.rb +6 -6
  101. data/spec/controllers/reserves_controller_spec.rb +5 -5
  102. data/spec/controllers/use_restrictions_controller_spec.rb +14 -14
  103. data/spec/controllers/user_checkout_stats_controller_spec.rb +8 -8
  104. data/spec/controllers/user_group_has_checkout_types_controller_spec.rb +11 -11
  105. data/spec/controllers/user_reserve_stats_controller_spec.rb +8 -8
  106. data/spec/dummy/app/assets/javascripts/application.js +1 -0
  107. data/spec/dummy/app/controllers/application_controller.rb +8 -4
  108. data/spec/dummy/app/models/user.rb +3 -5
  109. data/spec/dummy/config/application.rb +6 -37
  110. data/spec/dummy/config/environments/development.rb +22 -18
  111. data/spec/dummy/config/environments/production.rb +46 -34
  112. data/spec/dummy/config/environments/test.rb +19 -14
  113. data/spec/dummy/config/initializers/enju_leaf.rb +5 -0
  114. data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +13 -0
  115. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
  116. data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
  117. data/spec/dummy/db/schema.rb +30 -2
  118. data/spec/fixtures/profiles.yml +1 -1
  119. data/spec/models/manifestation_checkout_stat_spec.rb +3 -4
  120. data/spec/models/manifestation_reserve_stat_spec.rb +1 -1
  121. data/spec/models/user_checkout_stat_spec.rb +1 -1
  122. data/spec/models/user_reserve_stat_spec.rb +1 -1
  123. data/spec/support/devise.rb +2 -2
  124. data/spec/views/checkout_types/index.html.erb_spec.rb +1 -0
  125. data/spec/views/checkout_types/show.html.erb_spec.rb +1 -0
  126. data/spec/views/checkouts/index.html.erb_spec.rb +1 -3
  127. data/spec/views/checkouts/show.html.erb_spec.rb +5 -4
  128. data/spec/views/profiles/show.html.erb_spec.rb +2 -1
  129. data/spec/views/reserves/index.html.erb_spec.rb +3 -0
  130. data/spec/views/use_restrictions/index.html.erb_spec.rb +1 -0
  131. data/spec/views/use_restrictions/show.html.erb_spec.rb +1 -0
  132. metadata +147 -38
  133. data/app/models/enju_circulation/ability.rb +0 -114
  134. data/app/views/circulation_statuses/show.mobile.erb +0 -24
  135. data/app/workers/manifestation_checkout_stat_queue.rb +0 -7
  136. data/app/workers/manifestation_reserve_stat_queue.rb +0 -7
  137. data/app/workers/user_checkout_stat_queue.rb +0 -7
  138. data/app/workers/user_reserve_stat_queue.rb +0 -7
  139. data/lib/enju_circulation/accept.rb +0 -23
  140. data/lib/enju_circulation/basket.rb +0 -37
  141. data/lib/enju_circulation/carrier_type.rb +0 -15
  142. data/lib/enju_circulation/controller.rb +0 -21
  143. data/lib/enju_circulation/item.rb +0 -166
  144. data/lib/enju_circulation/manifestation.rb +0 -84
  145. data/lib/enju_circulation/profile.rb +0 -23
  146. data/lib/enju_circulation/user.rb +0 -61
  147. data/lib/enju_circulation/user_group.rb +0 -21
  148. data/lib/enju_circulation/withdraw.rb +0 -23
  149. data/spec/dummy/app/models/ability.rb +0 -111
  150. data/spec/dummy/app/models/local_agent.rb +0 -13
  151. data/spec/dummy/config/application.yml +0 -42
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe CheckoutsController 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
  Checkout.reindex
9
9
  end
@@ -22,7 +22,7 @@ describe CheckoutsController do
22
22
  end
23
23
 
24
24
  it "should get other user's index" do
25
- get :index, :user_id => users(:admin).username
25
+ get :index, user_id: users(:admin).username
26
26
  response.should be_success
27
27
  assigns(:checkouts).should eq users(:admin).checkouts.not_returned.order('checkouts.id DESC').page(1)
28
28
  end
@@ -37,41 +37,42 @@ describe CheckoutsController do
37
37
  end
38
38
 
39
39
  it "should get index txt" do
40
- get :index, :format => 'txt'
40
+ get :index, format: 'txt'
41
+ assigns(:checkouts).count.should eq Checkout.count
41
42
  response.should be_success
42
43
  end
43
44
 
44
45
  it "should get index rss" do
45
- get :index, :format => 'rss'
46
+ get :index, format: 'rss'
46
47
  response.should be_success
47
48
  end
48
49
 
49
50
  it "should get overdue index" do
50
- get :index, :view => 'overdue'
51
+ get :index, days_overdue: 1
51
52
  assigns(:checkouts).should eq Checkout.overdue(1.day.ago.beginning_of_day).order('checkouts.id DESC').page(1)
52
53
  response.should be_success
53
54
  end
54
55
 
55
- it "should get overdue index with nunber of days_overdue" do
56
- get :index, :view => 'overdue', :days_overdue => 2
56
+ it "should get overdue index with number of days_overdue" do
57
+ get :index, days_overdue: 2
57
58
  response.should be_success
58
59
  assigns(:checkouts).size.should > 0
59
60
  end
60
61
 
61
62
  it "should get overdue index with invalid number of days_overdue" do
62
- get :index, :view => 'overdue', :days_overdue => 'invalid days'
63
+ get :index, days_overdue: 'invalid days'
63
64
  response.should be_success
64
65
  assigns(:checkouts).size.should > 0
65
66
  end
66
67
 
67
68
  it "should get other user's index" do
68
- get :index, :user_id => users(:admin).username
69
+ get :index, user_id: users(:admin).username
69
70
  response.should be_success
70
71
  assigns(:checkouts).should eq users(:admin).checkouts.not_returned.order('checkouts.id DESC').page(1)
71
72
  end
72
73
 
73
74
  it "should get index with item_id" do
74
- get :index, :item_id => 1
75
+ get :index, item_id: 1
75
76
  response.should be_success
76
77
  assigns(:checkouts).should eq items(:item_00001).checkouts.order('checkouts.id DESC').page(1)
77
78
  end
@@ -89,37 +90,37 @@ describe CheckoutsController do
89
90
 
90
91
  it "should be forbidden if other's username is specified" do
91
92
  user = users(:user3)
92
- get :index, :user_id => user.username
93
+ get :index, user_id: user.username
93
94
  assigns(:checkouts).should be_nil
94
95
  response.should be_forbidden
95
96
  end
96
97
 
97
98
  it "should get my index feed" do
98
- get :index, :format => 'rss'
99
+ get :index, format: 'rss'
99
100
  response.should be_success
100
101
  assigns(:checkouts).should eq(users(:user1).checkouts.order('checkouts.created_at DESC').page(1))
101
102
  end
102
103
 
103
104
  it "should get my index with user_id" do
104
- get :index, :user_id => users(:user1).username
105
+ get :index, user_id: users(:user1).username
105
106
  assigns(:checkouts).should be_nil
106
107
  response.should redirect_to checkouts_url
107
108
  end
108
109
 
109
110
  it "should get my index in txt format" do
110
- get :index, :user_id => users(:user1).username, :format => 'txt'
111
- response.should redirect_to checkouts_url(:format => :txt)
111
+ get :index, user_id: users(:user1).username, format: 'txt'
112
+ response.should redirect_to checkouts_url(format: :txt)
112
113
  assigns(:checkouts).should be_nil
113
114
  end
114
115
 
115
116
  it "should get my index in rss format" do
116
- get :index, :user_id => users(:user1).username, :format => 'rss'
117
- response.should redirect_to checkouts_url(:format => :rss)
117
+ get :index, user_id: users(:user1).username, format: 'rss'
118
+ response.should redirect_to checkouts_url(format: :rss)
118
119
  assigns(:checkouts).should be_nil
119
120
  end
120
121
 
121
122
  it "should not get other user's index" do
122
- get :index, :user_id => users(:admin).username
123
+ get :index, user_id: users(:admin).username
123
124
  response.should be_forbidden
124
125
  end
125
126
  end
@@ -133,16 +134,16 @@ describe CheckoutsController do
133
134
 
134
135
  it "assigns his own checkouts as @checkouts" do
135
136
  token = "577830b08ecf9c4c4333d599a57a6f44a7fe76c0"
136
- user = Profile.where(:checkout_icalendar_token => token).first.user
137
- get :index, :icalendar_token => token
137
+ user = Profile.where(checkout_icalendar_token: token).first.user
138
+ get :index, icalendar_token: token
138
139
  assigns(:checkouts).should eq user.checkouts.not_returned.order('checkouts.id DESC')
139
140
  response.should be_success
140
141
  end
141
142
 
142
143
  it "should get ics template" do
143
144
  token = "577830b08ecf9c4c4333d599a57a6f44a7fe76c0"
144
- user = Profile.where(:checkout_icalendar_token => token).first.user
145
- get :index, :icalendar_token => token, :format => :ics
145
+ user = Profile.where(checkout_icalendar_token: token).first.user
146
+ get :index, icalendar_token: token, format: :ics
146
147
  assigns(:checkouts).should eq user.checkouts.not_returned.order('checkouts.id DESC')
147
148
  response.should be_success
148
149
  end
@@ -154,7 +155,7 @@ describe CheckoutsController do
154
155
  login_fixture_admin
155
156
 
156
157
  it "should show other user's content" do
157
- get :show, :id => 3
158
+ get :show, id: 3
158
159
  response.should be_success
159
160
  end
160
161
  end
@@ -163,7 +164,7 @@ describe CheckoutsController do
163
164
  login_fixture_librarian
164
165
 
165
166
  it "should show other user's content" do
166
- get :show, :id => 3
167
+ get :show, id: 3
167
168
  response.should be_success
168
169
  end
169
170
  end
@@ -172,13 +173,13 @@ describe CheckoutsController do
172
173
  login_fixture_user
173
174
 
174
175
  it "should show my account" do
175
- get :show, :id => 3
176
+ get :show, id: 3
176
177
  response.should be_success
177
178
  assigns(:checkout).should eq checkouts(:checkout_00003)
178
179
  end
179
180
 
180
181
  it "should not show other user's checkout" do
181
- get :show, :id => 1
182
+ get :show, id: 1
182
183
  response.should be_forbidden
183
184
  assigns(:checkout).should eq checkouts(:checkout_00001)
184
185
  end
@@ -186,7 +187,7 @@ describe CheckoutsController do
186
187
 
187
188
  describe "When not logged in" do
188
189
  it "should not assign the requested checkout as @checkout" do
189
- get :show, :id => 1
190
+ get :show, id: 1
190
191
  response.should redirect_to new_user_session_url
191
192
  end
192
193
  end
@@ -197,7 +198,7 @@ describe CheckoutsController do
197
198
  login_fixture_admin
198
199
 
199
200
  it "should edit other user's checkout" do
200
- get :edit, :id => 3
201
+ get :edit, id: 3
201
202
  response.should be_success
202
203
  end
203
204
  end
@@ -206,7 +207,7 @@ describe CheckoutsController do
206
207
  login_fixture_librarian
207
208
 
208
209
  it "should edit other user's checkout" do
209
- get :edit, :id => 3
210
+ get :edit, id: 3
210
211
  response.should be_success
211
212
  end
212
213
  end
@@ -216,19 +217,19 @@ describe CheckoutsController do
216
217
 
217
218
  it "should edit my checkout" do
218
219
  sign_in users(:user1)
219
- get :edit, :id => 3
220
+ get :edit, id: 3
220
221
  response.should be_success
221
222
  end
222
223
 
223
224
  it "should not edit other user's checkout" do
224
- get :edit, :id => 1
225
+ get :edit, id: 1
225
226
  response.should be_forbidden
226
227
  end
227
228
  end
228
229
 
229
230
  describe "When not logged in" do
230
231
  it "should not edit checkout" do
231
- get :edit, :id => 1
232
+ get :edit, id: 1
232
233
  response.should redirect_to new_user_session_url
233
234
  end
234
235
  end
@@ -237,8 +238,8 @@ describe CheckoutsController do
237
238
  describe "PUT update" do
238
239
  before(:each) do
239
240
  @checkout = checkouts(:checkout_00003)
240
- @attrs = {:due_date => 1.day.from_now}
241
- @invalid_attrs = {:item_identifier => 'invalid'}
241
+ @attrs = {due_date: 1.day.from_now}
242
+ @invalid_attrs = {item_identifier: 'invalid'}
242
243
  end
243
244
 
244
245
  describe "When logged in as Administrator" do
@@ -246,12 +247,12 @@ describe CheckoutsController do
246
247
 
247
248
  describe "with valid params" do
248
249
  it "updates the requested checkout" do
249
- put :update, :id => @checkout.id, :checkout => @attrs
250
+ put :update, id: @checkout.id, checkout: @attrs
250
251
  end
251
252
 
252
253
  it "assigns the requested checkout as @checkout" do
253
254
  old_due_date = @checkout.due_date
254
- put :update, :id => @checkout.id, :checkout => @attrs
255
+ put :update, id: @checkout.id, checkout: @attrs
255
256
  assigns(:checkout).should eq(@checkout)
256
257
  response.should redirect_to(assigns(:checkout))
257
258
  assigns(:checkout).due_date.should eq 1.day.from_now.end_of_day
@@ -260,24 +261,24 @@ describe CheckoutsController do
260
261
 
261
262
  describe "with invalid params" do
262
263
  it "assigns the requested checkout as @checkout" do
263
- put :update, :id => @checkout.id, :checkout => @invalid_attrs
264
+ put :update, id: @checkout.id, checkout: @invalid_attrs
264
265
  end
265
266
 
266
267
  it "should ignore item_id" do
267
- put :update, :id => @checkout.id, :checkout => @invalid_attrs
268
+ put :update, id: @checkout.id, checkout: @invalid_attrs
268
269
  response.should redirect_to(assigns(:checkout))
269
270
  assigns(:checkout).changed?.should be_falsy
270
271
  end
271
272
  end
272
273
 
273
274
  it "should remove its own checkout history" do
274
- put :remove_all, :user_id => users(:user1).username
275
+ put :remove_all, user_id: users(:user1).username
275
276
  users(:user1).checkouts.returned.count.should eq 0
276
277
  response.should redirect_to checkouts_url
277
278
  end
278
279
 
279
280
  it "should not remove other checkout history" do
280
- put :remove_all, :user_id => users(:user2).username
281
+ put :remove_all, user_id: users(:user2).username
281
282
  users(:user1).checkouts.returned.count.should_not eq 0
282
283
  response.should redirect_to checkouts_url
283
284
  end
@@ -288,11 +289,11 @@ describe CheckoutsController do
288
289
 
289
290
  describe "with valid params" do
290
291
  it "updates the requested checkout" do
291
- put :update, :id => @checkout.id, :checkout => @attrs, :user_id => @checkout.user.username
292
+ put :update, id: @checkout.id, checkout: @attrs, user_id: @checkout.user.username
292
293
  end
293
294
 
294
295
  it "assigns the requested checkout as @checkout" do
295
- put :update, :id => @checkout.id, :checkout => @attrs, :user_id => @checkout.user.username
296
+ put :update, id: @checkout.id, checkout: @attrs, user_id: @checkout.user.username
296
297
  assigns(:checkout).should eq(@checkout)
297
298
  response.should redirect_to(assigns(:checkout))
298
299
  end
@@ -300,35 +301,35 @@ describe CheckoutsController do
300
301
 
301
302
  describe "with invalid params" do
302
303
  it "assigns the checkout as @checkout" do
303
- put :update, :id => @checkout.id, :checkout => @invalid_attrs, :user_id => @checkout.user.username
304
+ put :update, id: @checkout.id, checkout: @invalid_attrs, user_id: @checkout.user.username
304
305
  assigns(:checkout).should be_valid
305
306
  end
306
307
 
307
308
  it "should ignore item_id" do
308
- put :update, :id => @checkout.id, :checkout => @invalid_attrs, :user_id => @checkout.user.username
309
+ put :update, id: @checkout.id, checkout: @invalid_attrs, user_id: @checkout.user.username
309
310
  response.should redirect_to(assigns(:checkout))
310
311
  end
311
312
  end
312
313
 
313
314
  it "should update checkout item that is reserved" do
314
- put :update, :id => 8, :checkout => { }
315
+ put :update, id: 8, checkout: { }
315
316
  assigns(:checkout).errors[:base].include?(I18n.t('checkout.this_item_is_reserved')).should be_truthy
316
317
  response.should be_success
317
318
  end
318
319
 
319
320
  it "should update other user's checkout" do
320
- put :update, :id => 1, :checkout => { }
321
+ put :update, id: 1, checkout: { }
321
322
  response.should redirect_to checkout_url(assigns(:checkout))
322
323
  end
323
324
 
324
325
  it "should remove its own checkout history" do
325
- put :remove_all, :user_id => users(:user1).username
326
+ put :remove_all, user_id: users(:user1).username
326
327
  users(:user1).checkouts.returned.count.should eq 0
327
328
  response.should redirect_to checkouts_url
328
329
  end
329
330
 
330
331
  it "should not remove other checkout history" do
331
- put :remove_all, :user_id => users(:user2).username
332
+ put :remove_all, user_id: users(:user2).username
332
333
  users(:user1).checkouts.returned.count.should_not eq 0
333
334
  response.should redirect_to checkouts_url
334
335
  end
@@ -339,11 +340,11 @@ describe CheckoutsController do
339
340
 
340
341
  describe "with valid params" do
341
342
  it "updates the requested checkout" do
342
- put :update, :id => checkouts(:checkout_00001).id, :checkout => @attrs
343
+ put :update, id: checkouts(:checkout_00001).id, checkout: @attrs
343
344
  end
344
345
 
345
346
  it "assigns the requested checkout as @checkout" do
346
- put :update, :id => checkouts(:checkout_00001).id, :checkout => @attrs
347
+ put :update, id: checkouts(:checkout_00001).id, checkout: @attrs
347
348
  assigns(:checkout).should eq(checkouts(:checkout_00001))
348
349
  response.should be_forbidden
349
350
  end
@@ -351,43 +352,43 @@ describe CheckoutsController do
351
352
 
352
353
  describe "with invalid params" do
353
354
  it "assigns the requested checkout as @checkout" do
354
- put :update, :id => checkouts(:checkout_00001).id, :checkout => @attrs
355
+ put :update, id: checkouts(:checkout_00001).id, checkout: @attrs
355
356
  response.should be_forbidden
356
357
  end
357
358
  end
358
359
 
359
360
  it "should not update other user's checkout" do
360
- put :update, :id => 1, :checkout => { }
361
+ put :update, id: 1, checkout: { }
361
362
  response.should be_forbidden
362
363
  end
363
364
 
364
365
  it "should not update checkout already renewed" do
365
- put :update, :id => 9, :checkout => { }
366
+ put :update, id: 9, checkout: { }
366
367
  assigns(:checkout).errors[:base].include?(I18n.t('checkout.excessed_renewal_limit')).should be_truthy
367
368
  response.should be_success
368
369
  end
369
370
 
370
371
  it "should update my checkout" do
371
- put :update, :id => 3, :checkout => { }
372
+ put :update, id: 3, checkout: { }
372
373
  assigns(:checkout).should be_valid
373
374
  response.should redirect_to checkout_url(assigns(:checkout))
374
375
  end
375
376
 
376
377
  it "should not update checkout without item_id" do
377
- put :update, :id => 3, :checkout => {:item_id => nil}
378
+ put :update, id: 3, checkout: {item_id: nil}
378
379
  assigns(:checkout).should be_valid
379
380
  response.should redirect_to(assigns(:checkout))
380
381
  assigns(:checkout).changed?.should be_falsy
381
382
  end
382
383
 
383
384
  it "should remove its own checkout history" do
384
- put :remove_all, :user_id => users(:user1).username
385
+ put :remove_all, user_id: users(:user1).username
385
386
  assigns(:user).checkouts.returned.count.should eq 0
386
387
  response.should redirect_to checkouts_url
387
388
  end
388
389
 
389
390
  it "should not remove other checkout history" do
390
- put :remove_all, :user_id => users(:admin).username
391
+ put :remove_all, user_id: users(:admin).username
391
392
  assigns(:user).checkouts.returned.count.should eq 0
392
393
  response.should be_forbidden
393
394
  end
@@ -396,18 +397,18 @@ describe CheckoutsController do
396
397
  describe "When not logged in" do
397
398
  describe "with valid params" do
398
399
  it "updates the requested checkout" do
399
- put :update, :id => @checkout.id, :checkout => @attrs, :user_id => @checkout.user.username
400
+ put :update, id: @checkout.id, checkout: @attrs, user_id: @checkout.user.username
400
401
  end
401
402
 
402
403
  it "should be forbidden" do
403
- put :update, :id => @checkout.id, :checkout => @attrs, :user_id => @checkout.user.username
404
+ put :update, id: @checkout.id, checkout: @attrs, user_id: @checkout.user.username
404
405
  response.should redirect_to(new_user_session_url)
405
406
  end
406
407
  end
407
408
 
408
409
  describe "with invalid params" do
409
410
  it "assigns the requested checkout as @checkout" do
410
- put :update, :id => @checkout.id, :checkout => @invalid_attrs, :user_id => @checkout.user.username
411
+ put :update, id: @checkout.id, checkout: @invalid_attrs, user_id: @checkout.user.username
411
412
  response.should redirect_to(new_user_session_url)
412
413
  end
413
414
  end
@@ -424,16 +425,16 @@ describe CheckoutsController do
424
425
  login_fixture_admin
425
426
 
426
427
  it "destroys the requested checkout" do
427
- delete :destroy, :id => @checkout.id
428
+ delete :destroy, id: @checkout.id
428
429
  end
429
430
 
430
431
  it "should not destroy the checkout that is not checked in" do
431
- delete :destroy, :id => @checkout.id
432
+ delete :destroy, id: @checkout.id
432
433
  response.should be_forbidden
433
434
  end
434
435
 
435
436
  it "redirects to the checkouts list" do
436
- delete :destroy, :id => @returned_checkout.id
437
+ delete :destroy, id: @returned_checkout.id
437
438
  response.should redirect_to(checkouts_url(user_id: @returned_checkout.user.username))
438
439
  end
439
440
  end
@@ -442,16 +443,16 @@ describe CheckoutsController do
442
443
  login_fixture_librarian
443
444
 
444
445
  it "destroys the requested checkout" do
445
- delete :destroy, :id => @checkout.id
446
+ delete :destroy, id: @checkout.id
446
447
  end
447
448
 
448
449
  it "should not destroy the checkout that is not checked in" do
449
- delete :destroy, :id => @checkout.id
450
+ delete :destroy, id: @checkout.id
450
451
  response.should be_forbidden
451
452
  end
452
453
 
453
454
  it "redirects to the checkouts list" do
454
- delete :destroy, :id => @returned_checkout.id
455
+ delete :destroy, id: @returned_checkout.id
455
456
  response.should redirect_to(checkouts_url(user_id: @returned_checkout.user.username))
456
457
  end
457
458
  end
@@ -460,27 +461,27 @@ describe CheckoutsController do
460
461
  login_fixture_user
461
462
 
462
463
  it "destroys the requested checkout" do
463
- delete :destroy, :id => checkouts(:checkout_00001).id
464
+ delete :destroy, id: checkouts(:checkout_00001).id
464
465
  end
465
466
 
466
467
  it "should be forbidden" do
467
- delete :destroy, :id => checkouts(:checkout_00001).id
468
+ delete :destroy, id: checkouts(:checkout_00001).id
468
469
  response.should be_forbidden
469
470
  end
470
471
 
471
472
  it "should destroy my checkout" do
472
- delete :destroy, :id => 13
473
+ delete :destroy, id: 13
473
474
  response.should redirect_to checkouts_url(user_id: users(:user1).username)
474
475
  end
475
476
  end
476
477
 
477
478
  describe "When not logged in" do
478
479
  it "destroys the requested checkout" do
479
- delete :destroy, :id => @checkout.id, :user_id => @checkout.user.username
480
+ delete :destroy, id: @checkout.id, user_id: @checkout.user.username
480
481
  end
481
482
 
482
483
  it "should be forbidden" do
483
- delete :destroy, :id => @checkout.id, :user_id => @checkout.user.username
484
+ delete :destroy, id: @checkout.id, user_id: @checkout.user.username
484
485
  response.should redirect_to(new_user_session_url)
485
486
  end
486
487
  end
@@ -95,7 +95,7 @@ describe CirculationStatusesController do
95
95
 
96
96
  it "should be forbidden" do
97
97
  get :new
98
- assigns(:circulation_status).should_not be_valid
98
+ assigns(:circulation_status).should be_nil
99
99
  response.should be_forbidden
100
100
  end
101
101
  end
@@ -105,7 +105,7 @@ describe CirculationStatusesController do
105
105
 
106
106
  it "should be forbidden" do
107
107
  get :new
108
- assigns(:circulation_status).should_not be_valid
108
+ assigns(:circulation_status).should be_nil
109
109
  response.should be_forbidden
110
110
  end
111
111
  end
@@ -115,7 +115,7 @@ describe CirculationStatusesController do
115
115
 
116
116
  it "should be forbidden" do
117
117
  get :new
118
- assigns(:circulation_status).should_not be_valid
118
+ assigns(:circulation_status).should be_nil
119
119
  response.should be_forbidden
120
120
  end
121
121
  end
@@ -123,7 +123,7 @@ describe CirculationStatusesController do
123
123
  describe "When not logged in" do
124
124
  it "should be redirected" do
125
125
  get :new
126
- assigns(:circulation_status).should_not be_valid
126
+ assigns(:circulation_status).should be_nil
127
127
  response.should redirect_to(new_user_session_url)
128
128
  end
129
129
  end
@@ -181,7 +181,7 @@ describe CirculationStatusesController do
181
181
  describe "with valid params" do
182
182
  it "assigns a newly created circulation_status as @circulation_status" do
183
183
  post :create, :circulation_status => @attrs
184
- assigns(:circulation_status).should be_valid
184
+ assigns(:circulation_status).should be_nil
185
185
  end
186
186
 
187
187
  it "redirects to the created patron" do
@@ -193,7 +193,7 @@ describe CirculationStatusesController do
193
193
  describe "with invalid params" do
194
194
  it "assigns a newly created but unsaved circulation_status as @circulation_status" do
195
195
  post :create, :circulation_status => @invalid_attrs
196
- assigns(:circulation_status).should_not be_valid
196
+ assigns(:circulation_status).should be_nil
197
197
  end
198
198
 
199
199
  it "should be successful" do
@@ -209,7 +209,7 @@ describe CirculationStatusesController do
209
209
  describe "with valid params" do
210
210
  it "assigns a newly created circulation_status as @circulation_status" do
211
211
  post :create, :circulation_status => @attrs
212
- assigns(:circulation_status).should be_valid
212
+ assigns(:circulation_status).should be_nil
213
213
  end
214
214
 
215
215
  it "should be forbidden" do
@@ -221,7 +221,7 @@ describe CirculationStatusesController do
221
221
  describe "with invalid params" do
222
222
  it "assigns a newly created but unsaved circulation_status as @circulation_status" do
223
223
  post :create, :circulation_status => @invalid_attrs
224
- assigns(:circulation_status).should_not be_valid
224
+ assigns(:circulation_status).should be_nil
225
225
  end
226
226
 
227
227
  it "should be forbidden" do
@@ -237,7 +237,7 @@ describe CirculationStatusesController do
237
237
  describe "with valid params" do
238
238
  it "assigns a newly created circulation_status as @circulation_status" do
239
239
  post :create, :circulation_status => @attrs
240
- assigns(:circulation_status).should be_valid
240
+ assigns(:circulation_status).should be_nil
241
241
  end
242
242
 
243
243
  it "should be forbidden" do
@@ -249,7 +249,7 @@ describe CirculationStatusesController do
249
249
  describe "with invalid params" do
250
250
  it "assigns a newly created but unsaved circulation_status as @circulation_status" do
251
251
  post :create, :circulation_status => @invalid_attrs
252
- assigns(:circulation_status).should_not be_valid
252
+ assigns(:circulation_status).should be_nil
253
253
  end
254
254
 
255
255
  it "should be forbidden" do
@@ -263,7 +263,7 @@ describe CirculationStatusesController do
263
263
  describe "with valid params" do
264
264
  it "assigns a newly created circulation_status as @circulation_status" do
265
265
  post :create, :circulation_status => @attrs
266
- assigns(:circulation_status).should be_valid
266
+ assigns(:circulation_status).should be_nil
267
267
  end
268
268
 
269
269
  it "should be forbidden" do
@@ -275,7 +275,7 @@ describe CirculationStatusesController do
275
275
  describe "with invalid params" do
276
276
  it "assigns a newly created but unsaved circulation_status as @circulation_status" do
277
277
  post :create, :circulation_status => @invalid_attrs
278
- assigns(:circulation_status).should_not be_valid
278
+ assigns(:circulation_status).should be_nil
279
279
  end
280
280
 
281
281
  it "should be forbidden" do