enju_circulation 0.0.43 → 0.0.45

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/app/controllers/checked_items_controller.rb +2 -4
  2. data/app/controllers/checkout_stat_has_manifestations_controller.rb +6 -6
  3. data/app/controllers/checkout_stat_has_users_controller.rb +6 -6
  4. data/app/controllers/checkout_types_controller.rb +2 -4
  5. data/app/controllers/item_has_use_restrictions_controller.rb +5 -5
  6. data/app/controllers/manifestation_checkout_stats_controller.rb +2 -4
  7. data/app/controllers/manifestation_reserve_stats_controller.rb +2 -4
  8. data/app/controllers/reserve_stat_has_manifestations_controller.rb +4 -2
  9. data/app/controllers/reserve_stat_has_users_controller.rb +6 -6
  10. data/app/controllers/user_group_has_checkout_types_controller.rb +2 -4
  11. data/app/models/carrier_type_has_checkout_type.rb +1 -0
  12. data/app/models/checked_item.rb +1 -0
  13. data/app/models/checkin.rb +1 -1
  14. data/app/models/checkout.rb +2 -3
  15. data/app/models/checkout_stat_has_manifestation.rb +3 -0
  16. data/app/models/checkout_stat_has_user.rb +3 -0
  17. data/app/models/checkout_type.rb +1 -0
  18. data/app/models/circulation_status.rb +2 -2
  19. data/app/models/item_has_use_restriction.rb +2 -0
  20. data/app/models/lending_policy.rb +2 -0
  21. data/app/models/manifestation_checkout_stat.rb +2 -0
  22. data/app/models/manifestation_reserve_stat.rb +2 -0
  23. data/app/models/reserve.rb +35 -16
  24. data/app/models/reserve_stat_has_manifestation.rb +3 -0
  25. data/app/models/reserve_stat_has_user.rb +3 -0
  26. data/app/models/use_restriction.rb +1 -1
  27. data/app/models/user_checkout_stat.rb +2 -1
  28. data/app/models/user_group_has_checkout_type.rb +4 -0
  29. data/app/models/user_reserve_stat.rb +2 -1
  30. data/lib/enju_circulation/version.rb +1 -1
  31. data/spec/controllers/carrier_type_has_checkout_types_controller_spec.rb +7 -7
  32. data/spec/controllers/checkout_stat_has_manifestations_controller_spec.rb +10 -10
  33. data/spec/controllers/checkout_stat_has_users_controller_spec.rb +3 -3
  34. data/spec/controllers/checkouts_controller_spec.rb +9 -7
  35. data/spec/controllers/circulation_statuses_controller_spec.rb +445 -0
  36. data/spec/controllers/item_has_use_restrictions_controller_spec.rb +10 -10
  37. data/spec/controllers/reserve_stat_has_manifestations_controller_spec.rb +10 -10
  38. data/spec/controllers/reserve_stat_has_users_controller_spec.rb +3 -3
  39. data/spec/controllers/reserves_controller_spec.rb +1 -1
  40. data/spec/controllers/use_restrictions_controller_spec.rb +4 -4
  41. data/spec/dummy/app/models/basket.rb +5 -2
  42. data/spec/dummy/db/development.sqlite3 +0 -0
  43. data/spec/dummy/db/test.sqlite3 +0 -0
  44. data/spec/dummy/solr/conf/admin-extra.html +31 -0
  45. data/spec/dummy/solr/conf/elevate.xml +36 -0
  46. data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  47. data/spec/dummy/solr/conf/protwords.txt +21 -0
  48. data/spec/dummy/solr/conf/schema.xml +238 -0
  49. data/spec/dummy/solr/conf/scripts.conf +24 -0
  50. data/spec/dummy/solr/conf/solrconfig.xml +934 -0
  51. data/spec/dummy/solr/conf/spellings.txt +2 -0
  52. data/spec/dummy/solr/conf/stopwords.txt +58 -0
  53. data/spec/dummy/solr/conf/synonyms.txt +31 -0
  54. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  55. data/spec/dummy/solr/data/test/index/segments_1 +0 -0
  56. data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
  57. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  58. data/spec/factories/circulation_status.rb +5 -0
  59. data/spec/models/basket_spec.rb +43 -0
  60. data/spec/models/checkin_spec.rb +13 -4
  61. data/spec/models/circulation_status_spec.rb +21 -0
  62. data/spec/spec_helper.rb +13 -0
  63. metadata +56 -18
