enju_subject 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. data/app/views/classifications/_form.html.erb +1 -1
  2. data/app/views/classifications/show.html.erb +1 -6
  3. data/config/locales/translation_en.yml +51 -0
  4. data/config/locales/translation_ja.yml +51 -0
  5. data/config/routes.rb +1 -1
  6. data/lib/enju_subject/engine.rb +10 -1
  7. data/lib/enju_subject/version.rb +1 -1
  8. data/spec/controllers/subject_types_controller_spec.rb +443 -0
  9. data/spec/dummy/app/helpers/application_helper.rb +19 -0
  10. data/spec/dummy/app/models/ability.rb +2 -0
  11. data/spec/dummy/config/application.rb +1 -0
  12. data/spec/dummy/config/locales/en.yml +17 -4
  13. data/spec/dummy/config/locales/ja.yml +18 -0
  14. data/spec/dummy/config/routes.rb +1 -1
  15. data/spec/dummy/db/development.sqlite3 +0 -0
  16. data/spec/dummy/db/fixtures/roles.yml +25 -0
  17. data/spec/dummy/db/seeds.rb +32 -0
  18. data/spec/dummy/db/test.sqlite3 +0 -0
  19. data/spec/dummy/lib/localized_name.rb +13 -0
  20. data/spec/dummy/log/development.log +3567 -0
  21. data/spec/dummy/log/sunspot-solr-test.log +148 -148
  22. data/spec/dummy/log/test.log +23172 -0
  23. data/spec/dummy/tmp/cache/assets/CCF/E80/sprockets%2F43cd60a461caf54702cd11b375829b44 +378 -0
  24. data/spec/dummy/tmp/cache/assets/CDA/820/sprockets%2F44191072efee7bea4011292f2f3f8534 +9272 -0
  25. data/spec/dummy/tmp/cache/assets/D30/680/sprockets%2F814ab0b411639d1c77bcee7c1729d0a3 +9288 -0
  26. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  27. data/spec/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +10 -0
  28. data/spec/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +9652 -0
  29. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  30. data/spec/dummy/tmp/cache/assets/E31/450/sprockets%2F1dd81425dd80ff4bdf569eadd2e1a8ed +394 -0
  31. metadata +138 -9
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
 
14
14
  <div class="field">
15
- <%= f.label t('activerecord.models.classification') -%><br />
15
+ <%= f.label t('activerecord.models.classification_type') -%><br />
16
16
  <%= f.select(:classification_type_id, @classification_types.collect{|c| [c.name, c.id]}) -%>
17
17
  </div>
18
18
 
@@ -3,11 +3,6 @@
3
3
  <div id="content_list">
4
4
  <p id="notice"><%= notice %></p>
5
5
 
6
- <p>
7
- <strong><%= t('activerecord.attributes.classification.parent') -%>:</strong>
8
- <%= link_to @classification.parent.category, @classification.parent %>
9
- </p>
10
-
11
6
  <p>
12
7
  <strong><%= t('activerecord.attributes.classification.category') -%>:</strong>
13
8
  <%= @classification.category %>
@@ -20,7 +15,7 @@
20
15
 
21
16
  <p>
22
17
  <strong><%= t('activerecord.models.classification_type') -%>:</strong>
23
- <%= link_to @classification.classification_type.localize, @classification.classification_type %>
18
+ <%= link_to @classification.classification_type.display_name.localize, @classification.classification_type %>
24
19
  </p>
25
20
 
26
21
  </div>
