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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/icons/book.png +0 -0
  3. data/app/assets/images/icons/cd.png +0 -0
  4. data/app/assets/images/icons/dvd.png +0 -0
  5. data/app/assets/images/icons/monitor.png +0 -0
  6. data/app/controllers/carrier_types_controller.rb +8 -3
  7. data/app/controllers/manifestations_controller.rb +17 -4
  8. data/app/controllers/picture_files_controller.rb +1 -1
  9. data/app/controllers/series_statements_controller.rb +6 -0
  10. data/app/helpers/manifestations_helper.rb +1 -1
  11. data/app/models/agent_import_file_transition.rb +1 -0
  12. data/app/models/carrier_type.rb +11 -7
  13. data/app/models/import_request_transition.rb +1 -0
  14. data/app/models/manifestation.rb +5 -0
  15. data/app/models/resource_export_file_transition.rb +1 -0
  16. data/app/models/resource_import_file_transition.rb +1 -0
  17. data/app/views/carrier_types/index.html.erb +4 -1
  18. data/app/views/manifestations/_show_detail_librarian.html.erb +4 -0
  19. data/app/views/manifestations/index.html.erb +3 -0
  20. data/config/locales/translation_en.yml +2 -0
  21. data/config/locales/translation_ja.yml +2 -0
  22. data/lib/enju_biblio/biblio_helper.rb +1 -12
  23. data/lib/enju_biblio/version.rb +1 -1
  24. data/lib/generators/enju_biblio/setup/templates/config/schedule.rb +3 -3
  25. data/lib/tasks/carrier_type.rb +30 -18
  26. data/lib/tasks/enju_biblio_tasks.rake +2 -0
  27. data/spec/controllers/agent_import_files_controller_spec.rb +87 -87
  28. data/spec/controllers/agent_import_results_controller_spec.rb +22 -22
  29. data/spec/controllers/agent_merge_lists_controller_spec.rb +157 -157
  30. data/spec/controllers/agent_merges_controller_spec.rb +151 -151
  31. data/spec/controllers/agent_relationship_types_controller_spec.rb +152 -152
  32. data/spec/controllers/agent_relationships_controller_spec.rb +153 -153
  33. data/spec/controllers/agent_types_controller_spec.rb +49 -50
  34. data/spec/controllers/agents_controller_spec.rb +234 -234
  35. data/spec/controllers/carrier_types_controller_spec.rb +123 -103
  36. data/spec/controllers/content_types_controller_spec.rb +51 -52
  37. data/spec/controllers/countries_controller_spec.rb +156 -156
  38. data/spec/controllers/create_types_controller_spec.rb +48 -49
  39. data/spec/controllers/creates_controller_spec.rb +154 -154
  40. data/spec/controllers/donates_controller_spec.rb +153 -153
  41. data/spec/controllers/form_of_works_controller_spec.rb +48 -49
  42. data/spec/controllers/frequencies_controller_spec.rb +51 -52
  43. data/spec/controllers/identifier_types_controller_spec.rb +48 -49
  44. data/spec/controllers/import_requests_controller_spec.rb +165 -164
  45. data/spec/controllers/items_controller_spec.rb +214 -216
  46. data/spec/controllers/languages_controller_spec.rb +109 -109
  47. data/spec/controllers/licenses_controller_spec.rb +48 -49
  48. data/spec/controllers/manifestation_relationship_types_controller_spec.rb +152 -152
  49. data/spec/controllers/manifestation_relationships_controller_spec.rb +153 -153
  50. data/spec/controllers/manifestations_controller_spec.rb +319 -289
  51. data/spec/controllers/medium_of_performances_controller_spec.rb +48 -49
  52. data/spec/controllers/owns_controller_spec.rb +153 -153
  53. data/spec/controllers/picture_files_controller_spec.rb +156 -156
  54. data/spec/controllers/produce_types_controller_spec.rb +48 -49
  55. data/spec/controllers/produces_controller_spec.rb +154 -154
  56. data/spec/controllers/realize_types_controller_spec.rb +48 -49
  57. data/spec/controllers/realizes_controller_spec.rb +155 -155
  58. data/spec/controllers/resource_export_files_controller_spec.rb +72 -72
  59. data/spec/controllers/resource_import_files_controller_spec.rb +90 -90
  60. data/spec/controllers/resource_import_results_controller_spec.rb +43 -43
  61. data/spec/controllers/series_statement_merge_lists_controller_spec.rb +153 -153
  62. data/spec/controllers/series_statement_merges_controller_spec.rb +151 -151
  63. data/spec/controllers/series_statements_controller_spec.rb +154 -154
  64. data/spec/factories/checkout.rb +9 -0
  65. data/spec/factories/library.rb +13 -0
  66. data/spec/factories/shelf.rb +6 -0
  67. data/spec/fixtures/carrier_types.yml +11 -7
  68. data/spec/models/carrier_type_spec.rb +11 -7
  69. data/spec/models/resource_export_file_spec.rb +58 -16
  70. data/spec/support/resque.rb +0 -1
  71. data/spec/views/manifestations/show.html.erb_spec.rb +5 -0
  72. data/spec/views/resource_import_files/index.html.erb_spec.rb +1 -1
  73. data/spec/views/resource_import_files/show.html.erb_spec.rb +1 -1
  74. data/spec/views/resource_import_results/index.html.erb_spec.rb +1 -1
  75. data/spec/views/resource_import_results/show.html.erb_spec.rb +1 -1
  76. metadata +49 -39