@@ -1,4 +1,7 @@
1
1
  class ReserveStatHasManifestation < ActiveRecord::Base
2
+ attr_accessible
3
+ attr_accessible :manifestation_reserve_stat_id, :manifestation_id,
4
+ :as => :admin
2
5
  belongs_to :manifestation_reserve_stat
3
6
  belongs_to :manifestation
4
7
 
@@ -1,4 +1,7 @@
1
1
  class ReserveStatHasUser < ActiveRecord::Base
2
+ attr_accessible
3
+ attr_accessible :user_reserve_stat_id, :user_id,
4
+ :as => :admin
2
5
  belongs_to :user_reserve_stat
3
6
  belongs_to :user
4
7
 
@@ -1,10 +1,10 @@
1
1
  class UseRestriction < ActiveRecord::Base
2
+ attr_accessible :name, :display_name, :note
2
3
  include MasterModel
3
4
  default_scope :order => 'use_restrictions.position'
4
5
  scope :available, where(:name => ['Not For Loan', 'Limited Circulation, Normal Loan Period'])
5
6
  has_many :item_has_use_restrictions
6
7
  has_many :items, :through => :item_has_use_restrictions
7
- attr_protected :name
8
8
  end
9
9
 
10
10
  # == Schema Information
@@ -1,6 +1,7 @@
1
1
  class UserCheckoutStat < ActiveRecord::Base
2
+ attr_accessible :start_date, :end_date, :note
2
3
  include CalculateStat
3
- default_scope :order => 'id DESC'
4
+ default_scope :order => 'user_checkout_stats.id DESC'
4
5
  scope :not_calculated, where(:state => 'pending')
5
6
  has_many :checkout_stat_has_users
6
7
  has_many :users, :through => :checkout_stat_has_users
@@ -1,4 +1,8 @@
1
1
  class UserGroupHasCheckoutType < ActiveRecord::Base
2
+ attr_accessible :user_group_id, :checkout_type_id,
3
+ :checkout_limit, :checkout_period, :checkout_renewal_limit,
4
+ :reservation_limit, :reservation_expired_period,
5
+ :set_due_date_before_closing_day, :fixed_due_date, :note
2
6
  scope :available_for_item, lambda{|item| where(:checkout_type_id => item.checkout_type.id)}
3
7
  scope :available_for_carrier_type, lambda{|carrier_type| {:include => {:checkout_type => :carrier_types}, :conditions => ['carrier_types.id = ?', carrier_type.id]}}
4
8
 
@@ -1,6 +1,7 @@
1
1
  class UserReserveStat < ActiveRecord::Base
2
+ attr_accessible :start_date, :end_date, :note
2
3
  include CalculateStat
3
- default_scope :order => 'id DESC'
4
+ default_scope :order => 'user_reserve_stats.id DESC'
4
5
  scope :not_calculated, where(:state => 'pending')
5
6
  has_many :reserve_stat_has_users
6
7
  has_many :users, :through => :reserve_stat_has_users
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.0.43"
2
+ VERSION = "0.0.45"
3
3
  end
@@ -26,7 +26,7 @@ describe CarrierTypeHasCheckoutTypesController do
26
26
  end
27
27
  end
28
28
 
29
- describe "When logged in as Subject" do
29
+ describe "When logged in as User" do
30
30
  login_user
31
31
 
32
32
  it "assigns all carrier_type_has_checkout_types as @carrier_type_has_checkout_types" do
@@ -66,7 +66,7 @@ describe CarrierTypeHasCheckoutTypesController do
66
66
  end
67
67
  end