@@ -0,0 +1,51 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ subject: Subject
5
+ work_has_subject: Resource has subject
6
+ subject_type: Subject type
7
+ subject_heading_type: Subject heading type
8
+ subject_heading_type_has_subject: Subject heading type to subject relationship
9
+ classification: Classification
10
+ classification_type: Classification type
11
+ subject_has_classification: Subject has classification
12
+ work: Work
13
+
14
+ attributes:
15
+ subject:
16
+ term: Term
17
+ term_transcription: Term transcription
18
+ scope_note: Scope note
19
+ note: Note
20
+ lock_version: Lock version
21
+ work_has_subject:
22
+ work: Work
23
+ subject: Subject
24
+ subjectable_type: Subjectable type
25
+ subject_type:
26
+ name: Name
27
+ display_name: Display name
28
+ note: Note
29
+ position: Position
30
+ subject_heading_type:
31
+ name: Name
32
+ display_name: Display name
33
+ note: Note
34
+ position: Position
35
+ subject_heading_type_has_subject:
36
+ classification:
37
+ category: Category
38
+ name: Name
39
+ note: Note
40
+ classification_type:
41
+ name: Name
42
+ display_name: Display name
43
+ note: Note
44
+ position: Position
45
+ subject_has_classification:
46
+
47
+ work_has_subject:
48
+ add_work: "Add a work"
49
+ add_subject: "Add a subject"
50
+ subjectable: "Subjectable"
51
+
@@ -0,0 +1,51 @@
1
+ ja:
2
+ activerecord:
3
+ models:
4
+ subject: 件名
5
+ work_has_subject: 資料と件名の関係
6
+ subject_type: 件名の種類
7
+ subject_heading_type: 件名標目の種類
8
+ subject_heading_type_has_subject: 件名標目と件名の関係
9
+ classification: 分類
10
+ classification_type: 分類型
11
+ subject_has_classification: 件名と分類の関係
12
+ work: 著作
13
+
14
+ attributes:
15
+ subject:
16
+ term: 用語
17
+ term_transcription: 用語よみ
18
+ scope_note: スコープ注記
19
+ note: 注記
20
+ lock_version: ロックバージョン
21
+ work_has_subject:
22
+ work: 書いた資料
23
+ subject: 件名
24
+ subjectable_type: 件名付与対象の種類
25
+ subject_type:
26
+ name: 名前
27
+ display_name: 表示名
28
+ note: 注記
29
+ position: 位置
30
+ subject_heading_type:
31
+ name: 名前
32
+ display_name: 表示名
33
+ note: 注記
34
+ position: 位置
35
+ subject_heading_type_has_subject:
36
+ classification:
37
+ category: カテゴリー
38
+ name: 名前
39
+ note: 注記
40
+ classification_type:
41
+ name: 名前
42
+ display_name: 表示名
43
+ note: 注記
44
+ position: 位置
45
+ subject_has_classification:
46
+
47
+ work_has_subject:
48
+ add_work: "書いた資料を追加する"
49
+ add_subject: "件名を追加する"
50
+ subjectable: "件名付与対象"
51
+
data/config/routes.rb CHANGED
@@ -8,7 +8,7 @@ Rails.application.routes.draw do
8
8
  resources :subject_has_classifications
9
9
  end
10
10
  resources :classification_types do
11
- resource :classifications
11
+ resources :classifications
12
12
  end
13
13
  resources :subject_types
14
14
 
@@ -1,4 +1,13 @@
1
+ require 'devise'
2
+ require 'cancan'
3
+ require 'inherited_resources'
4
+ require 'attribute_normalizer'
5
+ require 'friendly_id'
6
+ require 'will_paginate'
7
+ require 'sunspot_rails'
8
+ require 'dynamic_form'
9
+
1
10
  module EnjuSubject
2
- class Engine < Rails::Engine
11
+ class Engine < ::Rails::Engine
3
12
  end
4
13
  end