@@ -8,348 +8,346 @@ describe ItemsController do
8
8
  FactoryGirl.attributes_for(:item)
9
9
  end
10
10
 
11
- describe "GET index", :solr => true do
11
+ describe 'GET index', solr: true do
12
12
  before do
13
13
  Item.reindex
14
14
  end
15
15
 
16
- describe "When logged in as Administrator" do
16
+ describe 'When logged in as Administrator' do
17
17
  login_fixture_admin
18
18
 
19
- it "assigns all items as @items" do
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 "When logged in as Librarian" do
25
+ describe 'When logged in as Librarian' do
26
26
  login_fixture_librarian
27
27
 
28
- it "assigns all items as @items" do
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 "assigns items as @items with acquired_from and acquired_until" do
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 "assigns items as @items with acquired_from" do
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 "assigns items as @items with acquired_until" do
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 "should not get index with inventory_file_id" do
52
- get :index, :inventory_file_id => 1
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 "When logged in as User" do
59
+ describe 'When logged in as User' do
60
60
  login_fixture_user
61
61
 
62
- it "assigns all items as @items" do
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 "should not get index with inventory_file_id" do
68
- get :index, :inventory_file_id => 1
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 "When not logged in" do
74
- it "assigns all items as @items" do
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 "should get index with agent_id" do
80
- get :index, :agent_id => 1
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 "should get index with manifestation_id" do
87
- get :index, :manifestation_id => 1
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 "should get index with shelf_id" do
94
- get :index, :shelf_id => 1
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 "should not get index with inventory_file_id" do
101
- get :index, :inventory_file_id => 1
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 "GET show" do
108
+ describe 'GET show' do
109
109
  before(:each) do
110
110
  @item = FactoryGirl.create(:item)
111
111
  end
112
112
 
113
- describe "When logged in as Administrator" do
113
+ describe 'When logged in as Administrator' do
114
114
  login_fixture_admin
115
115
 
116
- it "assigns the requested item as @item" do
117
- get :show, :id => @item.id
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 "should not show missing item" do
122
- lambda{
123
- get :show, :id => 'missing'
124
- }.should raise_error(ActiveRecord::RecordNotFound)
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 "When logged in as Librarian" do
129
+ describe 'When logged in as Librarian' do
130
130
  login_fixture_librarian
131
131
 
132
- it "assigns the requested item as @item" do
133
- get :show, :id => @item.id
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 "When logged in as User" do
138
+ describe 'When logged in as User' do
139
139
  login_fixture_user
140
140
 
141
- it "assigns the requested item as @item" do
142
- get :show, :id => @item.id
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 "When not logged in" do
148
- it "assigns the requested item as @item" do
149
- get :show, :id => @item.id
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 "GET new" do
155
+ describe 'GET new' do
156
156
  before(:each) do
157
157
  @manifestation = FactoryGirl.create(:manifestation)
158
158
  end
159
159
 
160
- describe "When logged in as Administrator" do
160
+ describe 'When logged in as Administrator' do
161
161
  login_fixture_admin
162
162
 
163
- it "assigns the requested item as @item" do
164
- get :new, :manifestation_id => @manifestation.id
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 "should not get new without manifestation_id" do
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 "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 do |shelf|
177
- shelf.destroy
178
- end
179
- library.destroy
180
- end
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 "should not get new item for series_master" do
183
+ it 'should not get new item for series_master' do
186
184
  manifestation_serial = FactoryGirl.create(:manifestation_serial)
187
- get :new, :manifestation_id => manifestation_serial.id
188
- expect(response).to redirect_to(manifestations_url(parent_id: manifestation_serial.id))
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 "When logged in as Librarian" do
190
+ describe 'When logged in as Librarian' do
193
191
  login_fixture_librarian
194
192
 
195
- it "assigns the requested item as @item" do
196
- get :new, :manifestation_id => @manifestation.id
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 "When logged in as User" do
200
+ describe 'When logged in as User' do
203
201
  login_fixture_user
204
202
 