68
68
 
69
- describe "When logged in as Subject" do
69
+ describe "When logged in as User" do
70
70
  login_user
71
71
 
72
72
  it "assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type" do
@@ -106,7 +106,7 @@ describe CarrierTypeHasCheckoutTypesController do
106
106
  end
107
107
  end
108
108
 
109
- describe "When logged in as Subject" do
109
+ describe "When logged in as User" do
110
110
  login_user
111
111
 
112
112
  it "should not assign the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type" do
@@ -146,7 +146,7 @@ describe CarrierTypeHasCheckoutTypesController do
146
146
  end
147
147
  end
148
148
 
149
- describe "When logged in as Subject" do
149
+ describe "When logged in as User" do
150
150
  login_user
151
151
 
152
152
  it "assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type" do
@@ -227,7 +227,7 @@ describe CarrierTypeHasCheckoutTypesController do
227
227
  end
228
228
  end
229
229
 
230
- describe "When logged in as Subject" do
230
+ describe "When logged in as User" do
231
231
  login_user
232
232
 
233
233
  describe "with valid params" do
@@ -339,7 +339,7 @@ describe CarrierTypeHasCheckoutTypesController do
339
339
  end
340
340
  end
341
341
 
342
- describe "When logged in as Subject" do
342
+ describe "When logged in as User" do
343
343
  login_user
344
344
 
345
345
  describe "with valid params" do
@@ -414,7 +414,7 @@ describe CarrierTypeHasCheckoutTypesController do
414
414
  end
415
415
  end
416
416
 
417
- describe "When logged in as Subject" do
417
+ describe "When logged in as User" do
418
418
  login_user
419
419
 
420
420
  it "destroys the requested carrier_type_has_checkout_type" do
@@ -26,7 +26,7 @@ describe CheckoutStatHasManifestationsController do
26
26
  end
27
27
  end
28
28
 
29
- describe "When logged in as Manifestation" do
29
+ describe "When logged in as User" do
30
30
  login_user
31
31
 
32
32
  it "assigns all checkout_stat_has_manifestations as @checkout_stat_has_manifestations" do
@@ -66,7 +66,7 @@ describe CheckoutStatHasManifestationsController do
66
66
  end
67
67
  end
68
68
 
69
- describe "When logged in as Manifestation" do
69
+ describe "When logged in as User" do
70
70
  login_user
71
71
 
72
72
  it "assigns the requested checkout_stat_has_manifestation as @checkout_stat_has_manifestation" do
@@ -106,7 +106,7 @@ describe CheckoutStatHasManifestationsController do
106
106
  end
107
107
  end
108
108
 
109
- describe "When logged in as Manifestation" do
109
+ describe "When logged in as User" do
110
110
  login_user
111
111
 
112
112
  it "should not assign the requested checkout_stat_has_manifestation as @checkout_stat_has_manifestation" do
@@ -146,7 +146,7 @@ describe CheckoutStatHasManifestationsController do
146
146
  end
147
147
  end
148
148
 
149
- describe "When logged in as Manifestation" do
149
+ describe "When logged in as User" do
150
150
  login_user
151
151
 
152
152
  it "assigns the requested checkout_stat_has_manifestation as @checkout_stat_has_manifestation" do
@@ -205,7 +205,7 @@ describe CheckoutStatHasManifestationsController do
205
205
  describe "with valid params" do
206
206
  it "assigns a newly created checkout_stat_has_manifestation as @checkout_stat_has_manifestation" do
207
207
  post :create, :checkout_stat_has_manifestation => @attrs
208
- assigns(:checkout_stat_has_manifestation).should be_valid
208
+ assigns(:checkout_stat_has_manifestation).should_not be_valid
209
209
  end
210
210
 
211
211
  it "should be forbidden" do
@@ -227,13 +227,13 @@ describe CheckoutStatHasManifestationsController do
227
227
  end
228
228
  end
229
229
 
230
- describe "When logged in as Manifestation" do
230
+ describe "When logged in as User" do
231
231
  login_user
