enju_purchase_request 0.0.3
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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +45 -0
- data/app/controllers/order_lists_controller.rb +94 -0
- data/app/controllers/orders_controller.rb +129 -0
- data/app/controllers/purchase_requests_controller.rb +139 -0
- data/app/models/order.rb +35 -0
- data/app/models/order_list.rb +53 -0
- data/app/models/purchase_request.rb +89 -0
- data/app/views/order_lists/edit.html.erb +37 -0
- data/app/views/order_lists/index.atom.builder +11 -0
- data/app/views/order_lists/index.html.erb +34 -0
- data/app/views/order_lists/index.rss.builder +31 -0
- data/app/views/order_lists/new.html.erb +32 -0
- data/app/views/order_lists/show.html.erb +40 -0
- data/app/views/orders/edit.html.erb +30 -0
- data/app/views/orders/index.atom.builder +11 -0
- data/app/views/orders/index.html.erb +40 -0
- data/app/views/orders/index.rss.builder +38 -0
- data/app/views/orders/new.html.erb +34 -0
- data/app/views/orders/show.html.erb +23 -0
- data/app/views/purchase_requests/_index.html.erb +85 -0
- data/app/views/purchase_requests/_index_order_list.html.erb +76 -0
- data/app/views/purchase_requests/_new.html.erb +76 -0
- data/app/views/purchase_requests/_new_order_list.html.erb +74 -0
- data/app/views/purchase_requests/edit.html.erb +66 -0
- data/app/views/purchase_requests/index.atom.builder +15 -0
- data/app/views/purchase_requests/index.csv.erb +4 -0
- data/app/views/purchase_requests/index.html.erb +5 -0
- data/app/views/purchase_requests/index.rss.builder +38 -0
- data/app/views/purchase_requests/new.html.erb +5 -0
- data/app/views/purchase_requests/show.html.erb +94 -0
- data/config/routes.rb +18 -0
- data/db/migrate/123_create_purchase_requests.rb +30 -0
- data/db/migrate/126_create_orders.rb +18 -0
- data/db/migrate/20081009062129_create_order_lists.rb +21 -0
- data/lib/enju_purchase_request/bookmark_url.rb +45 -0
- data/lib/enju_purchase_request/bookstore.rb +3 -0
- data/lib/enju_purchase_request/engine.rb +14 -0
- data/lib/enju_purchase_request/url_validator.rb +10 -0
- data/lib/enju_purchase_request/version.rb +3 -0
- data/lib/enju_purchase_request.rb +7 -0
- data/lib/tasks/enju_purchase_request_tasks.rake +4 -0
- data/spec/controllers/order_lists_controller_spec.rb +476 -0
- data/spec/controllers/orders_controller_spec.rb +481 -0
- data/spec/controllers/purchase_requests_controller_spec.rb +537 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +104 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/ability.rb +25 -0
- data/spec/dummy/app/models/bookmark.rb +29 -0
- data/spec/dummy/app/models/bookstore.rb +31 -0
- data/spec/dummy/app/models/role.rb +5 -0
- data/spec/dummy/app/models/user.rb +29 -0
- data/spec/dummy/app/models/user_group.rb +2 -0
- data/spec/dummy/app/models/user_has_role.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/page/403.html.erb +9 -0
- data/spec/dummy/app/views/page/403.mobile.erb +5 -0
- data/spec/dummy/app/views/page/403.xml.erb +4 -0
- data/spec/dummy/app/views/page/404.html.erb +9 -0
- data/spec/dummy/app/views/page/404.mobile.erb +5 -0
- data/spec/dummy/app/views/page/404.xml.erb +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +209 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +6 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/006_create_items.rb +36 -0
- data/spec/dummy/db/migrate/124_create_bookstores.rb +21 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +13 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
- data/spec/dummy/db/migrate/20111201163342_create_user_groups.rb +12 -0
- data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
- data/spec/dummy/db/schema.rb +156 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/sunspot-solr-test.log +222 -0
- data/spec/dummy/log/test.log +137771 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/solr/conf/admin-extra.html +31 -0
- data/spec/dummy/solr/conf/elevate.xml +36 -0
- data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/spec/dummy/solr/conf/protwords.txt +21 -0
- data/spec/dummy/solr/conf/schema.xml +238 -0
- data/spec/dummy/solr/conf/scripts.conf +24 -0
- data/spec/dummy/solr/conf/solrconfig.xml +934 -0
- data/spec/dummy/solr/conf/spellings.txt +2 -0
- data/spec/dummy/solr/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/conf/synonyms.txt +31 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_1 +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
- data/spec/factories/bookstore.rb +5 -0
- data/spec/factories/order.rb +6 -0
- data/spec/factories/order_list.rb +7 -0
- data/spec/factories/purchase_request.rb +6 -0
- data/spec/factories/user.rb +34 -0
- data/spec/fixtures/order_lists.yml +40 -0
- data/spec/fixtures/orders.yml +50 -0
- data/spec/fixtures/purchase_requests.yml +129 -0
- data/spec/fixtures/roles.yml +21 -0
- data/spec/fixtures/user_has_roles.yml +41 -0
- data/spec/fixtures/users.yml +69 -0
- data/spec/models/order_list_spec.rb +24 -0
- data/spec/models/order_spec.rb +21 -0
- data/spec/models/purchase_request_spec.rb +31 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/support/controller_macros.rb +48 -0
- data/spec/support/devise.rb +4 -0
- metadata +394 -0
@@ -0,0 +1,476 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sunspot/rails/spec_helper'
|
3
|
+
|
4
|
+
describe OrderListsController do
|
5
|
+
disconnect_sunspot
|
6
|
+
|
7
|
+
describe "GET index" do
|
8
|
+
describe "When logged in as Administrator" do
|
9
|
+
before(:each) do
|
10
|
+
sign_in FactoryGirl.create(:admin)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "assigns all order_lists as @order_lists" do
|
14
|
+
get :index
|
15
|
+
assigns(:order_lists).should eq(OrderList.all)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "When logged in as Librarian" do
|
20
|
+
before(:each) do
|
21
|
+
sign_in FactoryGirl.create(:librarian)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "assigns all order_lists as @order_lists" do
|
25
|
+
get :index
|
26
|
+
assigns(:order_lists).should eq(OrderList.all)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "When logged in as User" do
|
31
|
+
before(:each) do
|
32
|
+
sign_in FactoryGirl.create(:user)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "assigns empty as @order_lists" do
|
36
|
+
get :index
|
37
|
+
assigns(:order_lists).should be_empty
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "When not logged in" do
|
42
|
+
it "assigns empty as @order_lists" do
|
43
|
+
get :index
|
44
|
+
assigns(:order_lists).should be_empty
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "GET show" do
|
50
|
+
describe "When logged in as Administrator" do
|
51
|
+
before(:each) do
|
52
|
+
sign_in FactoryGirl.create(:admin)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "assigns the requested order_list as @order_list" do
|
56
|
+
order_list = FactoryGirl.create(:order_list)
|
57
|
+
get :show, :id => order_list.id
|
58
|
+
assigns(:order_list).should eq(order_list)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "When logged in as Librarian" do
|
63
|
+
before(:each) do
|
64
|
+
sign_in FactoryGirl.create(:librarian)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "assigns the requested order_list as @order_list" do
|
68
|
+
order_list = FactoryGirl.create(:order_list)
|
69
|
+
get :show, :id => order_list.id
|
70
|
+
assigns(:order_list).should eq(order_list)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "When logged in as User" do
|
75
|
+
before(:each) do
|
76
|
+
sign_in FactoryGirl.create(:user)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "assigns the requested order_list as @order_list" do
|
80
|
+
order_list = FactoryGirl.create(:order_list)
|
81
|
+
get :show, :id => order_list.id
|
82
|
+
assigns(:order_list).should eq(order_list)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "When not logged in" do
|
87
|
+
it "assigns the requested order_list as @order_list" do
|
88
|
+
order_list = FactoryGirl.create(:order_list)
|
89
|
+
get :show, :id => order_list.id
|
90
|
+
assigns(:order_list).should eq(order_list)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "GET new" do
|
96
|
+
describe "When logged in as Administrator" do
|
97
|
+
before(:each) do
|
98
|
+
sign_in FactoryGirl.create(:admin)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "assigns the requested order_list as @order_list" do
|
102
|
+
get :new
|
103
|
+
assigns(:order_list).should_not be_valid
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "When logged in as Librarian" do
|
108
|
+
before(:each) do
|
109
|
+
sign_in FactoryGirl.create(:librarian)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "assigns the requested order_list as @order_list" do
|
113
|
+
get :new
|
114
|
+
assigns(:order_list).should_not be_valid
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "When logged in as User" do
|
119
|
+
before(:each) do
|
120
|
+
sign_in FactoryGirl.create(:user)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should not assign the requested order_list as @order_list" do
|
124
|
+
get :new
|
125
|
+
assigns(:order_list).should_not be_valid
|
126
|
+
response.should be_forbidden
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "When not logged in" do
|
131
|
+
it "should not assign the requested order_list as @order_list" do
|
132
|
+
get :new
|
133
|
+
assigns(:order_list).should_not be_valid
|
134
|
+
response.should redirect_to(new_user_session_url)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "GET edit" do
|
140
|
+
describe "When logged in as Administrator" do
|
141
|
+
before(:each) do
|
142
|
+
sign_in FactoryGirl.create(:admin)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "assigns the requested order_list as @order_list" do
|
146
|
+
order_list = FactoryGirl.create(:order_list)
|
147
|
+
get :edit, :id => order_list.id
|
148
|
+
assigns(:order_list).should eq(order_list)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "When logged in as Librarian" do
|
153
|
+
before(:each) do
|
154
|
+
sign_in FactoryGirl.create(:librarian)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "assigns the requested order_list as @order_list" do
|
158
|
+
order_list = FactoryGirl.create(:order_list)
|
159
|
+
get :edit, :id => order_list.id
|
160
|
+
assigns(:order_list).should eq(order_list)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "When logged in as User" do
|
165
|
+
before(:each) do
|
166
|
+
sign_in FactoryGirl.create(:user)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "assigns the requested order_list as @order_list" do
|
170
|
+
order_list = FactoryGirl.create(:order_list)
|
171
|
+
get :edit, :id => order_list.id
|
172
|
+
response.should be_forbidden
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "When not logged in" do
|
177
|
+
it "should not assign the requested order_list as @order_list" do
|
178
|
+
order_list = FactoryGirl.create(:order_list)
|
179
|
+
get :edit, :id => order_list.id
|
180
|
+
response.should redirect_to(new_user_session_url)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe "POST create" do
|
186
|
+
before(:each) do
|
187
|
+
@attrs = FactoryGirl.attributes_for(:order_list)
|
188
|
+
@invalid_attrs = {:bookstore_id => ''}
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "When logged in as Administrator" do
|
192
|
+
before(:each) do
|
193
|
+
sign_in FactoryGirl.create(:admin)
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "with valid params" do
|
197
|
+
it "assigns a newly created order_list as @order_list" do
|
198
|
+
post :create, :order_list => @attrs
|
199
|
+
assigns(:order_list).should be_valid
|
200
|
+
end
|
201
|
+
|
202
|
+
it "redirects to the created order_list" do
|
203
|
+
post :create, :order_list => @attrs
|
204
|
+
response.should redirect_to(order_list_url(assigns(:order_list)))
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
describe "with invalid params" do
|
209
|
+
it "assigns a newly created but unsaved order_list as @order_list" do
|
210
|
+
post :create, :order_list => @invalid_attrs
|
211
|
+
assigns(:order_list).should_not be_valid
|
212
|
+
end
|
213
|
+
|
214
|
+
it "re-renders the 'new' template" do
|
215
|
+
post :create, :order_list => @invalid_attrs
|
216
|
+
response.should render_template("new")
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "When logged in as Librarian" do
|
222
|
+
before(:each) do
|
223
|
+
sign_in FactoryGirl.create(:librarian)
|
224
|
+
end
|
225
|
+
|
226
|
+
describe "with valid params" do
|
227
|
+
it "assigns a newly created order_list as @order_list" do
|
228
|
+
post :create, :order_list => @attrs
|
229
|
+
assigns(:order_list).should be_valid
|
230
|
+
end
|
231
|
+
|
232
|
+
it "redirects to the created order_list" do
|
233
|
+
post :create, :order_list => @attrs
|
234
|
+
response.should redirect_to(order_list_url(assigns(:order_list)))
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe "with invalid params" do
|
239
|
+
it "assigns a newly created but unsaved order_list as @order_list" do
|
240
|
+
post :create, :order_list => @invalid_attrs
|
241
|
+
assigns(:order_list).should_not be_valid
|
242
|
+
end
|
243
|
+
|
244
|
+
it "re-renders the 'new' template" do
|
245
|
+
post :create, :order_list => @invalid_attrs
|
246
|
+
response.should render_template("new")
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
describe "When logged in as User" do
|
252
|
+
before(:each) do
|
253
|
+
sign_in FactoryGirl.create(:user)
|
254
|
+
end
|
255
|
+
|
256
|
+
describe "with valid params" do
|
257
|
+
it "assigns a newly created order_list as @order_list" do
|
258
|
+
post :create, :order_list => @attrs
|
259
|
+
assigns(:order_list).should be_valid
|
260
|
+
end
|
261
|
+
|
262
|
+
it "should be forbidden" do
|
263
|
+
post :create, :order_list => @attrs
|
264
|
+
response.should be_forbidden
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
describe "with invalid params" do
|
269
|
+
it "assigns a newly created but unsaved order_list as @order_list" do
|
270
|
+
post :create, :order_list => @invalid_attrs
|
271
|
+
assigns(:order_list).should_not be_valid
|
272
|
+
end
|
273
|
+
|
274
|
+
it "should be forbidden" do
|
275
|
+
post :create, :order_list => @invalid_attrs
|
276
|
+
response.should be_forbidden
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe "When not logged in" do
|
282
|
+
describe "with valid params" do
|
283
|
+
it "assigns a newly created order_list as @order_list" do
|
284
|
+
post :create, :order_list => @attrs
|
285
|
+
assigns(:order_list).should be_valid
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should be forbidden" do
|
289
|
+
post :create, :order_list => @attrs
|
290
|
+
response.should redirect_to(new_user_session_url)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
describe "with invalid params" do
|
295
|
+
it "assigns a newly created but unsaved order_list as @order_list" do
|
296
|
+
post :create, :order_list => @invalid_attrs
|
297
|
+
assigns(:order_list).should_not be_valid
|
298
|
+
end
|
299
|
+
|
300
|
+
it "should be forbidden" do
|
301
|
+
post :create, :order_list => @invalid_attrs
|
302
|
+
response.should redirect_to(new_user_session_url)
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
describe "PUT update" do
|
309
|
+
before(:each) do
|
310
|
+
@order_list = FactoryGirl.create(:order_list)
|
311
|
+
@attrs = FactoryGirl.attributes_for(:order_list)
|
312
|
+
@invalid_attrs = {:bookstore_id => ''}
|
313
|
+
end
|
314
|
+
|
315
|
+
describe "When logged in as Administrator" do
|
316
|
+
before(:each) do
|
317
|
+
sign_in FactoryGirl.create(:admin)
|
318
|
+
end
|
319
|
+
|
320
|
+
describe "with valid params" do
|
321
|
+
it "updates the requested order_list" do
|
322
|
+
put :update, :id => @order_list.id, :order_list => @attrs
|
323
|
+
end
|
324
|
+
|
325
|
+
it "assigns the requested order_list as @order_list" do
|
326
|
+
put :update, :id => @order_list.id, :order_list => @attrs
|
327
|
+
assigns(:order_list).should eq(@order_list)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe "with invalid params" do
|
332
|
+
it "assigns the requested order_list as @order_list" do
|
333
|
+
put :update, :id => @order_list.id, :order_list => @invalid_attrs
|
334
|
+
response.should render_template("edit")
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
describe "When logged in as Librarian" do
|
340
|
+
before(:each) do
|
341
|
+
sign_in FactoryGirl.create(:librarian)
|
342
|
+
end
|
343
|
+
|
344
|
+
describe "with valid params" do
|
345
|
+
it "updates the requested order_list" do
|
346
|
+
put :update, :id => @order_list.id, :order_list => @attrs
|
347
|
+
end
|
348
|
+
|
349
|
+
it "assigns the requested order_list as @order_list" do
|
350
|
+
put :update, :id => @order_list.id, :order_list => @attrs
|
351
|
+
assigns(:order_list).should eq(@order_list)
|
352
|
+
response.should redirect_to(@order_list)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
describe "with invalid params" do
|
357
|
+
it "assigns the order_list as @order_list" do
|
358
|
+
put :update, :id => @order_list, :order_list => @invalid_attrs
|
359
|
+
assigns(:order_list).should_not be_valid
|
360
|
+
end
|
361
|
+
|
362
|
+
it "re-renders the 'edit' template" do
|
363
|
+
put :update, :id => @order_list, :order_list => @invalid_attrs
|
364
|
+
response.should render_template("edit")
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe "When logged in as User" do
|
370
|
+
before(:each) do
|
371
|
+
sign_in FactoryGirl.create(:user)
|
372
|
+
end
|
373
|
+
|
374
|
+
describe "with valid params" do
|
375
|
+
it "updates the requested order_list" do
|
376
|
+
put :update, :id => @order_list.id, :order_list => @attrs
|
377
|
+
end
|
378
|
+
|
379
|
+
it "assigns the requested order_list as @order_list" do
|
380
|
+
put :update, :id => @order_list.id, :order_list => @attrs
|
381
|
+
assigns(:order_list).should eq(@order_list)
|
382
|
+
response.should be_forbidden
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
describe "with invalid params" do
|
387
|
+
it "assigns the requested order_list as @order_list" do
|
388
|
+
put :update, :id => @order_list.id, :order_list => @invalid_attrs
|
389
|
+
response.should be_forbidden
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
describe "When not logged in" do
|
395
|
+
describe "with valid params" do
|
396
|
+
it "updates the requested order_list" do
|
397
|
+
put :update, :id => @order_list.id, :order_list => @attrs
|
398
|
+
end
|
399
|
+
|
400
|
+
it "should be forbidden" do
|
401
|
+
put :update, :id => @order_list.id, :order_list => @attrs
|
402
|
+
response.should redirect_to(new_user_session_url)
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
describe "with invalid params" do
|
407
|
+
it "assigns the requested order_list as @order_list" do
|
408
|
+
put :update, :id => @order_list.id, :order_list => @invalid_attrs
|
409
|
+
response.should redirect_to(new_user_session_url)
|
410
|
+
end
|
411
|
+
end
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
describe "DELETE destroy" do
|
416
|
+
before(:each) do
|
417
|
+
@order_list = FactoryGirl.create(:order_list)
|
418
|
+
end
|
419
|
+
|
420
|
+
describe "When logged in as Administrator" do
|
421
|
+
before(:each) do
|
422
|
+
sign_in FactoryGirl.create(:admin)
|
423
|
+
end
|
424
|
+
|
425
|
+
it "destroys the requested order_list" do
|
426
|
+
delete :destroy, :id => @order_list.id
|
427
|
+
end
|
428
|
+
|
429
|
+
it "redirects to the order_lists list" do
|
430
|
+
delete :destroy, :id => @order_list.id
|
431
|
+
response.should redirect_to(order_lists_url)
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
describe "When logged in as Librarian" do
|
436
|
+
before(:each) do
|
437
|
+
sign_in FactoryGirl.create(:librarian)
|
438
|
+
end
|
439
|
+
|
440
|
+
it "destroys the requested order_list" do
|
441
|
+
delete :destroy, :id => @order_list.id
|
442
|
+
end
|
443
|
+
|
444
|
+
it "should be forbidden" do
|
445
|
+
delete :destroy, :id => @order_list.id
|
446
|
+
response.should redirect_to(order_lists_url)
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
describe "When logged in as User" do
|
451
|
+
before(:each) do
|
452
|
+
sign_in FactoryGirl.create(:user)
|
453
|
+
end
|
454
|
+
|
455
|
+
it "destroys the requested order_list" do
|
456
|
+
delete :destroy, :id => @order_list.id
|
457
|
+
end
|
458
|
+
|
459
|
+
it "should be forbidden" do
|
460
|
+
delete :destroy, :id => @order_list.id
|
461
|
+
response.should be_forbidden
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
describe "When not logged in" do
|
466
|
+
it "destroys the requested order_list" do
|
467
|
+
delete :destroy, :id => @order_list.id
|
468
|
+
end
|
469
|
+
|
470
|
+
it "should be forbidden" do
|
471
|
+
delete :destroy, :id => @order_list.id
|
472
|
+
response.should redirect_to(new_user_session_url)
|
473
|
+
end
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end
|