@@ -1,3 +1,3 @@
1
1
  module EnjuSubject
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -0,0 +1,443 @@
1
+ require 'spec_helper'
2
+ require 'sunspot/rails/spec_helper'
3
+
4
+ describe SubjectTypesController do
5
+ fixtures :all
6
+ disconnect_sunspot
7
+
8
+ describe "GET index" do
9
+ before(:each) do
10
+ FactoryGirl.create(:subject_type)
11
+ end
12
+
13
+ describe "When logged in as Administrator" do
14
+ login_admin
15
+
16
+ it "assigns all subject_types as @subject_types" do
17
+ get :index
18
+ assigns(:subject_types).should eq(SubjectType.all)
19
+ end
20
+ end
21
+
22
+ describe "When logged in as Librarian" do
23
+ login_librarian
24
+
25
+ it "assigns all subject_types as @subject_types" do
26
+ get :index
27
+ assigns(:subject_types).should eq(SubjectType.all)
28
+ end
29
+ end
30
+
31
+ describe "When logged in as User" do
32
+ login_user
33
+
34
+ it "assigns all subject_types as @subject_types" do
35
+ get :index
36
+ assigns(:subject_types).should be_empty
37
+ response.should be_forbidden
38
+ end
39
+ end
40
+
41
+ describe "When not logged in" do
42
+ it "assigns all subject_types as @subject_types" do
43
+ get :index
44
+ assigns(:subject_types).should be_empty
45
+ response.should redirect_to(new_user_session_url)
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "GET show" do
51
+ describe "When logged in as Administrator" do
52
+ login_admin
53
+
54
+ it "assigns the requested subject_type as @subject_type" do
55
+ subject_type = FactoryGirl.create(:subject_type)
56
+ get :show, :id => subject_type.id
57
+ assigns(:subject_type).should eq(subject_type)
58
+ end
59
+ end
60
+
61
+ describe "When logged in as Librarian" do
62
+ login_librarian
63
+
64
+ it "assigns the requested subject_type as @subject_type" do
65
+ subject_type = FactoryGirl.create(:subject_type)
66
+ get :show, :id => subject_type.id
67
+ assigns(:subject_type).should eq(subject_type)
68
+ end
69
+ end
70
+
71
+ describe "When logged in as User" do
72
+ login_user
73
+
74
+ it "assigns the requested subject_type as @subject_type" do
75
+ subject_type = FactoryGirl.create(:subject_type)
76
+ get :show, :id => subject_type.id
77
+ assigns(:subject_type).should eq(subject_type)
78
+ end
79
+ end
80
+
81
+ describe "When not logged in" do
82
+ it "assigns the requested subject_type as @subject_type" do
83
+ subject_type = FactoryGirl.create(:subject_type)
84
+ get :show, :id => subject_type.id
85
+ assigns(:subject_type).should eq(subject_type)
86
+ end
87
+ end
88
+ end
89
+
90
+ describe "GET new" do
91
+ describe "When logged in as Administrator" do
92
+ login_admin
93
+
94
+ it "assigns the requested subject_type as @subject_type" do
95
+ get :new
96
+ assigns(:subject_type).should_not be_valid
97
+ response.should be_success
98
+ end
99
+ end
100
+
101
+ describe "When logged in as Librarian" do
102
+ login_librarian
103
+
104
+ it "should not assign the requested subject_type as @subject_type" do
105
+ get :new
106
+ assigns(:subject_type).should_not be_valid
107
+ response.should be_forbidden
108
+ end
109
+ end
110
+
111
+ describe "When logged in as User" do
112
+ login_user
113
+
114
+ it "should not assign the requested subject_type as @subject_type" do
115
+ get :new
116
+ assigns(:subject_type).should_not be_valid
117
+ response.should be_forbidden
118
+ end
119
+ end
120
+
121
+ describe "When not logged in" do
122
+ it "should not assign the requested subject_type as @subject_type" do
123
+ get :new
124
+ assigns(:subject_type).should_not be_valid
125
+ response.should redirect_to(new_user_session_url)
126
+ end
127
+ end
128
+ end
129
+
130
+ describe "GET edit" do
131
+ describe "When logged in as Administrator" do
132
+ login_admin
133
+
134
+ it "assigns the requested subject_type as @subject_type" do
135
+ subject_type = FactoryGirl.create(:subject_type)
136
+ get :edit, :id => subject_type.id
137
+ assigns(:subject_type).should eq(subject_type)
138
+ end
139
+ end
140
+
141
+ describe "When logged in as Librarian" do
142
+ login_librarian
143
+
144
+ it "assigns the requested subject_type as @subject_type" do
145
+ subject_type = FactoryGirl.create(:subject_type)
146
+ get :edit, :id => subject_type.id
147
+ response.should be_forbidden
148
+ end
149
+ end
150
+
151
+ describe "When logged in as User" do
152
+ login_user
153
+
154
+ it "assigns the requested subject_type as @subject_type" do
155
+ subject_type = FactoryGirl.create(:subject_type)
156
+ get :edit, :id => subject_type.id
157
+ response.should be_forbidden
158
+ end
159
+ end
160
+
161
+ describe "When not logged in" do
162
+ it "should not assign the requested subject_type as @subject_type" do
163
+ subject_type = FactoryGirl.create(:subject_type)
164
+ get :edit, :id => subject_type.id
165
+ response.should redirect_to(new_user_session_url)
166
+ end
167
+ end
168
+ end
169
+
170
+ describe "POST create" do
171
+ before(:each) do
172
+ @attrs = FactoryGirl.attributes_for(:subject_type)
173
+ @invalid_attrs = {:name => ''}
174
+ end
175
+
176
+ describe "When logged in as Administrator" do
177
+ login_admin
178
+
179
+ describe "with valid params" do
180
+ it "assigns a newly created subject_type as @subject_type" do
181
+ post :create, :subject_type => @attrs
182
+ assigns(:subject_type).should be_valid
183
+ end
184
+
185
+ it "redirects to the created patron" do
186
+ post :create, :subject_type => @attrs
187
+ response.should redirect_to(assigns(:subject_type))
188
+ end
189
+ end
190
+
191
+ describe "with invalid params" do
192
+ it "assigns a newly created but unsaved subject_type as @subject_type" do
193
+ post :create, :subject_type => @invalid_attrs
194
+ assigns(:subject_type).should_not be_valid
195
+ end
196
+
197
+ it "should be successful" do
198
+ post :create, :subject_type => @invalid_attrs
199
+ response.should be_success
200
+ end
201
+ end
202
+ end
203
+
204
+ describe "When logged in as Librarian" do
205
+ login_librarian
206
+
207
+ describe "with valid params" do
208
+ it "assigns a newly created subject_type as @subject_type" do
209
+ post :create, :subject_type => @attrs
210
+ assigns(:subject_type).should be_valid
211
+ end
212
+
213
+ it "should be forbidden" do
214
+ post :create, :subject_type => @attrs
215
+ response.should be_forbidden
216
+ end
217
+ end
218
+
219
+ describe "with invalid params" do
220
+ it "assigns a newly created but unsaved subject_type as @subject_type" do
221
+ post :create, :subject_type => @invalid_attrs
222
+ assigns(:subject_type).should_not be_valid
223
+ end
224
+
225
+ it "should be forbidden" do
226
+ post :create, :subject_type => @invalid_attrs
227
+ response.should be_forbidden
228
+ end
229
+ end
230
+ end
231
+
232
+ describe "When logged in as User" do
233
+ login_user
234
+
235
+ describe "with valid params" do
236
+ it "assigns a newly created subject_type as @subject_type" do
237
+ post :create, :subject_type => @attrs
238
+ assigns(:subject_type).should be_valid
239
+ end
240
+
241
+ it "should be forbidden" do
242
+ post :create, :subject_type => @attrs
243
+ response.should be_forbidden
244
+ end
245
+ end
246
+
247
+ describe "with invalid params" do
248
+ it "assigns a newly created but unsaved subject_type as @subject_type" do
249
+ post :create, :subject_type => @invalid_attrs
250
+ assigns(:subject_type).should_not be_valid
251
+ end
252
+
253
+ it "should be forbidden" do
254
+ post :create, :subject_type => @invalid_attrs
255
+ response.should be_forbidden
256
+ end
257
+ end
258
+ end
259
+
260
+ describe "When not logged in" do
261
+ describe "with valid params" do
262
+ it "assigns a newly created subject_type as @subject_type" do
263
+ post :create, :subject_type => @attrs
264
+ assigns(:subject_type).should be_valid
265
+ end
266
+
267
+ it "should be forbidden" do
268
+ post :create, :subject_type => @attrs
269
+ response.should redirect_to(new_user_session_url)
270
+ end
271
+ end
272
+
273
+ describe "with invalid params" do
274
+ it "assigns a newly created but unsaved subject_type as @subject_type" do
275
+ post :create, :subject_type => @invalid_attrs
276
+ assigns(:subject_type).should_not be_valid
277
+ end
278
+
279
+ it "should be forbidden" do
280
+ post :create, :subject_type => @invalid_attrs
281
+ response.should redirect_to(new_user_session_url)
282
+ end
283
+ end
284
+ end
285
+ end
286
+
287
+ describe "PUT update" do
288
+ before(:each) do
289
+ @subject_type = FactoryGirl.create(:subject_type)
290
+ @attrs = FactoryGirl.attributes_for(:subject_type)
291
+ @invalid_attrs = {:name => ''}
292
+ end
293
+
294
+ describe "When logged in as Administrator" do
295
+ login_admin
296
+
297
+ describe "with valid params" do
298
+ it "updates the requested subject_type" do
299
+ put :update, :id => @subject_type.id, :subject_type => @attrs
300
+ end
301
+
302
+ it "assigns the requested subject_type as @subject_type" do
303
+ put :update, :id => @subject_type.id, :subject_type => @attrs
304
+ assigns(:subject_type).should eq(@subject_type)
305
+ end
306
+
307
+ it "moves its position when specified" do
308
+ put :update, :id => @subject_type.id, :subject_type => @attrs, :position => 2
309
+ response.should redirect_to(subject_types_url)
310
+ end
311
+ end
312
+
313
+ describe "with invalid params" do
314
+ it "assigns the requested subject_type as @subject_type" do
315
+ put :update, :id => @subject_type.id, :subject_type => @invalid_attrs
316
+ response.should render_template("edit")
317
+ end
318
+ end
319
+ end
320
+
321
+ describe "When logged in as Librarian" do
322
+ login_librarian
323
+
324
+ describe "with valid params" do
325
+ it "updates the requested subject_type" do
326
+ put :update, :id => @subject_type.id, :subject_type => @attrs
327
+ end
328
+
329
+ it "assigns the requested subject_type as @subject_type" do
330
+ put :update, :id => @subject_type.id, :subject_type => @attrs
331
+ assigns(:subject_type).should eq(@subject_type)
332
+ response.should be_forbidden
333
+ end
334
+ end
335
+
336
+ describe "with invalid params" do
337
+ it "assigns the requested subject_type as @subject_type" do
338
+ put :update, :id => @subject_type.id, :subject_type => @invalid_attrs
339
+ response.should be_forbidden
340
+ end
341
+ end
342
+ end
343
+
344
+ describe "When logged in as User" do
345
+ login_user
346
+
347
+ describe "with valid params" do
348
+ it "updates the requested subject_type" do
349
+ put :update, :id => @subject_type.id, :subject_type => @attrs
350
+ end
351
+
352
+ it "assigns the requested subject_type as @subject_type" do
353
+ put :update, :id => @subject_type.id, :subject_type => @attrs
354
+ assigns(:subject_type).should eq(@subject_type)
355
+ response.should be_forbidden
356
+ end
357
+ end
358
+
359
+ describe "with invalid params" do
360
+ it "assigns the requested subject_type as @subject_type" do
361
+ put :update, :id => @subject_type.id, :subject_type => @invalid_attrs
362
+ response.should be_forbidden
363
+ end
364
+ end
365
+ end
366
+
367
+ describe "When not logged in" do
368
+ describe "with valid params" do
369
+ it "updates the requested subject_type" do
370
+ put :update, :id => @subject_type.id, :subject_type => @attrs
371
+ end
372
+
373
+ it "should be forbidden" do
374
+ put :update, :id => @subject_type.id, :subject_type => @attrs
375
+ response.should redirect_to(new_user_session_url)
376
+ end
377
+ end
378
+
379
+ describe "with invalid params" do
380
+ it "assigns the requested subject_type as @subject_type" do
381
+ put :update, :id => @subject_type.id, :subject_type => @invalid_attrs
382
+ response.should redirect_to(new_user_session_url)
383
+ end
384
+ end
385
+ end
386
+ end
387
+
388
+ describe "DELETE destroy" do
389
+ before(:each) do
390
+ @subject_type = FactoryGirl.create(:subject_type)
391
+ end
392
+
393
+ describe "When logged in as Administrator" do
394
+ login_admin
395
+
396
+ it "destroys the requested subject_type" do
397
+ delete :destroy, :id => @subject_type.id
398
+ end
399
+
400
+ it "redirects to the subject_types list" do
401
+ delete :destroy, :id => @subject_type.id
402
+ response.should redirect_to(subject_types_url)
403
+ end
404
+ end
405
+
406
+ describe "When logged in as Librarian" do
407
+ login_librarian
408
+
409
+ it "destroys the requested subject_type" do
410
+ delete :destroy, :id => @subject_type.id
411
+ end
412
+
413
+ it "should be forbidden" do
414
+ delete :destroy, :id => @subject_type.id
415
+ response.should be_forbidden
416
+ end
417
+ end
418
+
419
+ describe "When logged in as User" do
420
+ login_user
421
+
422
+ it "destroys the requested subject_type" do
423
+ delete :destroy, :id => @subject_type.id
424
+ end
425
+
426
+ it "should be forbidden" do
427
+ delete :destroy, :id => @subject_type.id
428
+ response.should be_forbidden
429
+ end
430
+ end
431
+
432
+ describe "When not logged in" do
433
+ it "destroys the requested subject_type" do
434
+ delete :destroy, :id => @subject_type.id
435
+ end
436
+
437
+ it "should be forbidden" do
438
+ delete :destroy, :id => @subject_type.id
439
+ response.should redirect_to(new_user_session_url)
440
+ end
441
+ end
442
+ end
443
+ end