232
232
 
233
233
  describe "with valid params" do
234
234
  it "assigns a newly created checkout_stat_has_manifestation as @checkout_stat_has_manifestation" do
235
235
  post :create, :checkout_stat_has_manifestation => @attrs
236
- assigns(:checkout_stat_has_manifestation).should be_valid
236
+ assigns(:checkout_stat_has_manifestation).should_not be_valid
237
237
  end
238
238
 
239
239
  it "should be forbidden" do
@@ -259,7 +259,7 @@ describe CheckoutStatHasManifestationsController do
259
259
  describe "with valid params" do
260
260
  it "assigns a newly created checkout_stat_has_manifestation as @checkout_stat_has_manifestation" do
261
261
  post :create, :checkout_stat_has_manifestation => @attrs
262
- assigns(:checkout_stat_has_manifestation).should be_valid
262
+ assigns(:checkout_stat_has_manifestation).should_not be_valid
263
263
  end
264
264
 
265
265
  it "should be forbidden" do
@@ -339,7 +339,7 @@ describe CheckoutStatHasManifestationsController do
339
339
  end
340
340
  end
341
341
 
342
- describe "When logged in as Manifestation" do
342
+ describe "When logged in as User" do
343
343
  login_user
344
344
 
345
345
  describe "with valid params" do
@@ -414,7 +414,7 @@ describe CheckoutStatHasManifestationsController do
414
414
  end
415
415
  end
416
416
 
417
- describe "When logged in as Manifestation" do
417
+ describe "When logged in as User" do
418
418
  login_user
419
419
 
420
420
  it "destroys the requested checkout_stat_has_manifestation" do
@@ -205,7 +205,7 @@ describe CheckoutStatHasUsersController do
205
205
  describe "with valid params" do
206
206
  it "assigns a newly created checkout_stat_has_user as @checkout_stat_has_user" do
207
207
  post :create, :checkout_stat_has_user => @attrs
208
- assigns(:checkout_stat_has_user).should be_valid
208
+ assigns(:checkout_stat_has_user).should_not be_valid
209
209
  end
210
210
 
211
211
  it "should be forbidden" do
@@ -233,7 +233,7 @@ describe CheckoutStatHasUsersController do
233
233
  describe "with valid params" do
234
234
  it "assigns a newly created checkout_stat_has_user as @checkout_stat_has_user" do
235
235
  post :create, :checkout_stat_has_user => @attrs
236
- assigns(:checkout_stat_has_user).should be_valid
236
+ assigns(:checkout_stat_has_user).should_not be_valid
237
237
  end
238
238
 
239
239
  it "should be forbidden" do
@@ -259,7 +259,7 @@ describe CheckoutStatHasUsersController do
259
259
  describe "with valid params" do
260
260
  it "assigns a newly created checkout_stat_has_user as @checkout_stat_has_user" do
261
261
  post :create, :checkout_stat_has_user => @attrs
262
- assigns(:checkout_stat_has_user).should be_valid
262
+ assigns(:checkout_stat_has_user).should_not be_valid
263
263
  end
264
264
 
265
265
  it "should be forbidden" do
@@ -254,9 +254,10 @@ describe CheckoutsController do
254
254
  put :update, :id => @checkout.id, :checkout => @invalid_attrs
255
255
  end
256
256
 
257
- it "re-renders the 'edit' template" do
257
+ it "should ignore item_id" do
258
258
  put :update, :id => @checkout.id, :checkout => @invalid_attrs
259
- response.should render_template("edit")
259
+ response.should redirect_to(assigns(:checkout))
260
+ assigns(:checkout).changed?.should be_false
260
261
  end
261
262
  end
262
263
 
@@ -296,12 +297,12 @@ describe CheckoutsController do
296
297
  describe "with invalid params" do
297
298
  it "assigns the checkout as @checkout" do
298
299
  put :update, :id => @checkout.id, :checkout => @invalid_attrs, :user_id => @checkout.user.username
