enju_biblio 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/app/assets/images/icons/book.png +0 -0
- data/app/assets/images/icons/cd.png +0 -0
- data/app/assets/images/icons/dvd.png +0 -0
- data/app/assets/images/icons/monitor.png +0 -0
- data/app/controllers/carrier_types_controller.rb +8 -3
- data/app/controllers/manifestations_controller.rb +17 -4
- data/app/controllers/picture_files_controller.rb +1 -1
- data/app/controllers/series_statements_controller.rb +6 -0
- data/app/helpers/manifestations_helper.rb +1 -1
- data/app/models/agent_import_file_transition.rb +1 -0
- data/app/models/carrier_type.rb +11 -7
- data/app/models/import_request_transition.rb +1 -0
- data/app/models/manifestation.rb +5 -0
- data/app/models/resource_export_file_transition.rb +1 -0
- data/app/models/resource_import_file_transition.rb +1 -0
- data/app/views/carrier_types/index.html.erb +4 -1
- data/app/views/manifestations/_show_detail_librarian.html.erb +4 -0
- data/app/views/manifestations/index.html.erb +3 -0
- data/config/locales/translation_en.yml +2 -0
- data/config/locales/translation_ja.yml +2 -0
- data/lib/enju_biblio/biblio_helper.rb +1 -12
- data/lib/enju_biblio/version.rb +1 -1
- data/lib/generators/enju_biblio/setup/templates/config/schedule.rb +3 -3
- data/lib/tasks/carrier_type.rb +30 -18
- data/lib/tasks/enju_biblio_tasks.rake +2 -0
- data/spec/controllers/agent_import_files_controller_spec.rb +87 -87
- data/spec/controllers/agent_import_results_controller_spec.rb +22 -22
- data/spec/controllers/agent_merge_lists_controller_spec.rb +157 -157
- data/spec/controllers/agent_merges_controller_spec.rb +151 -151
- data/spec/controllers/agent_relationship_types_controller_spec.rb +152 -152
- data/spec/controllers/agent_relationships_controller_spec.rb +153 -153
- data/spec/controllers/agent_types_controller_spec.rb +49 -50
- data/spec/controllers/agents_controller_spec.rb +234 -234
- data/spec/controllers/carrier_types_controller_spec.rb +123 -103
- data/spec/controllers/content_types_controller_spec.rb +51 -52
- data/spec/controllers/countries_controller_spec.rb +156 -156
- data/spec/controllers/create_types_controller_spec.rb +48 -49
- data/spec/controllers/creates_controller_spec.rb +154 -154
- data/spec/controllers/donates_controller_spec.rb +153 -153
- data/spec/controllers/form_of_works_controller_spec.rb +48 -49
- data/spec/controllers/frequencies_controller_spec.rb +51 -52
- data/spec/controllers/identifier_types_controller_spec.rb +48 -49
- data/spec/controllers/import_requests_controller_spec.rb +165 -164
- data/spec/controllers/items_controller_spec.rb +214 -216
- data/spec/controllers/languages_controller_spec.rb +109 -109
- data/spec/controllers/licenses_controller_spec.rb +48 -49
- data/spec/controllers/manifestation_relationship_types_controller_spec.rb +152 -152
- data/spec/controllers/manifestation_relationships_controller_spec.rb +153 -153
- data/spec/controllers/manifestations_controller_spec.rb +319 -289
- data/spec/controllers/medium_of_performances_controller_spec.rb +48 -49
- data/spec/controllers/owns_controller_spec.rb +153 -153
- data/spec/controllers/picture_files_controller_spec.rb +156 -156
- data/spec/controllers/produce_types_controller_spec.rb +48 -49
- data/spec/controllers/produces_controller_spec.rb +154 -154
- data/spec/controllers/realize_types_controller_spec.rb +48 -49
- data/spec/controllers/realizes_controller_spec.rb +155 -155
- data/spec/controllers/resource_export_files_controller_spec.rb +72 -72
- data/spec/controllers/resource_import_files_controller_spec.rb +90 -90
- data/spec/controllers/resource_import_results_controller_spec.rb +43 -43
- data/spec/controllers/series_statement_merge_lists_controller_spec.rb +153 -153
- data/spec/controllers/series_statement_merges_controller_spec.rb +151 -151
- data/spec/controllers/series_statements_controller_spec.rb +154 -154
- data/spec/factories/checkout.rb +9 -0
- data/spec/factories/library.rb +13 -0
- data/spec/factories/shelf.rb +6 -0
- data/spec/fixtures/carrier_types.yml +11 -7
- data/spec/models/carrier_type_spec.rb +11 -7
- data/spec/models/resource_export_file_spec.rb +58 -16
- data/spec/support/resque.rb +0 -1
- data/spec/views/manifestations/show.html.erb_spec.rb +5 -0
- data/spec/views/resource_import_files/index.html.erb_spec.rb +1 -1
- data/spec/views/resource_import_files/show.html.erb_spec.rb +1 -1
- data/spec/views/resource_import_results/index.html.erb_spec.rb +1 -1
- data/spec/views/resource_import_results/show.html.erb_spec.rb +1 -1
- metadata +49 -39
@@ -8,348 +8,346 @@ describe ItemsController do
|
|
8
8
|
FactoryGirl.attributes_for(:item)
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe 'GET index', solr: true do
|
12
12
|
before do
|
13
13
|
Item.reindex
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe 'When logged in as Administrator' do
|
17
17
|
login_fixture_admin
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'assigns all items as @items' do
|
20
20
|
get :index
|
21
21
|
expect(assigns(:items)).to_not be_nil
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe 'When logged in as Librarian' do
|
26
26
|
login_fixture_librarian
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'assigns all items as @items' do
|
29
29
|
get :index
|
30
30
|
expect(assigns(:items)).to_not be_nil
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'assigns items as @items with acquired_from and acquired_until' do
|
34
34
|
get :index, acquired_from: '2015-09-20', acquired_until: '2015-09-26'
|
35
35
|
expect(assigns(:items)).to_not be_nil
|
36
36
|
expect(assigns(:items).count).to eq 1
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it 'assigns items as @items with acquired_from' do
|
40
40
|
get :index, acquired_from: '2015-09-20'
|
41
41
|
expect(assigns(:items)).to_not be_nil
|
42
42
|
expect(assigns(:items).count).to eq 1
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'assigns items as @items with acquired_until' do
|
46
46
|
get :index, acquired_until: '2015-09-20'
|
47
47
|
expect(assigns(:items)).to_not be_nil
|
48
48
|
expect(assigns(:items).count).to eq 1
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
52
|
-
get :index, :
|
51
|
+
it 'should not get index with inventory_file_id' do
|
52
|
+
get :index, inventory_file_id: 1
|
53
53
|
expect(response).to be_success
|
54
54
|
assigns(:inventory_file).should eq InventoryFile.find(1)
|
55
55
|
expect(assigns(:items)).to eq Item.inventory_items(assigns(:inventory_file), 'not_on_shelf').order('items.id').page(1)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe
|
59
|
+
describe 'When logged in as User' do
|
60
60
|
login_fixture_user
|
61
61
|
|
62
|
-
it
|
62
|
+
it 'assigns all items as @items' do
|
63
63
|
get :index
|
64
64
|
expect(assigns(:items)).to_not be_nil
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
68
|
-
get :index, :
|
67
|
+
it 'should not get index with inventory_file_id' do
|
68
|
+
get :index, inventory_file_id: 1
|
69
69
|
expect(response).to be_forbidden
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
describe
|
74
|
-
it
|
73
|
+
describe 'When not logged in' do
|
74
|
+
it 'assigns all items as @items' do
|
75
75
|
get :index
|
76
76
|
expect(assigns(:items)).to_not be_nil
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
80
|
-
get :index, :
|
79
|
+
it 'should get index with agent_id' do
|
80
|
+
get :index, agent_id: 1
|
81
81
|
expect(response).to be_success
|
82
82
|
assigns(:agent).should eq Agent.find(1)
|
83
83
|
expect(assigns(:items)).to eq assigns(:agent).items.order('created_at DESC').page(1)
|
84
84
|
end
|
85
85
|
|
86
|
-
it
|
87
|
-
get :index, :
|
86
|
+
it 'should get index with manifestation_id' do
|
87
|
+
get :index, manifestation_id: 1
|
88
88
|
expect(response).to be_success
|
89
89
|
assigns(:manifestation).should eq Manifestation.find(1)
|
90
90
|
assigns(:items).collect(&:id).should eq assigns(:manifestation).items.order('items.created_at DESC').page(1).collect(&:id)
|
91
91
|
end
|
92
92
|
|
93
|
-
it
|
94
|
-
get :index, :
|
93
|
+
it 'should get index with shelf_id' do
|
94
|
+
get :index, shelf_id: 1
|
95
95
|
expect(response).to be_success
|
96
96
|
assigns(:shelf).should eq Shelf.find(1)
|
97
97
|
expect(assigns(:items)).to eq assigns(:shelf).items.order('created_at DESC').page(1)
|
98
98
|
end
|
99
99
|
|
100
|
-
it
|
101
|
-
get :index, :
|
100
|
+
it 'should not get index with inventory_file_id' do
|
101
|
+
get :index, inventory_file_id: 1
|
102
102
|
expect(response).to redirect_to new_user_session_url
|
103
103
|
assigns(:inventory_file).should_not be_nil
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
describe
|
108
|
+
describe 'GET show' do
|
109
109
|
before(:each) do
|
110
110
|
@item = FactoryGirl.create(:item)
|
111
111
|
end
|
112
112
|
|
113
|
-
describe
|
113
|
+
describe 'When logged in as Administrator' do
|
114
114
|
login_fixture_admin
|
115
115
|
|
116
|
-
it
|
117
|
-
get :show, :
|
116
|
+
it 'assigns the requested item as @item' do
|
117
|
+
get :show, id: @item.id
|
118
118
|
expect(assigns(:item)).to eq(@item)
|
119
119
|
end
|
120
120
|
|
121
|
-
it
|
122
|
-
lambda
|
123
|
-
get :show, :
|
124
|
-
|
125
|
-
#expect(response).to be_missing
|
121
|
+
it 'should not show missing item' do
|
122
|
+
lambda do
|
123
|
+
get :show, id: 'missing'
|
124
|
+
end.should raise_error(ActiveRecord::RecordNotFound)
|
125
|
+
# expect(response).to be_missing
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
describe
|
129
|
+
describe 'When logged in as Librarian' do
|
130
130
|
login_fixture_librarian
|
131
131
|
|
132
|
-
it
|
133
|
-
get :show, :
|
132
|
+
it 'assigns the requested item as @item' do
|
133
|
+
get :show, id: @item.id
|
134
134
|
expect(assigns(:item)).to eq(@item)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
-
describe
|
138
|
+
describe 'When logged in as User' do
|
139
139
|
login_fixture_user
|
140
140
|
|
141
|
-
it
|
142
|
-
get :show, :
|
141
|
+
it 'assigns the requested item as @item' do
|
142
|
+
get :show, id: @item.id
|
143
143
|
expect(assigns(:item)).to eq(@item)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
describe
|
148
|
-
it
|
149
|
-
get :show, :
|
147
|
+
describe 'When not logged in' do
|
148
|
+
it 'assigns the requested item as @item' do
|
149
|
+
get :show, id: @item.id
|
150
150
|
expect(assigns(:item)).to eq(@item)
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
describe
|
155
|
+
describe 'GET new' do
|
156
156
|
before(:each) do
|
157
157
|
@manifestation = FactoryGirl.create(:manifestation)
|
158
158
|
end
|
159
159
|
|
160
|
-
describe
|
160
|
+
describe 'When logged in as Administrator' do
|
161
161
|
login_fixture_admin
|
162
162
|
|
163
|
-
it
|
164
|
-
get :new, :
|
163
|
+
it 'assigns the requested item as @item' do
|
164
|
+
get :new, manifestation_id: @manifestation.id
|
165
165
|
expect(assigns(:item)).to be_valid
|
166
166
|
expect(response).to be_success
|
167
167
|
end
|
168
168
|
|
169
|
-
it
|
169
|
+
it 'should not get new without manifestation_id' do
|
170
170
|
get :new
|
171
171
|
expect(response).to redirect_to(manifestations_url)
|
172
172
|
end
|
173
173
|
|
174
|
-
it
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
get :new, :manifestation_id => @manifestation.id
|
182
|
-
expect(response).to redirect_to(libraries_url)
|
174
|
+
it 'should work without exception, even if library and shelf is unavailable' do
|
175
|
+
Library.real.each do |library|
|
176
|
+
library.try(:shelves).to_a.each(&:destroy)
|
177
|
+
library.destroy
|
178
|
+
end
|
179
|
+
get :new, manifestation_id: @manifestation.id
|
180
|
+
expect(response).to redirect_to(libraries_url)
|
183
181
|
end
|
184
182
|
|
185
|
-
it
|
183
|
+
it 'should not get new item for series_master' do
|
186
184
|
manifestation_serial = FactoryGirl.create(:manifestation_serial)
|
187
|
-
get :new, :
|
188
|
-
|
185
|
+
get :new, manifestation_id: manifestation_serial.id
|
186
|
+
expect(response).to redirect_to(manifestations_url(parent_id: manifestation_serial.id))
|
189
187
|
end
|
190
188
|
end
|
191
189
|
|
192
|
-
describe
|
190
|
+
describe 'When logged in as Librarian' do
|
193
191
|
login_fixture_librarian
|
194
192
|
|
195
|
-
it
|
196
|
-
get :new, :
|
193
|
+
it 'assigns the requested item as @item' do
|
194
|
+
get :new, manifestation_id: @manifestation.id
|
197
195
|
expect(assigns(:item)).to be_valid
|
198
196
|
expect(response).to be_success
|
199
197
|
end
|
200
198
|
end
|
201
199
|
|
202
|
-
describe
|
200
|
+
describe 'When logged in as User' do
|
203
201
|
login_fixture_user
|
204
202
|
|
205
|
-
it
|
206
|
-
get :new, :
|
203
|
+
it 'should not assign the requested item as @item' do
|
204
|
+
get :new, manifestation_id: @manifestation.id
|
207
205
|
expect(assigns(:item)).to be_nil
|
208
206
|
expect(response).to be_forbidden
|
209
207
|
end
|
210
208
|
end
|
211
209
|
|
212
|
-
describe
|
213
|
-
it
|
214
|
-
get :new, :
|
210
|
+
describe 'When not logged in' do
|
211
|
+
it 'should not assign the requested item as @item' do
|
212
|
+
get :new, manifestation_id: @manifestation.id
|
215
213
|
expect(assigns(:item)).to be_nil
|
216
214
|
expect(response).to redirect_to(new_user_session_url)
|
217
215
|
end
|
218
216
|
end
|
219
217
|
end
|
220
218
|
|
221
|
-
describe
|
222
|
-
describe
|
219
|
+
describe 'GET edit' do
|
220
|
+
describe 'When logged in as Administrator' do
|
223
221
|
login_fixture_admin
|
224
222
|
|
225
|
-
it
|
223
|
+
it 'assigns the requested item as @item' do
|
226
224
|
item = FactoryGirl.create(:item)
|
227
|
-
get :edit, :
|
225
|
+
get :edit, id: item.id
|
228
226
|
expect(assigns(:item)).to eq(item)
|
229
227
|
end
|
230
228
|
|
231
|
-
it
|
232
|
-
lambda
|
233
|
-
get :edit, :
|
234
|
-
|
235
|
-
#expect(response).to be_missing
|
229
|
+
it 'should not edit missing item' do
|
230
|
+
lambda do
|
231
|
+
get :edit, id: 'missing'
|
232
|
+
end.should raise_error(ActiveRecord::RecordNotFound)
|
233
|
+
# expect(response).to be_missing
|
236
234
|
end
|
237
235
|
end
|
238
236
|
|
239
|
-
describe
|
237
|
+
describe 'When logged in as Librarian' do
|
240
238
|
login_fixture_librarian
|
241
239
|
|
242
|
-
it
|
240
|
+
it 'assigns the requested item as @item' do
|
243
241
|
item = FactoryGirl.create(:item)
|
244
|
-
get :edit, :
|
242
|
+
get :edit, id: item.id
|
245
243
|
expect(assigns(:item)).to eq(item)
|
246
244
|
end
|
247
245
|
end
|
248
246
|
|
249
|
-
describe
|
247
|
+
describe 'When logged in as User' do
|
250
248
|
login_fixture_user
|
251
249
|
|
252
|
-
it
|
250
|
+
it 'assigns the requested item as @item' do
|
253
251
|
item = FactoryGirl.create(:item)
|
254
|
-
get :edit, :
|
252
|
+
get :edit, id: item.id
|
255
253
|
expect(response).to be_forbidden
|
256
254
|
end
|
257
255
|
end
|
258
256
|
|
259
|
-
describe
|
260
|
-
it
|
257
|
+
describe 'When not logged in' do
|
258
|
+
it 'should not assign the requested item as @item' do
|
261
259
|
item = FactoryGirl.create(:item)
|
262
|
-
get :edit, :
|
260
|
+
get :edit, id: item.id
|
263
261
|
expect(response).to redirect_to(new_user_session_url)
|
264
262
|
end
|
265
263
|
end
|
266
264
|
end
|
267
265
|
|
268
|
-
describe
|
266
|
+
describe 'POST create' do
|
269
267
|
before(:each) do
|
270
268
|
manifestation = FactoryGirl.create(:manifestation)
|
271
|
-
@attrs = FactoryGirl.attributes_for(:item, :
|
272
|
-
@invalid_attrs = {:
|
269
|
+
@attrs = FactoryGirl.attributes_for(:item, manifestation_id: manifestation.id)
|
270
|
+
@invalid_attrs = { item_identifier: '無効なID', manifestation_id: manifestation.id }
|
273
271
|
end
|
274
272
|
|
275
|
-
describe
|
273
|
+
describe 'When logged in as Administrator' do
|
276
274
|
login_fixture_admin
|
277
275
|
|
278
|
-
describe
|
279
|
-
it
|
280
|
-
post :create, :
|
276
|
+
describe 'with valid params' do
|
277
|
+
it 'assigns a newly created item as @item' do
|
278
|
+
post :create, item: @attrs
|
281
279
|
expect(assigns(:item)).to be_valid
|
282
280
|
end
|
283
281
|
|
284
|
-
it
|
285
|
-
post :create, :
|
282
|
+
it 'redirects to the created item' do
|
283
|
+
post :create, item: @attrs
|
286
284
|
assigns(:item).manifestation.should_not be_nil
|
287
285
|
expect(response).to redirect_to(item_url(assigns(:item)))
|
288
286
|
end
|
289
287
|
|
290
|
-
it
|
288
|
+
it 'should create a lending policy' do
|
291
289
|
old_lending_policy_count = LendingPolicy.count
|
292
|
-
post :create, :
|
290
|
+
post :create, item: @attrs
|
293
291
|
LendingPolicy.count.should eq old_lending_policy_count
|
294
292
|
end
|
295
293
|
end
|
296
294
|
|
297
|
-
describe
|
298
|
-
it
|
299
|
-
post :create, :
|
295
|
+
describe 'with invalid params' do
|
296
|
+
it 'assigns a newly created but unsaved item as @item' do
|
297
|
+
post :create, item: @invalid_attrs
|
300
298
|
expect(assigns(:item)).to_not be_valid
|
301
299
|
end
|
302
300
|
|
303
301
|
it "re-renders the 'new' template" do
|
304
|
-
post :create, :
|
305
|
-
expect(response).to render_template(
|
302
|
+
post :create, item: @invalid_attrs
|
303
|
+
expect(response).to render_template('new')
|
306
304
|
end
|
307
305
|
end
|
308
306
|
|
309
|
-
it
|
310
|
-
lambda
|
311
|
-
post :create, :
|
312
|
-
|
307
|
+
it 'should not create item without manifestation_id' do
|
308
|
+
lambda do
|
309
|
+
post :create, item: { circulation_status_id: 1 }
|
310
|
+
end.should raise_error(ActiveRecord::RecordNotFound)
|
313
311
|
expect(assigns(:item)).to_not be_valid
|
314
|
-
#expect(response).to be_missing
|
312
|
+
# expect(response).to be_missing
|
315
313
|
end
|
316
314
|
|
317
|
-
it
|
318
|
-
post :create, :
|
315
|
+
it 'should not create item already created' do
|
316
|
+
post :create, item: { circulation_status_id: 1, item_identifier: '00001', manifestation_id: 1 }
|
319
317
|
expect(assigns(:item)).to_not be_valid
|
320
318
|
expect(response).to be_success
|
321
319
|
end
|
322
320
|
end
|
323
321
|
|
324
|
-
describe
|
322
|
+
describe 'When logged in as Librarian' do
|
325
323
|
login_fixture_librarian
|
326
324
|
|
327
|
-
describe
|
328
|
-
it
|
329
|
-
post :create, :
|
325
|
+
describe 'with valid params' do
|
326
|
+
it 'assigns a newly created item as @item' do
|
327
|
+
post :create, item: @attrs
|
330
328
|
expect(assigns(:item)).to be_valid
|
331
329
|
end
|
332
330
|
|
333
|
-
it
|
334
|
-
post :create, :
|
331
|
+
it 'redirects to the created item' do
|
332
|
+
post :create, item: @attrs
|
335
333
|
expect(response).to redirect_to(item_url(assigns(:item)))
|
336
334
|
end
|
337
335
|
end
|
338
336
|
|
339
|
-
describe
|
340
|
-
it
|
341
|
-
post :create, :
|
337
|
+
describe 'with invalid params' do
|
338
|
+
it 'assigns a newly created but unsaved item as @item' do
|
339
|
+
post :create, item: @invalid_attrs
|
342
340
|
expect(assigns(:item)).to_not be_valid
|
343
341
|
end
|
344
342
|
|
345
343
|
it "re-renders the 'new' template" do
|
346
|
-
post :create, :
|
347
|
-
expect(response).to render_template(
|
344
|
+
post :create, item: @invalid_attrs
|
345
|
+
expect(response).to render_template('new')
|
348
346
|
end
|
349
347
|
end
|
350
348
|
|
351
|
-
it
|
352
|
-
post :create, :
|
349
|
+
it 'should create reserved item' do
|
350
|
+
post :create, item: { circulation_status_id: 1, manifestation_id: 2 }
|
353
351
|
expect(assigns(:item)).to be_valid
|
354
352
|
|
355
353
|
expect(response).to redirect_to item_url(assigns(:item))
|
@@ -370,236 +368,236 @@ describe ItemsController do
|
|
370
368
|
end
|
371
369
|
end
|
372
370
|
|
373
|
-
describe
|
371
|
+
describe 'When logged in as User' do
|
374
372
|
login_fixture_user
|
375
373
|
|
376
|
-
describe
|
377
|
-
it
|
378
|
-
post :create, :
|
374
|
+
describe 'with valid params' do
|
375
|
+
it 'assigns a newly created item as @item' do
|
376
|
+
post :create, item: @attrs
|
379
377
|
expect(assigns(:item)).to be_nil
|
380
378
|
end
|
381
379
|
|
382
|
-
it
|
383
|
-
post :create, :
|
380
|
+
it 'should be forbidden' do
|
381
|
+
post :create, item: @attrs
|
384
382
|
expect(response).to be_forbidden
|
385
383
|
end
|
386
384
|
end
|
387
385
|
|
388
|
-
describe
|
389
|
-
it
|
390
|
-
post :create, :
|
386
|
+
describe 'with invalid params' do
|
387
|
+
it 'assigns a newly created but unsaved item as @item' do
|
388
|
+
post :create, item: @invalid_attrs
|
391
389
|
expect(assigns(:item)).to be_nil
|
392
390
|
end
|
393
391
|
|
394
|
-
it
|
395
|
-
post :create, :
|
392
|
+
it 'should be forbidden' do
|
393
|
+
post :create, item: @invalid_attrs
|
396
394
|
expect(response).to be_forbidden
|
397
395
|
end
|
398
396
|
end
|
399
397
|
end
|
400
398
|
|
401
|
-
describe
|
402
|
-
describe
|
403
|
-
it
|
404
|
-
post :create, :
|
399
|
+
describe 'When not logged in' do
|
400
|
+
describe 'with valid params' do
|
401
|
+
it 'assigns a newly created item as @item' do
|
402
|
+
post :create, item: @attrs
|
405
403
|
expect(assigns(:item)).to be_nil
|
406
404
|
end
|
407
405
|
|
408
|
-
it
|
409
|
-
post :create, :
|
406
|
+
it 'should be forbidden' do
|
407
|
+
post :create, item: @attrs
|
410
408
|
expect(response).to redirect_to(new_user_session_url)
|
411
409
|
end
|
412
410
|
end
|
413
411
|
|
414
|
-
describe
|
415
|
-
it
|
416
|
-
post :create, :
|
412
|
+
describe 'with invalid params' do
|
413
|
+
it 'assigns a newly created but unsaved item as @item' do
|
414
|
+
post :create, item: @invalid_attrs
|
417
415
|
expect(assigns(:item)).to be_nil
|
418
416
|
end
|
419
417
|
|
420
|
-
it
|
421
|
-
post :create, :
|
418
|
+
it 'should be forbidden' do
|
419
|
+
post :create, item: @invalid_attrs
|
422
420
|
expect(response).to redirect_to(new_user_session_url)
|
423
421
|
end
|
424
422
|
end
|
425
423
|
end
|
426
424
|
end
|
427
425
|
|
428
|
-
describe
|
426
|
+
describe 'PUT update' do
|
429
427
|
before(:each) do
|
430
428
|
@item = FactoryGirl.create(:item)
|
431
429
|
@attrs = FactoryGirl.attributes_for(:item)
|
432
|
-
@invalid_attrs = {:
|
430
|
+
@invalid_attrs = { item_identifier: '無効なID' }
|
433
431
|
end
|
434
432
|
|
435
|
-
describe
|
433
|
+
describe 'When logged in as Administrator' do
|
436
434
|
login_fixture_admin
|
437
435
|
|
438
|
-
describe
|
439
|
-
it
|
440
|
-
put :update, :
|
436
|
+
describe 'with valid params' do
|
437
|
+
it 'updates the requested item' do
|
438
|
+
put :update, id: @item.id, item: @attrs
|
441
439
|
end
|
442
440
|
|
443
|
-
it
|
444
|
-
put :update, :
|
441
|
+
it 'assigns the requested item as @item' do
|
442
|
+
put :update, id: @item.id, item: @attrs
|
445
443
|
expect(assigns(:item)).to eq(@item)
|
446
444
|
end
|
447
445
|
end
|
448
446
|
|
449
|
-
describe
|
450
|
-
it
|
451
|
-
put :update, :
|
447
|
+
describe 'with invalid params' do
|
448
|
+
it 'assigns the requested item as @item' do
|
449
|
+
put :update, id: @item.id, item: @invalid_attrs
|
452
450
|
end
|
453
451
|
|
454
452
|
it "re-renders the 'edit' template" do
|
455
|
-
put :update, :
|
456
|
-
expect(response).to render_template(
|
453
|
+
put :update, id: @item, item: @invalid_attrs
|
454
|
+
expect(response).to render_template('edit')
|
457
455
|
end
|
458
456
|
end
|
459
457
|
end
|
460
458
|
|
461
|
-
describe
|
459
|
+
describe 'When logged in as Librarian' do
|
462
460
|
login_fixture_librarian
|
463
461
|
|
464
|
-
describe
|
465
|
-
it
|
466
|
-
put :update, :
|
462
|
+
describe 'with valid params' do
|
463
|
+
it 'updates the requested item' do
|
464
|
+
put :update, id: @item.id, item: @attrs
|
467
465
|
end
|
468
466
|
|
469
|
-
it
|
470
|
-
put :update, :
|
467
|
+
it 'assigns the requested item as @item' do
|
468
|
+
put :update, id: @item.id, item: @attrs
|
471
469
|
expect(assigns(:item)).to eq(@item)
|
472
470
|
expect(response).to redirect_to(@item)
|
473
471
|
end
|
474
472
|
end
|
475
473
|
|
476
|
-
describe
|
477
|
-
it
|
478
|
-
put :update, :
|
474
|
+
describe 'with invalid params' do
|
475
|
+
it 'assigns the item as @item' do
|
476
|
+
put :update, id: @item, item: @invalid_attrs
|
479
477
|
expect(assigns(:item)).to_not be_valid
|
480
478
|
end
|
481
479
|
|
482
480
|
it "re-renders the 'edit' template" do
|
483
|
-
put :update, :
|
484
|
-
expect(response).to render_template(
|
481
|
+
put :update, id: @item, item: @invalid_attrs
|
482
|
+
expect(response).to render_template('edit')
|
485
483
|
end
|
486
484
|
end
|
487
485
|
end
|
488
486
|
|
489
|
-
describe
|
487
|
+
describe 'When logged in as User' do
|
490
488
|
login_fixture_user
|
491
489
|
|
492
|
-
describe
|
493
|
-
it
|
494
|
-
put :update, :
|
490
|
+
describe 'with valid params' do
|
491
|
+
it 'updates the requested item' do
|
492
|
+
put :update, id: @item.id, item: @attrs
|
495
493
|
end
|
496
494
|
|
497
|
-
it
|
498
|
-
put :update, :
|
495
|
+
it 'assigns the requested item as @item' do
|
496
|
+
put :update, id: @item.id, item: @attrs
|
499
497
|
expect(assigns(:item)).to eq(@item)
|
500
498
|
expect(response).to be_forbidden
|
501
499
|
end
|
502
500
|
end
|
503
501
|
|
504
|
-
describe
|
505
|
-
it
|
506
|
-
put :update, :
|
502
|
+
describe 'with invalid params' do
|
503
|
+
it 'assigns the requested item as @item' do
|
504
|
+
put :update, id: @item.id, item: @invalid_attrs
|
507
505
|
expect(response).to be_forbidden
|
508
506
|
end
|
509
507
|
end
|
510
508
|
end
|
511
509
|
|
512
|
-
describe
|
513
|
-
describe
|
514
|
-
it
|
515
|
-
put :update, :
|
510
|
+
describe 'When not logged in' do
|
511
|
+
describe 'with valid params' do
|
512
|
+
it 'updates the requested item' do
|
513
|
+
put :update, id: @item.id, item: @attrs
|
516
514
|
end
|
517
515
|
|
518
|
-
it
|
519
|
-
put :update, :
|
516
|
+
it 'should be forbidden' do
|
517
|
+
put :update, id: @item.id, item: @attrs
|
520
518
|
expect(response).to redirect_to(new_user_session_url)
|
521
519
|
end
|
522
520
|
end
|
523
521
|
|
524
|
-
describe
|
525
|
-
it
|
526
|
-
put :update, :
|
522
|
+
describe 'with invalid params' do
|
523
|
+
it 'assigns the requested item as @item' do
|
524
|
+
put :update, id: @item.id, item: @invalid_attrs
|
527
525
|
expect(response).to redirect_to(new_user_session_url)
|
528
526
|
end
|
529
527
|
end
|
530
528
|
end
|
531
529
|
end
|
532
530
|
|
533
|
-
describe
|
531
|
+
describe 'DELETE destroy' do
|
534
532
|
before(:each) do
|
535
533
|
@item = items(:item_00006)
|
536
534
|
end
|
537
535
|
|
538
|
-
describe
|
536
|
+
describe 'When logged in as Administrator' do
|
539
537
|
login_fixture_admin
|
540
538
|
|
541
|
-
it
|
542
|
-
delete :destroy, :
|
539
|
+
it 'destroys the requested item' do
|
540
|
+
delete :destroy, id: @item.id
|
543
541
|
end
|
544
542
|
|
545
|
-
it
|
543
|
+
it 'redirects to the items list' do
|
546
544
|
manifestation = @item.manifestation
|
547
|
-
delete :destroy, :
|
545
|
+
delete :destroy, id: @item.id
|
548
546
|
expect(response).to redirect_to(items_url(manifestation_id: manifestation.id))
|
549
547
|
end
|
550
548
|
|
551
|
-
it
|
552
|
-
lambda
|
553
|
-
delete :destroy, :
|
554
|
-
|
555
|
-
#expect(response).to be_missing
|
549
|
+
it 'should not destroy missing item' do
|
550
|
+
lambda do
|
551
|
+
delete :destroy, id: 'missing'
|
552
|
+
end.should raise_error(ActiveRecord::RecordNotFound)
|
553
|
+
# expect(response).to be_missing
|
556
554
|
end
|
557
555
|
|
558
|
-
it
|
559
|
-
delete :destroy, :
|
556
|
+
it 'should not destroy item if not checked in' do
|
557
|
+
delete :destroy, id: 1
|
560
558
|
expect(response).to be_forbidden
|
561
559
|
end
|
562
560
|
|
563
|
-
it
|
564
|
-
delete :destroy, :
|
561
|
+
it 'should not destroy a removed item' do
|
562
|
+
delete :destroy, id: 23
|
565
563
|
expect(response).to be_forbidden
|
566
564
|
end
|
567
565
|
end
|
568
566
|
|
569
|
-
describe
|
567
|
+
describe 'When logged in as Librarian' do
|
570
568
|
login_fixture_librarian
|
571
569
|
|
572
|
-
it
|
573
|
-
delete :destroy, :
|
570
|
+
it 'destroys the requested item' do
|
571
|
+
delete :destroy, id: @item.id
|
574
572
|
end
|
575
573
|
|
576
|
-
it
|
574
|
+
it 'redirects to the items list' do
|
577
575
|
manifestation = @item.manifestation
|
578
|
-
delete :destroy, :
|
576
|
+
delete :destroy, id: @item.id
|
579
577
|
expect(response).to redirect_to(items_url(manifestation_id: manifestation.id))
|
580
578
|
end
|
581
579
|
end
|
582
580
|
|
583
|
-
describe
|
581
|
+
describe 'When logged in as User' do
|
584
582
|
login_fixture_user
|
585
583
|
|
586
|
-
it
|
587
|
-
delete :destroy, :
|
584
|
+
it 'destroys the requested item' do
|
585
|
+
delete :destroy, id: @item.id
|
588
586
|
end
|
589
587
|
|
590
|
-
it
|
591
|
-
delete :destroy, :
|
588
|
+
it 'should be forbidden' do
|
589
|
+
delete :destroy, id: @item.id
|
592
590
|
expect(response).to be_forbidden
|
593
591
|
end
|
594
592
|
end
|
595
593
|
|
596
|
-
describe
|
597
|
-
it
|
598
|
-
delete :destroy, :
|
594
|
+
describe 'When not logged in' do
|
595
|
+
it 'destroys the requested item' do
|
596
|
+
delete :destroy, id: @item.id
|
599
597
|
end
|
600
598
|
|
601
|
-
it
|
602
|
-
delete :destroy, :
|
599
|
+
it 'should be forbidden' do
|
600
|
+
delete :destroy, id: @item.id
|
603
601
|
expect(response).to redirect_to(new_user_session_url)
|
604
602
|
end
|
605
603
|
end
|