205
- it "should not assign the requested item as @item" do
206
- get :new, :manifestation_id => @manifestation.id
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 "When not logged in" do
213
- it "should not assign the requested item as @item" do
214
- get :new, :manifestation_id => @manifestation.id
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 "GET edit" do
222
- describe "When logged in as Administrator" do
219
+ describe 'GET edit' do
220
+ describe 'When logged in as Administrator' do
223
221
  login_fixture_admin
224
222
 
225
- it "assigns the requested item as @item" do
223
+ it 'assigns the requested item as @item' do
226
224
  item = FactoryGirl.create(:item)
227
- get :edit, :id => item.id
225
+ get :edit, id: item.id
228
226
  expect(assigns(:item)).to eq(item)
229
227
  end
230
228
 
231
- it "should not edit missing item" do
232
- lambda{
233
- get :edit, :id => 'missing'
234
- }.should raise_error(ActiveRecord::RecordNotFound)
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 "When logged in as Librarian" do
237
+ describe 'When logged in as Librarian' do
240
238
  login_fixture_librarian
241
239
 
242
- it "assigns the requested item as @item" do
240
+ it 'assigns the requested item as @item' do
243
241
  item = FactoryGirl.create(:item)
244
- get :edit, :id => item.id
242
+ get :edit, id: item.id
245
243
  expect(assigns(:item)).to eq(item)
246
244
  end
247
245
  end
248
246
 
249
- describe "When logged in as User" do
247
+ describe 'When logged in as User' do
250
248
  login_fixture_user
251
249
 
252
- it "assigns the requested item as @item" do
250
+ it 'assigns the requested item as @item' do
253
251
  item = FactoryGirl.create(:item)
254
- get :edit, :id => item.id
252
+ get :edit, id: item.id
255
253
  expect(response).to be_forbidden
256
254
  end
257
255
  end
258
256
 
259
- describe "When not logged in" do
260
- it "should not assign the requested item as @item" do
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, :id => item.id
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 "POST create" do
266
+ describe 'POST create' do
269
267
  before(:each) do
270
268
  manifestation = FactoryGirl.create(:manifestation)
271
- @attrs = FactoryGirl.attributes_for(:item, :manifestation_id => manifestation.id)
272
- @invalid_attrs = {:item_identifier => '無効なID', :manifestation_id => manifestation.id}
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 "When logged in as Administrator" do
273
+ describe 'When logged in as Administrator' do
276
274
  login_fixture_admin
277
275
 
278
- describe "with valid params" do
279
- it "assigns a newly created item as @item" do
280
- post :create, :item => @attrs
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 "redirects to the created item" do
285
- post :create, :item => @attrs
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 "should create a lending policy" do
288
+ it 'should create a lending policy' do
291
289
  old_lending_policy_count = LendingPolicy.count
292
- post :create, :item => @attrs
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 "with invalid params" do
298
- it "assigns a newly created but unsaved item as @item" do
299
- post :create, :item => @invalid_attrs
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, :item => @invalid_attrs
305
- expect(response).to render_template("new")
302
+ post :create, item: @invalid_attrs
303
+ expect(response).to render_template('new')
306
304
  end
307
305
  end
308
306
 
309
- it "should not create item without manifestation_id" do
310
- lambda{
311
- post :create, :item => { :circulation_status_id => 1 }
312
- }.should raise_error(ActiveRecord::RecordNotFound)
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 "should not create item already created" do
318
- post :create, :item => { :circulation_status_id => 1, :item_identifier => "00001", :manifestation_id => 1}
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 "When logged in as Librarian" do
322
+ describe 'When logged in as Librarian' do
325
323
  login_fixture_librarian
326
324
 
327
- describe "with valid params" do
328
- it "assigns a newly created item as @item" do
329
- post :create, :item => @attrs
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 "redirects to the created item" do
334
- post :create, :item => @attrs
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 "with invalid params" do
340
- it "assigns a newly created but unsaved item as @item" do
341
- post :create, :item => @invalid_attrs
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, :item => @invalid_attrs
347
- expect(response).to render_template("new")
344
+ post :create, item: @invalid_attrs
345
+ expect(response).to render_template('new')
348
346
  end
349
347
  end
350
348
 
351
- it "should create reserved item" do
352
- post :create, :item => { :circulation_status_id => 1, :manifestation_id => 2}
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 "When logged in as User" do
371
+ describe 'When logged in as User' do
374
372
  login_fixture_user
375
373
 