299
- assigns(:checkout).should_not be_valid
300
+ assigns(:checkout).should be_valid
300
301
  end
301
302
 
302
- it "re-renders the 'edit' template" do
303
+ it "should ignore item_id" do
303
304
  put :update, :id => @checkout.id, :checkout => @invalid_attrs, :user_id => @checkout.user.username
304
- response.should render_template("edit")
305
+ response.should redirect_to(assigns(:checkout))
305
306
  end
306
307
  end
307
308
 
@@ -370,8 +371,9 @@ describe CheckoutsController do
370
371
 
371
372
  it "should not update checkout without item_id" do
372
373
  put :update, :id => 3, :checkout => {:item_id => nil}
373
- assigns(:checkout).should_not be_valid
374
- response.should be_success
374
+ assigns(:checkout).should be_valid
375
+ response.should redirect_to(assigns(:checkout))
376
+ assigns(:checkout).changed?.should be_false
375
377
  end
376
378
 
377
379
  it "should remove its own checkout history" do
@@ -0,0 +1,445 @@
1
+ require 'spec_helper'
2
+ require 'sunspot/rails/spec_helper'
3
+
4
+ describe CirculationStatusesController do
5
+ fixtures :all
6
+ disconnect_sunspot
7
+
8
+ def valid_attributes
9
+ FactoryGirl.attributes_for(:circulation_status)
10
+ end
11
+
12
+ describe "GET index" do
13
+ before(:each) do
14
+ FactoryGirl.create(:circulation_status)
15
+ end
16
+
17
+ describe "When logged in as Administrator" do
18
+ login_admin
19
+
20
+ it "assigns all circulation_statuses as @circulation_statuses" do
21
+ get :index
22
+ assigns(:circulation_statuses).should eq(CirculationStatus.all)
23
+ end
24
+ end
25
+
26
+ describe "When logged in as Librarian" do
27
+ login_librarian
28
+
29
+ it "assigns all circulation_statuses as @circulation_statuses" do
30
+ get :index
31
+ assigns(:circulation_statuses).should eq(CirculationStatus.all)
32
+ end
33
+ end
34
+
35
+ describe "When logged in as User" do
36
+ login_user
37
+
38
+ it "assigns all circulation_statuses as @circulation_statuses" do
39
+ get :index
40
+ assigns(:circulation_statuses).should eq(CirculationStatus.all)
41
+ end
42
+ end
43
+
44
+ describe "When not logged in" do
45
+ it "assigns all circulation_statuses as @circulation_statuses" do
46
+ get :index
47
+ assigns(:circulation_statuses).should eq(CirculationStatus.all)
48
+ end
49
+ end
50
+ end
51
+
52
+ describe "GET show" do
53
+ describe "When logged in as Administrator" do
54
+ login_admin
55
+
56
+ it "assigns the requested circulation_status as @circulation_status" do
57
+ circulation_status = FactoryGirl.create(:circulation_status)
58
+ get :show, :id => circulation_status.id
59
+ assigns(:circulation_status).should eq(circulation_status)
60
+ end
61
+ end
62
+
63
+ describe "When logged in as Librarian" do
64
+ login_librarian
65
+
66
+ it "assigns the requested circulation_status as @circulation_status" do
67
+ circulation_status = FactoryGirl.create(:circulation_status)
68
+ get :show, :id => circulation_status.id
69
+ assigns(:circulation_status).should eq(circulation_status)
70
+ end
71
+ end
72
+
73
+ describe "When logged in as User" do
74
+ login_user
75
+
76
+ it "assigns the requested circulation_status as @circulation_status" do
77
+ circulation_status = FactoryGirl.create(:circulation_status)
78
+ get :show, :id => circulation_status.id
79
+ assigns(:circulation_status).should eq(circulation_status)
80
+ end
81
+ end
82
+
83
+ describe "When not logged in" do
84
+ it "assigns the requested circulation_status as @circulation_status" do
85
+ circulation_status = FactoryGirl.create(:circulation_status)
86
+ get :show, :id => circulation_status.id
87
+ assigns(:circulation_status).should eq(circulation_status)
88
+ end
89
+ end
90
+ end
91
+
92
+ describe "GET new" do
93
+ describe "When logged in as Administrator" do
94
+ login_admin
95
+
96
+ it "should be forbidden" do
97
+ get :new
98
+ assigns(:circulation_status).should_not be_valid
99
+ response.should be_forbidden
100
+ end
101
+ end
102
+
103
+ describe "When logged in as Librarian" do
104
+ login_librarian
105
+
106
+ it "should be forbidden" do
107
+ get :new
108
+ assigns(:circulation_status).should_not be_valid
109
+ response.should be_forbidden
110
+ end
111
+ end
112
+
113
+ describe "When logged in as User" do
114
+ login_user
115
+
116
+ it "should be forbidden" do
117
+ get :new
118
+ assigns(:circulation_status).should_not be_valid
119
+ response.should be_forbidden
120
+ end
121
+ end
122
+
123
+ describe "When not logged in" do
124
+ it "should be redirected" do
125
+ get :new
126
+ assigns(:circulation_status).should_not be_valid
127
+ response.should redirect_to(new_user_session_url)
128
+ end
129
+ end
130
+ end
131
+
132
+ describe "GET edit" do
133
+ describe "When logged in as Administrator" do
134
+ login_admin
135
+
136
+ it "assigns the requested circulation_status as @circulation_status" do
137
+ circulation_status = FactoryGirl.create(:circulation_status)
138
+ get :edit, :id => circulation_status.id
139
+ assigns(:circulation_status).should eq(circulation_status)
140
+ end
141
+ end
142
+
143
+ describe "When logged in as Librarian" do
144
+ login_librarian
145
+
146
+ it "assigns the requested circulation_status as @circulation_status" do
147
+ circulation_status = FactoryGirl.create(:circulation_status)
148
+ get :edit, :id => circulation_status.id
149
+ response.should be_forbidden
150
+ end
151
+ end
152
+
153
+ describe "When logged in as User" do
154
+ login_user
155
+
156
+ it "assigns the requested circulation_status as @circulation_status" do
157
+ circulation_status = FactoryGirl.create(:circulation_status)
158
+ get :edit, :id => circulation_status.id
159
+ response.should be_forbidden
160
+ end
161
+ end
162
+
163
+ describe "When not logged in" do
164
+ it "should not assign the requested circulation_status as @circulation_status" do
165
+ circulation_status = FactoryGirl.create(:circulation_status)
166
+ get :edit, :id => circulation_status.id
167
+ response.should redirect_to(new_user_session_url)
168
+ end
169
+ end
170
+ end
171
+
172
+ describe "POST create" do
173
+ before(:each) do
174
+ @attrs = valid_attributes
175
+ @invalid_attrs = {:name => ''}
176
+ end
177
+
178
+ describe "When logged in as Administrator" do
179
+ login_admin
180
+
181
+ describe "with valid params" do
182
+ it "assigns a newly created circulation_status as @circulation_status" do
183
+ post :create, :circulation_status => @attrs
184
+ assigns(:circulation_status).should be_valid
185
+ end
186
+
187
+ it "redirects to the created patron" do
188
+ post :create, :circulation_status => @attrs
189
+ response.should be_forbidden
190
+ end
191
+ end
192
+
193
+ describe "with invalid params" do
194
+ it "assigns a newly created but unsaved circulation_status as @circulation_status" do
195
+ post :create, :circulation_status => @invalid_attrs
196
+ assigns(:circulation_status).should_not be_valid
197
+ end
198
+
199
+ it "should be successful" do
200
+ post :create, :circulation_status => @invalid_attrs
201
+ response.should be_forbidden
202
+ end
203
+ end
204
+ end
205
+
206
+ describe "When logged in as Librarian" do
207
+ login_librarian
208
+
209
+ describe "with valid params" do
210
+ it "assigns a newly created circulation_status as @circulation_status" do
211
+ post :create, :circulation_status => @attrs
212
+ assigns(:circulation_status).should be_valid
213
+ end
214
+
215
+ it "should be forbidden" do
216
+ post :create, :circulation_status => @attrs
217
+ response.should be_forbidden
218
+ end
219
+ end
220
+
221
+ describe "with invalid params" do
222
+ it "assigns a newly created but unsaved circulation_status as @circulation_status" do
223
+ post :create, :circulation_status => @invalid_attrs
224
+ assigns(:circulation_status).should_not be_valid
225
+ end
226
+
227
+ it "should be forbidden" do
228
+ post :create, :circulation_status => @invalid_attrs
229
+ response.should be_forbidden
230
+ end
231
+ end
232
+ end
233
+
234
+ describe "When logged in as User" do
235
+ login_user
236
+
237
+ describe "with valid params" do
238
+ it "assigns a newly created circulation_status as @circulation_status" do
239
+ post :create, :circulation_status => @attrs
240
+ assigns(:circulation_status).should be_valid
241
+ end
242
+
243
+ it "should be forbidden" do
244
+ post :create, :circulation_status => @attrs
245
+ response.should be_forbidden
246
+ end
247
+ end
248
+
249
+ describe "with invalid params" do
250
+ it "assigns a newly created but unsaved circulation_status as @circulation_status" do
251
+ post :create, :circulation_status => @invalid_attrs
252
+ assigns(:circulation_status).should_not be_valid
253
+ end
254
+
255
+ it "should be forbidden" do
256
+ post :create, :circulation_status => @invalid_attrs
257
+ response.should be_forbidden
258
+ end
259
+ end
260
+ end
261
+
262
+ describe "When not logged in" do
263
+ describe "with valid params" do
264
+ it "assigns a newly created circulation_status as @circulation_status" do
265
+ post :create, :circulation_status => @attrs
266
+ assigns(:circulation_status).should be_valid
267
+ end
268
+
269
+ it "should be forbidden" do
270
+ post :create, :circulation_status => @attrs
271
+ response.should redirect_to(new_user_session_url)
272
+ end
273
+ end
274
+
275
+ describe "with invalid params" do
276
+ it "assigns a newly created but unsaved circulation_status as @circulation_status" do
277
+ post :create, :circulation_status => @invalid_attrs
278
+ assigns(:circulation_status).should_not be_valid
279
+ end
280
+
281
+ it "should be forbidden" do
282
+ post :create, :circulation_status => @invalid_attrs
283
+ response.should redirect_to(new_user_session_url)
284
+ end
285
+ end
286
+ end
287
+ end
288
+
289
+ describe "PUT update" do
290
+ before(:each) do
291
+ @circulation_status = FactoryGirl.create(:circulation_status)
292
+ @attrs = valid_attributes
293
+ @invalid_attrs = {:display_name => ''}
294
+ end
295
+
296
+ describe "When logged in as Administrator" do
297
+ login_admin
298
+
299
+ describe "with valid params" do
300
+ it "updates the requested circulation_status" do
301
+ put :update, :id => @circulation_status.id, :circulation_status => @attrs
302
+ end
303
+
304
+ it "assigns the requested circulation_status as @circulation_status" do
305
+ put :update, :id => @circulation_status.id, :circulation_status => @attrs
306
+ assigns(:circulation_status).should eq(@circulation_status)
307
+ end
308
+
309
+ it "moves its position when specified" do
310
+ put :update, :id => @circulation_status.id, :circulation_status => @attrs, :move => 'lower'
311
+ response.should redirect_to(circulation_statuses_url)
312
+ end
313
+ end
314
+
315
+ describe "with invalid params" do
316
+ it "assigns the requested circulation_status as @circulation_status" do
317
+ put :update, :id => @circulation_status.id, :circulation_status => @invalid_attrs
318
+ response.should render_template("edit")
319
+ end
320
+ end
321
+ end
322
+
323
+ describe "When logged in as Librarian" do
324
+ login_librarian
325
+
326
+ describe "with valid params" do
327
+ it "updates the requested circulation_status" do
328
+ put :update, :id => @circulation_status.id, :circulation_status => @attrs
329
+ end
330
+
331
+ it "assigns the requested circulation_status as @circulation_status" do
332
+ put :update, :id => @circulation_status.id, :circulation_status => @attrs
333
+ assigns(:circulation_status).should eq(@circulation_status)
334
+ response.should be_forbidden
335
+ end
336
+ end
337
+
338
+ describe "with invalid params" do
339
+ it "assigns the requested circulation_status as @circulation_status" do
340
+ put :update, :id => @circulation_status.id, :circulation_status => @invalid_attrs
341
+ response.should be_forbidden
342
+ end
343
+ end
344
+ end
345
+
346
+ describe "When logged in as User" do
347
+ login_user
348
+
349
+ describe "with valid params" do
350
+ it "updates the requested circulation_status" do
351
+ put :update, :id => @circulation_status.id, :circulation_status => @attrs
352
+ end
353
+
354
+ it "assigns the requested circulation_status as @circulation_status" do
355
+ put :update, :id => @circulation_status.id, :circulation_status => @attrs
356
+ assigns(:circulation_status).should eq(@circulation_status)
357
+ response.should be_forbidden
358
+ end
359
+ end
360
+
361
+ describe "with invalid params" do
362
+ it "assigns the requested circulation_status as @circulation_status" do
363
+ put :update, :id => @circulation_status.id, :circulation_status => @invalid_attrs
364
+ response.should be_forbidden
365
+ end
366
+ end
367
+ end
368
+
369
+ describe "When not logged in" do
370
+ describe "with valid params" do
371
+ it "updates the requested circulation_status" do
372
+ put :update, :id => @circulation_status.id, :circulation_status => @attrs
373
+ end
374
+
375
+ it "should be forbidden" do
376
+ put :update, :id => @circulation_status.id, :circulation_status => @attrs
377
+ response.should redirect_to(new_user_session_url)
378
+ end
379
+ end
380
+
381
+ describe "with invalid params" do
382
+ it "assigns the requested circulation_status as @circulation_status" do
383
+ put :update, :id => @circulation_status.id, :circulation_status => @invalid_attrs
384
+ response.should redirect_to(new_user_session_url)
385
+ end
386
+ end
387
+ end
388
+ end
389
+
390
+ describe "DELETE destroy" do
391
+ before(:each) do
392
+ @circulation_status = FactoryGirl.create(:circulation_status)
393
+ end
394
+
395
+ describe "When logged in as Administrator" do
396
+ login_admin
397
+
398
+ it "destroys the requested circulation_status" do
399
+ delete :destroy, :id => @circulation_status.id
400
+ end
401
+
402
+ it "should be forbidden" do
403
+ delete :destroy, :id => @circulation_status.id
404
+ response.should be_forbidden
405
+ end
406
+ end
407
+
408
+ describe "When logged in as Librarian" do
409
+ login_librarian
410
+
411
+ it "destroys the requested circulation_status" do
412
+ delete :destroy, :id => @circulation_status.id
413
+ end
414
+
415
+ it "should be forbidden" do
416
+ delete :destroy, :id => @circulation_status.id
417
+ response.should be_forbidden
418
+ end
419
+ end
420
+
421
+ describe "When logged in as User" do
422
+ login_user
423
+
424
+ it "destroys the requested circulation_status" do
425
+ delete :destroy, :id => @circulation_status.id
426
+ end
427
+
428
+ it "should be forbidden" do
429
+ delete :destroy, :id => @circulation_status.id
430
+ response.should be_forbidden
431
+ end
432
+ end
433
+
434
+ describe "When not logged in" do
435
+ it "destroys the requested circulation_status" do
436
+ delete :destroy, :id => @circulation_status.id
437
+ end
438
+
439
+ it "should be forbidden" do
440
+ delete :destroy, :id => @circulation_status.id
441
+ response.should redirect_to(new_user_session_url)
442
+ end
443
+ end
444
+ end
445
+ end