enju_subject 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/enju_subject/version.rb +1 -1
- data/spec/controllers/classification_types_controller_spec.rb +152 -152
- data/spec/controllers/classifications_controller_spec.rb +152 -152
- data/spec/controllers/subject_heading_types_controller_spec.rb +108 -108
- data/spec/controllers/subject_types_controller_spec.rb +152 -152
- data/spec/controllers/subjects_controller_spec.rb +150 -150
- metadata +200 -214
@@ -7,122 +7,122 @@ describe ClassificationsController do
|
|
7
7
|
FactoryGirl.attributes_for(:classification)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe 'GET index', solr: true do
|
11
11
|
before do
|
12
12
|
Classification.reindex
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe 'When logged in as Administrator' do
|
16
16
|
login_admin
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'assigns all classifications as @classifications' do
|
19
19
|
get :index
|
20
20
|
expect(assigns(:classifications)).not_to be_empty
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
24
|
+
describe 'When logged in as Librarian' do
|
25
25
|
login_librarian
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'assigns all classifications as @classifications' do
|
28
28
|
get :index
|
29
29
|
expect(assigns(:classifications)).not_to be_empty
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe
|
33
|
+
describe 'When logged in as User' do
|
34
34
|
login_user
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'assigns all classifications as @classifications' do
|
37
37
|
get :index
|
38
38
|
expect(assigns(:classifications)).not_to be_empty
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe
|
43
|
-
it
|
42
|
+
describe 'When not logged in' do
|
43
|
+
it 'assigns all classifications as @classifications' do
|
44
44
|
get :index
|
45
45
|
expect(assigns(:classifications)).not_to be_empty
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
49
|
-
get :index, :
|
48
|
+
it 'should get index with query' do
|
49
|
+
get :index, query: '500'
|
50
50
|
response.should be_success
|
51
51
|
expect(assigns(:classifications)).not_to be_empty
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
56
|
+
describe 'GET show' do
|
57
57
|
before(:each) do
|
58
58
|
@classification = FactoryGirl.create(:classification)
|
59
59
|
end
|
60
60
|
|
61
|
-
describe
|
61
|
+
describe 'When logged in as Administrator' do
|
62
62
|
login_admin
|
63
63
|
|
64
|
-
it
|
65
|
-
get :show, :
|
64
|
+
it 'assigns the requested classification as @classification' do
|
65
|
+
get :show, id: @classification.id
|
66
66
|
expect(assigns(:classification)).to eq(@classification)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe
|
70
|
+
describe 'When logged in as Librarian' do
|
71
71
|
login_librarian
|
72
72
|
|
73
|
-
it
|
74
|
-
get :show, :
|
73
|
+
it 'assigns the requested classification as @classification' do
|
74
|
+
get :show, id: @classification.id
|
75
75
|
expect(assigns(:classification)).to eq(@classification)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
79
|
+
describe 'When logged in as User' do
|
80
80
|
login_user
|
81
81
|
|
82
|
-
it
|
83
|
-
get :show, :
|
82
|
+
it 'assigns the requested classification as @classification' do
|
83
|
+
get :show, id: @classification.id
|
84
84
|
expect(assigns(:classification)).to eq(@classification)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
describe
|
89
|
-
it
|
90
|
-
get :show, :
|
88
|
+
describe 'When not logged in' do
|
89
|
+
it 'assigns the requested classification as @classification' do
|
90
|
+
get :show, id: @classification.id
|
91
91
|
expect(assigns(:classification)).to eq(@classification)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
describe
|
97
|
-
describe
|
96
|
+
describe 'GET new' do
|
97
|
+
describe 'When logged in as Administrator' do
|
98
98
|
login_admin
|
99
99
|
|
100
|
-
it
|
100
|
+
it 'assigns the requested classification as @classification' do
|
101
101
|
get :new
|
102
102
|
expect(assigns(:classification)).not_to be_valid
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
describe
|
106
|
+
describe 'When logged in as Librarian' do
|
107
107
|
login_librarian
|
108
108
|
|
109
|
-
it
|
109
|
+
it 'assigns the requested classification as @classification' do
|
110
110
|
get :new
|
111
111
|
expect(assigns(:classification)).to be_nil
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
describe
|
115
|
+
describe 'When logged in as User' do
|
116
116
|
login_user
|
117
117
|
|
118
|
-
it
|
118
|
+
it 'should assign the requested classification as @classification' do
|
119
119
|
get :new
|
120
120
|
expect(assigns(:classification)).to be_nil
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
describe
|
125
|
-
it
|
124
|
+
describe 'When not logged in' do
|
125
|
+
it 'should not assign the requested classification as @classification' do
|
126
126
|
get :new
|
127
127
|
expect(assigns(:classification)).to be_nil
|
128
128
|
response.should redirect_to(new_user_session_url)
|
@@ -130,310 +130,310 @@ describe ClassificationsController do
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
-
describe
|
134
|
-
describe
|
133
|
+
describe 'GET edit' do
|
134
|
+
describe 'When logged in as Administrator' do
|
135
135
|
login_admin
|
136
136
|
|
137
|
-
it
|
137
|
+
it 'assigns the requested classification as @classification' do
|
138
138
|
classification = FactoryGirl.create(:classification)
|
139
|
-
get :edit, :
|
139
|
+
get :edit, id: classification.id
|
140
140
|
expect(assigns(:classification)).to eq(classification)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
describe
|
144
|
+
describe 'When logged in as Librarian' do
|
145
145
|
login_librarian
|
146
146
|
|
147
|
-
it
|
147
|
+
it 'assigns the requested classification as @classification' do
|
148
148
|
classification = FactoryGirl.create(:classification)
|
149
|
-
get :edit, :
|
149
|
+
get :edit, id: classification.id
|
150
150
|
expect(assigns(:classification)).to eq(classification)
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
-
describe
|
154
|
+
describe 'When logged in as User' do
|
155
155
|
login_user
|
156
156
|
|
157
|
-
it
|
157
|
+
it 'assigns the requested classification as @classification' do
|
158
158
|
classification = FactoryGirl.create(:classification)
|
159
|
-
get :edit, :
|
159
|
+
get :edit, id: classification.id
|
160
160
|
response.should be_forbidden
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
-
describe
|
165
|
-
it
|
164
|
+
describe 'When not logged in' do
|
165
|
+
it 'should not assign the requested classification as @classification' do
|
166
166
|
classification = FactoryGirl.create(:classification)
|
167
|
-
get :edit, :
|
167
|
+
get :edit, id: classification.id
|
168
168
|
response.should redirect_to(new_user_session_url)
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
-
describe
|
173
|
+
describe 'POST create' do
|
174
174
|
before(:each) do
|
175
175
|
@attrs = valid_attributes
|
176
|
-
@invalid_attrs = {:
|
176
|
+
@invalid_attrs = { category: '' }
|
177
177
|
end
|
178
178
|
|
179
|
-
describe
|
179
|
+
describe 'When logged in as Administrator' do
|
180
180
|
login_admin
|
181
181
|
|
182
|
-
describe
|
183
|
-
it
|
184
|
-
post :create, :
|
182
|
+
describe 'with valid params' do
|
183
|
+
it 'assigns a newly created classification as @classification' do
|
184
|
+
post :create, classification: @attrs
|
185
185
|
expect(assigns(:classification)).to be_valid
|
186
186
|
end
|
187
187
|
|
188
|
-
it
|
189
|
-
post :create, :
|
188
|
+
it 'redirects to the created classification' do
|
189
|
+
post :create, classification: @attrs
|
190
190
|
response.should redirect_to(classification_url(assigns(:classification)))
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
|
-
describe
|
195
|
-
it
|
196
|
-
post :create, :
|
194
|
+
describe 'with invalid params' do
|
195
|
+
it 'assigns a newly created but unsaved classification as @classification' do
|
196
|
+
post :create, classification: @invalid_attrs
|
197
197
|
expect(assigns(:classification)).not_to be_valid
|
198
198
|
end
|
199
199
|
|
200
200
|
it "re-renders the 'new' template" do
|
201
|
-
post :create, :
|
202
|
-
response.should render_template(
|
201
|
+
post :create, classification: @invalid_attrs
|
202
|
+
response.should render_template('new')
|
203
203
|
end
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
-
describe
|
207
|
+
describe 'When logged in as Librarian' do
|
208
208
|
login_librarian
|
209
209
|
|
210
|
-
describe
|
211
|
-
it
|
212
|
-
post :create, :
|
210
|
+
describe 'with valid params' do
|
211
|
+
it 'assigns a newly created classification as @classification' do
|
212
|
+
post :create, classification: @attrs
|
213
213
|
expect(assigns(:classification)).to be_nil
|
214
214
|
end
|
215
215
|
|
216
|
-
it
|
217
|
-
post :create, :
|
216
|
+
it 'should be forbidden' do
|
217
|
+
post :create, classification: @attrs
|
218
218
|
response.should be_forbidden
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
222
|
-
describe
|
223
|
-
it
|
224
|
-
post :create, :
|
222
|
+
describe 'with invalid params' do
|
223
|
+
it 'assigns a newly created but unsaved classification as @classification' do
|
224
|
+
post :create, classification: @invalid_attrs
|
225
225
|
expect(assigns(:classification)).to be_nil
|
226
226
|
end
|
227
227
|
|
228
|
-
it
|
229
|
-
post :create, :
|
228
|
+
it 'should be forbidden' do
|
229
|
+
post :create, classification: @invalid_attrs
|
230
230
|
response.should be_forbidden
|
231
231
|
end
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
235
|
-
describe
|
235
|
+
describe 'When logged in as User' do
|
236
236
|
login_user
|
237
237
|
|
238
|
-
describe
|
239
|
-
it
|
240
|
-
post :create, :
|
238
|
+
describe 'with valid params' do
|
239
|
+
it 'assigns a newly created classification as @classification' do
|
240
|
+
post :create, classification: @attrs
|
241
241
|
expect(assigns(:classification)).to be_nil
|
242
242
|
end
|
243
243
|
|
244
|
-
it
|
245
|
-
post :create, :
|
244
|
+
it 'should be forbidden' do
|
245
|
+
post :create, classification: @attrs
|
246
246
|
response.should be_forbidden
|
247
247
|
end
|
248
248
|
end
|
249
249
|
|
250
|
-
describe
|
251
|
-
it
|
252
|
-
post :create, :
|
250
|
+
describe 'with invalid params' do
|
251
|
+
it 'assigns a newly created but unsaved classification as @classification' do
|
252
|
+
post :create, classification: @invalid_attrs
|
253
253
|
expect(assigns(:classification)).to be_nil
|
254
254
|
end
|
255
255
|
|
256
|
-
it
|
257
|
-
post :create, :
|
256
|
+
it 'should be forbidden' do
|
257
|
+
post :create, classification: @invalid_attrs
|
258
258
|
response.should be_forbidden
|
259
259
|
end
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
263
|
-
describe
|
264
|
-
describe
|
265
|
-
it
|
266
|
-
post :create, :
|
263
|
+
describe 'When not logged in' do
|
264
|
+
describe 'with valid params' do
|
265
|
+
it 'assigns a newly created classification as @classification' do
|
266
|
+
post :create, classification: @attrs
|
267
267
|
expect(assigns(:classification)).to be_nil
|
268
268
|
end
|
269
269
|
|
270
|
-
it
|
271
|
-
post :create, :
|
270
|
+
it 'should be forbidden' do
|
271
|
+
post :create, classification: @attrs
|
272
272
|
response.should redirect_to(new_user_session_url)
|
273
273
|
end
|
274
274
|
end
|
275
275
|
|
276
|
-
describe
|
277
|
-
it
|
278
|
-
post :create, :
|
276
|
+
describe 'with invalid params' do
|
277
|
+
it 'assigns a newly created but unsaved classification as @classification' do
|
278
|
+
post :create, classification: @invalid_attrs
|
279
279
|
expect(assigns(:classification)).to be_nil
|
280
280
|
end
|
281
281
|
|
282
|
-
it
|
283
|
-
post :create, :
|
282
|
+
it 'should be forbidden' do
|
283
|
+
post :create, classification: @invalid_attrs
|
284
284
|
response.should redirect_to(new_user_session_url)
|
285
285
|
end
|
286
286
|
end
|
287
287
|
end
|
288
288
|
end
|
289
289
|
|
290
|
-
describe
|
290
|
+
describe 'PUT update' do
|
291
291
|
before(:each) do
|
292
292
|
@classification = FactoryGirl.create(:classification)
|
293
293
|
@attrs = valid_attributes
|
294
|
-
@invalid_attrs = {:
|
294
|
+
@invalid_attrs = { category: '' }
|
295
295
|
end
|
296
296
|
|
297
|
-
describe
|
297
|
+
describe 'When logged in as Administrator' do
|
298
298
|
login_admin
|
299
299
|
|
300
|
-
describe
|
301
|
-
it
|
302
|
-
put :update, :
|
300
|
+
describe 'with valid params' do
|
301
|
+
it 'updates the requested classification' do
|
302
|
+
put :update, id: @classification.id, classification: @attrs
|
303
303
|
end
|
304
304
|
|
305
|
-
it
|
306
|
-
put :update, :
|
305
|
+
it 'assigns the requested classification as @classification' do
|
306
|
+
put :update, id: @classification.id, classification: @attrs
|
307
307
|
expect(assigns(:classification)).to eq(@classification)
|
308
308
|
end
|
309
309
|
end
|
310
310
|
|
311
|
-
describe
|
312
|
-
it
|
313
|
-
put :update, :
|
314
|
-
response.should render_template(
|
311
|
+
describe 'with invalid params' do
|
312
|
+
it 'assigns the requested classification as @classification' do
|
313
|
+
put :update, id: @classification.id, classification: @invalid_attrs
|
314
|
+
response.should render_template('edit')
|
315
315
|
end
|
316
316
|
end
|
317
317
|
end
|
318
318
|
|
319
|
-
describe
|
319
|
+
describe 'When logged in as Librarian' do
|
320
320
|
login_librarian
|
321
321
|
|
322
|
-
describe
|
323
|
-
it
|
324
|
-
put :update, :
|
322
|
+
describe 'with valid params' do
|
323
|
+
it 'updates the requested classification' do
|
324
|
+
put :update, id: @classification.id, classification: @attrs
|
325
325
|
end
|
326
326
|
|
327
|
-
it
|
328
|
-
put :update, :
|
327
|
+
it 'should be forbidden' do
|
328
|
+
put :update, id: @classification.id, classification: @attrs
|
329
329
|
expect(assigns(:classification)).to eq(@classification)
|
330
330
|
response.should be_forbidden
|
331
331
|
end
|
332
332
|
end
|
333
333
|
|
334
|
-
describe
|
335
|
-
it
|
336
|
-
put :update, :
|
334
|
+
describe 'with invalid params' do
|
335
|
+
it 'should be forbidden' do
|
336
|
+
put :update, id: @classification, classification: @invalid_attrs
|
337
337
|
response.should be_forbidden
|
338
338
|
end
|
339
339
|
end
|
340
340
|
end
|
341
341
|
|
342
|
-
describe
|
342
|
+
describe 'When logged in as User' do
|
343
343
|
login_user
|
344
344
|
|
345
|
-
describe
|
346
|
-
it
|
347
|
-
put :update, :
|
345
|
+
describe 'with valid params' do
|
346
|
+
it 'updates the requested classification' do
|
347
|
+
put :update, id: @classification.id, classification: @attrs
|
348
348
|
end
|
349
349
|
|
350
|
-
it
|
351
|
-
put :update, :
|
350
|
+
it 'assigns the requested classification as @classification' do
|
351
|
+
put :update, id: @classification.id, classification: @attrs
|
352
352
|
expect(assigns(:classification)).to eq(@classification)
|
353
353
|
response.should be_forbidden
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
357
|
-
describe
|
358
|
-
it
|
359
|
-
put :update, :
|
357
|
+
describe 'with invalid params' do
|
358
|
+
it 'assigns the requested classification as @classification' do
|
359
|
+
put :update, id: @classification.id, classification: @invalid_attrs
|
360
360
|
response.should be_forbidden
|
361
361
|
end
|
362
362
|
end
|
363
363
|
end
|
364
364
|
|
365
|
-
describe
|
366
|
-
describe
|
367
|
-
it
|
368
|
-
put :update, :
|
365
|
+
describe 'When not logged in' do
|
366
|
+
describe 'with valid params' do
|
367
|
+
it 'updates the requested classification' do
|
368
|
+
put :update, id: @classification.id, classification: @attrs
|
369
369
|
end
|
370
370
|
|
371
|
-
it
|
372
|
-
put :update, :
|
371
|
+
it 'should be forbidden' do
|
372
|
+
put :update, id: @classification.id, classification: @attrs
|
373
373
|
response.should redirect_to(new_user_session_url)
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
377
|
-
describe
|
378
|
-
it
|
379
|
-
put :update, :
|
377
|
+
describe 'with invalid params' do
|
378
|
+
it 'assigns the requested classification as @classification' do
|
379
|
+
put :update, id: @classification.id, classification: @invalid_attrs
|
380
380
|
response.should redirect_to(new_user_session_url)
|
381
381
|
end
|
382
382
|
end
|
383
383
|
end
|
384
384
|
end
|
385
385
|
|
386
|
-
describe
|
386
|
+
describe 'DELETE destroy' do
|
387
387
|
before(:each) do
|
388
388
|
@classification = FactoryGirl.create(:classification)
|
389
389
|
end
|
390
390
|
|
391
|
-
describe
|
391
|
+
describe 'When logged in as Administrator' do
|
392
392
|
login_admin
|
393
393
|
|
394
|
-
it
|
395
|
-
delete :destroy, :
|
394
|
+
it 'destroys the requested classification' do
|
395
|
+
delete :destroy, id: @classification.id
|
396
396
|
end
|
397
397
|
|
398
|
-
it
|
399
|
-
delete :destroy, :
|
398
|
+
it 'redirects to the classifications list' do
|
399
|
+
delete :destroy, id: @classification.id
|
400
400
|
response.should redirect_to(classifications_url)
|
401
401
|
end
|
402
402
|
end
|
403
403
|
|
404
|
-
describe
|
404
|
+
describe 'When logged in as Librarian' do
|
405
405
|
login_librarian
|
406
406
|
|
407
|
-
it
|
408
|
-
delete :destroy, :
|
407
|
+
it 'destroys the requested classification' do
|
408
|
+
delete :destroy, id: @classification.id
|
409
409
|
end
|
410
410
|
|
411
|
-
it
|
412
|
-
delete :destroy, :
|
411
|
+
it 'should be forbidden' do
|
412
|
+
delete :destroy, id: @classification.id
|
413
413
|
response.should be_forbidden
|
414
414
|
end
|
415
415
|
end
|
416
416
|
|
417
|
-
describe
|
417
|
+
describe 'When logged in as User' do
|
418
418
|
login_user
|
419
419
|
|
420
|
-
it
|
421
|
-
delete :destroy, :
|
420
|
+
it 'destroys the requested classification' do
|
421
|
+
delete :destroy, id: @classification.id
|
422
422
|
end
|
423
423
|
|
424
|
-
it
|
425
|
-
delete :destroy, :
|
424
|
+
it 'should be forbidden' do
|
425
|
+
delete :destroy, id: @classification.id
|
426
426
|
response.should be_forbidden
|
427
427
|
end
|
428
428
|
end
|
429
429
|
|
430
|
-
describe
|
431
|
-
it
|
432
|
-
delete :destroy, :
|
430
|
+
describe 'When not logged in' do
|
431
|
+
it 'destroys the requested classification' do
|
432
|
+
delete :destroy, id: @classification.id
|
433
433
|
end
|
434
434
|
|
435
|
-
it
|
436
|
-
delete :destroy, :
|
435
|
+
it 'should be forbidden' do
|
436
|
+
delete :destroy, id: @classification.id
|
437
437
|
response.should redirect_to(new_user_session_url)
|
438
438
|
end
|
439
439
|
end
|