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