376
- describe "with valid params" do
377
- it "assigns a newly created item as @item" do
378
- post :create, :item => @attrs
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 "should be forbidden" do
383
- post :create, :item => @attrs
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 "with invalid params" do
389
- it "assigns a newly created but unsaved item as @item" do
390
- post :create, :item => @invalid_attrs
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 "should be forbidden" do
395
- post :create, :item => @invalid_attrs
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 "When not logged in" do
402
- describe "with valid params" do
403
- it "assigns a newly created item as @item" do
404
- post :create, :item => @attrs
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 "should be forbidden" do
409
- post :create, :item => @attrs
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 "with invalid params" do
415
- it "assigns a newly created but unsaved item as @item" do
416
- post :create, :item => @invalid_attrs
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 "should be forbidden" do
421
- post :create, :item => @invalid_attrs
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 "PUT update" do
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 = {:item_identifier => '無効なID'}
430
+ @invalid_attrs = { item_identifier: '無効なID' }
433
431
  end
434
432
 
435
- describe "When logged in as Administrator" do
433
+ describe 'When logged in as Administrator' do
436
434
  login_fixture_admin
437
435
 
438
- describe "with valid params" do
439
- it "updates the requested item" do
440
- put :update, :id => @item.id, :item => @attrs
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 "assigns the requested item as @item" do
444
- put :update, :id => @item.id, :item => @attrs
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 "with invalid params" do
450
- it "assigns the requested item as @item" do
451
- put :update, :id => @item.id, :item => @invalid_attrs
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, :id => @item, :item => @invalid_attrs
456
- expect(response).to render_template("edit")
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 "When logged in as Librarian" do
459
+ describe 'When logged in as Librarian' do
462
460
  login_fixture_librarian
463
461
 
464
- describe "with valid params" do
465
- it "updates the requested item" do
466
- put :update, :id => @item.id, :item => @attrs
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 "assigns the requested item as @item" do
470
- put :update, :id => @item.id, :item => @attrs
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 "with invalid params" do
477
- it "assigns the item as @item" do
478
- put :update, :id => @item, :item => @invalid_attrs
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, :id => @item, :item => @invalid_attrs
484
- expect(response).to render_template("edit")
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 "When logged in as User" do
487
+ describe 'When logged in as User' do
490
488
  login_fixture_user
491
489
 
492
- describe "with valid params" do
493
- it "updates the requested item" do
494
- put :update, :id => @item.id, :item => @attrs
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 "assigns the requested item as @item" do
498
- put :update, :id => @item.id, :item => @attrs
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 "with invalid params" do
505
- it "assigns the requested item as @item" do
506
- put :update, :id => @item.id, :item => @invalid_attrs
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 "When not logged in" do
513
- describe "with valid params" do
514
- it "updates the requested item" do
515
- put :update, :id => @item.id, :item => @attrs
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 "should be forbidden" do
519
- put :update, :id => @item.id, :item => @attrs
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 "with invalid params" do
525
- it "assigns the requested item as @item" do
526
- put :update, :id => @item.id, :item => @invalid_attrs
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 "DELETE destroy" do
531
+ describe 'DELETE destroy' do
534
532
  before(:each) do
535
533
  @item = items(:item_00006)
536
534
  end
537
535
 
538
- describe "When logged in as Administrator" do
536
+ describe 'When logged in as Administrator' do
539
537
  login_fixture_admin
540
538
 
541
- it "destroys the requested item" do
542
- delete :destroy, :id => @item.id
539
+ it 'destroys the requested item' do
540
+ delete :destroy, id: @item.id
543
541
  end
544
542
 
545
- it "redirects to the items list" do
543
+ it 'redirects to the items list' do
546
544
  manifestation = @item.manifestation
547
- delete :destroy, :id => @item.id
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 "should not destroy missing item" do
552
- lambda{
553
- delete :destroy, :id => 'missing'
554
- }.should raise_error(ActiveRecord::RecordNotFound)
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 "should not destroy item if not checked in" do
559
- delete :destroy, :id => 1
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 "should not destroy a removed item" do
564
- delete :destroy, :id => 23
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 "When logged in as Librarian" do
567
+ describe 'When logged in as Librarian' do
570
568
  login_fixture_librarian
571
569
 
572
- it "destroys the requested item" do
573
- delete :destroy, :id => @item.id
570
+ it 'destroys the requested item' do
571
+ delete :destroy, id: @item.id
574
572
  end
575
573
 
576
- it "redirects to the items list" do
574
+ it 'redirects to the items list' do
577
575
  manifestation = @item.manifestation
578
- delete :destroy, :id => @item.id
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 "When logged in as User" do
581
+ describe 'When logged in as User' do
584
582
  login_fixture_user
585
583
 
586
- it "destroys the requested item" do
587
- delete :destroy, :id => @item.id
584
+ it 'destroys the requested item' do
585
+ delete :destroy, id: @item.id
588
586
  end
589
587
 
590
- it "should be forbidden" do
591
- delete :destroy, :id => @item.id
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 "When not logged in" do
597
- it "destroys the requested item" do
598
- delete :destroy, :id => @item.id
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 "should be forbidden" do
602
- delete :destroy, :id => @item.id
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