enju_subject 0.1.1 → 0.2.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -3
  3. data/app/controllers/classification_types_controller.rb +13 -2
  4. data/app/controllers/classifications_controller.rb +12 -3
  5. data/app/controllers/concerns/enju_subject/controller.rb +27 -0
  6. data/app/controllers/subject_heading_types_controller.rb +13 -2
  7. data/app/controllers/subject_types_controller.rb +13 -2
  8. data/app/controllers/subjects_controller.rb +12 -4
  9. data/app/models/classification.rb +1 -1
  10. data/app/models/classification_type.rb +0 -1
  11. data/app/models/concerns/enju_subject/enju_manifestation.rb +37 -0
  12. data/app/models/subject.rb +1 -1
  13. data/app/models/subject_heading_type.rb +0 -1
  14. data/app/models/subject_type.rb +0 -1
  15. data/app/policies/classification_policy.rb +21 -0
  16. data/app/policies/classification_type_policy.rb +23 -0
  17. data/app/policies/subject_heading_type_policy.rb +23 -0
  18. data/app/policies/subject_policy.rb +21 -0
  19. data/app/policies/subject_type_policy.rb +21 -0
  20. data/app/views/classification_types/index.html.erb +4 -4
  21. data/app/views/classification_types/show.html.erb +2 -2
  22. data/app/views/classifications/index.html.erb +2 -2
  23. data/app/views/classifications/show.html.erb +2 -2
  24. data/app/views/manifestations/_classification_fields.html.erb +5 -0
  25. data/app/views/manifestations/_subject_facet.html.erb +2 -2
  26. data/app/views/manifestations/_subject_fields.html.erb +6 -0
  27. data/app/views/manifestations/_subject_form.html.erb +8 -9
  28. data/app/views/subject_heading_types/index.html.erb +4 -4
  29. data/app/views/subject_heading_types/show.html.erb +2 -2
  30. data/app/views/subject_types/index.html.erb +4 -4
  31. data/app/views/subject_types/show.html.erb +2 -2
  32. data/app/views/subjects/index.html.erb +3 -3
  33. data/app/views/subjects/index.rss.builder +2 -2
  34. data/app/views/subjects/show.html.erb +3 -3
  35. data/db/fixtures/subject_types.yml +4 -4
  36. data/lib/enju_subject/master_model.rb +3 -3
  37. data/lib/enju_subject/version.rb +1 -1
  38. data/lib/enju_subject.rb +0 -29
  39. data/lib/generators/enju_subject/setup/setup_generator.rb +6 -1
  40. data/lib/generators/enju_subject/setup/templates/db/fixtures/classification_types.yml +6 -0
  41. data/lib/generators/enju_subject/setup/templates/db/fixtures/subject_heading_types.yml +6 -6
  42. data/lib/tasks/enju_subject_tasks.rake +1 -1
  43. data/spec/controllers/classification_types_controller_spec.rb +13 -13
  44. data/spec/controllers/classifications_controller_spec.rb +9 -9
  45. data/spec/controllers/subject_heading_types_controller_spec.rb +58 -58
  46. data/spec/controllers/subject_types_controller_spec.rb +13 -13
  47. data/spec/controllers/subjects_controller_spec.rb +9 -9
  48. data/spec/dummy/app/controllers/application_controller.rb +8 -4
  49. data/spec/dummy/app/models/user.rb +1 -1
  50. data/spec/dummy/config/application.rb +5 -24
  51. data/spec/dummy/config/environments/development.rb +25 -14
  52. data/spec/dummy/config/environments/production.rb +50 -31
  53. data/spec/dummy/config/environments/test.rb +23 -18
  54. data/spec/dummy/config/initializers/enju_leaf.rb +1 -0
  55. data/spec/dummy/db/schema.rb +2 -1
  56. data/spec/lib/generators/enju_subject/setup/setup_generator_spec.rb +34 -0
  57. data/spec/support/devise.rb +2 -1
  58. metadata +95 -20
  59. data/app/models/enju_subject/ability.rb +0 -58
  60. data/lib/enju_subject/manifestation.rb +0 -44
  61. data/spec/dummy/app/models/ability.rb +0 -59
  62. data/spec/dummy/config/application.yml +0 -38
  63. data/spec/dummy/config/initializers/assets.rb +0 -12
@@ -4,11 +4,11 @@ xml.rss('version' => "2.0",
4
4
  'xmlns:atom' => "http://www.w3.org/2005/Atom"){
5
5
  xml.channel{
6
6
  xml.title t('page.listing', model: t('activerecord.models.subject')) + " (#{@library_group.display_name.localize})"
7
- xml.link "#{request.protocol}#{request.host_with_port}#{url_for(params.merge(format: nil, only_path: true))}"
7
+ xml.link "#{request.protocol}#{request.host_with_port}#{url_for(params.permit.merge(format: nil, only_path: true))}"
8
8
  xml.description "Next-L Enju, an open source integrated library system developed by Project Next-L"
9
9
  xml.language @locale.to_s
10
10
  xml.ttl "60"
11
- xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(params.merge(format: :rss, only_path: true))}"
11
+ xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(params.permit.merge(format: :rss, only_path: true))}"
12
12
  xml.tag! "atom:link", rel: 'alternate', href: subjects_url
13
13
  xml.tag! "atom:link", rel: 'search', type: 'application/opensearchdescription+xml', href: page_opensearch_url
14
14
  unless params[:query].blank?
@@ -32,11 +32,11 @@
32
32
 
33
33
  <div id="submenu" class="ui-corner-all ui-widget-content">
34
34
  <ul>
35
- <li><%= back_to_index(flash[:page_info]) -%></li>
36
- <% if can? :update, @subject %>
35
+ <li><%= link_to t('page.back'), :back -%></li>
36
+ <% if policy(@subject).update? %>
37
37
  <li><%= link_to t('page.edit'), edit_subject_path(@subject) -%></li>
38
38
  <% end %>
39
- <% if can? :delete, @subject %>
39
+ <% if policy(@subject).destroy? %>
40
40
  <li><%= link_to t('page.destroy'), subject_path(@subject), data: {confirm: t('page.are_you_sure')}, method: :delete -%></li>
41
41
  <% end %>
42
42
  </ul>
@@ -1,28 +1,28 @@
1
1
  ---
2
2
  subject_type_00001:
3
3
  id: 1
4
- name: Concept
4
+ name: concept
5
5
  display_name: Concept
6
6
  note:
7
7
  position: 1
8
8
 
9
9
  subject_type_00002:
10
10
  id: 2
11
- name: Event
11
+ name: event
12
12
  display_name: Event
13
13
  note:
14
14
  position: 2
15
15
 
16
16
  subject_type_00003:
17
17
  id: 3
18
- name: Object
18
+ name: object
19
19
  display_name: Object
20
20
  note:
21
21
  position: 3
22
22
 
23
23
  subject_type_00004:
24
24
  id: 4
25
- name: Place
25
+ name: place
26
26
  display_name: Place
27
27
  note:
28
28
  position: 4
@@ -4,10 +4,10 @@ module MasterModel
4
4
  base.send :include, InstanceMethods
5
5
  base.class_eval do
6
6
  acts_as_list
7
- validates_uniqueness_of :name, :case_sensitive => false
7
+ validates_uniqueness_of :name, case_sensitive: false
8
8
  validates_presence_of :name, :display_name
9
- before_validation :set_display_name, :on => :create
10
- normalize_attributes :name
9
+ before_validation :set_display_name, on: :create
10
+ stirp_attributes only: :name
11
11
  end
12
12
  end
13
13
 
@@ -1,3 +1,3 @@
1
1
  module EnjuSubject
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0.beta.1"
3
3
  end
data/lib/enju_subject.rb CHANGED
@@ -1,33 +1,4 @@
1
1
  require "enju_subject/engine"
2
- require "enju_subject/manifestation"
3
2
 
4
3
  module EnjuSubject
5
- def self.included(base)
6
- base.extend(ClassMethods)
7
- end
8
-
9
- module ClassMethods
10
- def enju_subject
11
- include EnjuSubject::InstanceMethods
12
- end
13
- end
14
-
15
- module InstanceMethods
16
- private
17
-
18
- def get_subject_heading_type
19
- @subject_heading_type = SubjectHeadingType.find(params[:subject_heading_type_id]) if params[:subject_heading_type_id]
20
- end
21
-
22
- def get_subject
23
- @subject = Subject.find(params[:subject_id]) if params[:subject_id]
24
- end
25
-
26
- def get_classification
27
- @classification = Classification.find(params[:classification_id]) if params[:classification_id]
28
- end
29
- end
30
4
  end
31
-
32
- ActionController::Base.send :include, EnjuSubject
33
- ActiveRecord::Base.send :include, EnjuSubject::EnjuManifestation
@@ -5,6 +5,11 @@ class EnjuSubject::SetupGenerator < Rails::Generators::Base
5
5
  directory("db/fixtures", "db/fixtures/enju_subject")
6
6
  rake("enju_subject_engine:install:migrations")
7
7
  inject_into_file 'app/controllers/application_controller.rb',
8
- " enju_subject\n", :after => "enju_library\n"
8
+ " include EnjuSubject::Controller\n", after: "EnjuLibrary::Controller\n"
9
+ append_to_file("config/initializers/enju_leaf.rb") do
10
+ <<"EOS"
11
+ Manifestation.include(EnjuSubject::EnjuManifestation)
12
+ EOS
13
+ end
9
14
  end
10
15
  end
@@ -11,3 +11,9 @@ classification_type_00002:
11
11
  id: 2
12
12
  note: ""
13
13
  position: 2
14
+ classification_type_00003:
15
+ name: ndc8
16
+ display_name: NDC8
17
+ id: 3
18
+ note: ""
19
+ position: 3
@@ -2,27 +2,27 @@
2
2
  subject_heading_type_00001:
3
3
  name: unknown
4
4
  display_name: unknown
5
- updated_at: 2008-03-03 00:44:49.850140 +09:00
6
5
  id: 1
7
6
  note: ""
8
- created_at: 2008-03-03 00:44:34.260739 +09:00
9
7
  position: 1
10
8
  subject_heading_type_00002:
11
9
  name: ndlsh
12
10
  display_name: NDLSH
13
- updated_at: 2008-03-03 00:44:49.850140 +09:00
14
11
  id: 2
15
12
  note: ""
16
- created_at: 2008-03-03 00:44:34.260739 +09:00
17
13
  position: 2
18
14
  subject_heading_type_00003:
19
15
  name: bsh
20
16
  display_name: BSH
21
- updated_at: 2008-03-03 00:44:58.685360 +09:00
22
17
  id: 3
23
18
  note: ""
24
- created_at: 2008-03-03 00:44:58.685360 +09:00
25
19
  position: 3
20
+ subject_heading_type_00004:
21
+ name: lcsh
22
+ display_name: LCSH
23
+ id: 4
24
+ note: ""
25
+ position: 4
26
26
 
27
27
  # == Schema Information
28
28
  #
@@ -6,7 +6,7 @@ desc "create initial records for enju_subject"
6
6
  namespace :enju_subject do
7
7
  task :setup => :environment do
8
8
  Dir.glob(Rails.root.to_s + '/db/fixtures/enju_subject/*.yml').each do |file|
9
- ActiveRecord::Fixtures.create_fixtures('db/fixtures/enju_subject', File.basename(file, '.*'))
9
+ ActiveRecord::FixtureSet.create_fixtures('db/fixtures/enju_subject', File.basename(file, '.*'))
10
10
  end
11
11
 
12
12
  puts 'initial fixture files loaded.'
@@ -19,7 +19,7 @@ describe ClassificationTypesController do
19
19
 
20
20
  it "assigns all classification_types as @classification_types" do
21
21
  get :index
22
- expect(assigns(:classification_types)).to eq(ClassificationType.all)
22
+ expect(assigns(:classification_types)).to eq(ClassificationType.order(:position))
23
23
  end
24
24
  end
25
25
 
@@ -28,7 +28,7 @@ describe ClassificationTypesController do
28
28
 
29
29
  it "assigns all classification_types as @classification_types" do
30
30
  get :index
31
- expect(assigns(:classification_types)).to eq(ClassificationType.all)
31
+ expect(assigns(:classification_types)).to eq(ClassificationType.order(:position))
32
32
  end
33
33
  end
34
34
 
@@ -37,14 +37,14 @@ describe ClassificationTypesController do
37
37
 
38
38
  it "assigns all classification_types as @classification_types" do
39
39
  get :index
40
- expect(assigns(:classification_types)).to eq(ClassificationType.all)
40
+ expect(assigns(:classification_types)).to eq(ClassificationType.order(:position))
41
41
  end
42
42
  end
43
43
 
44
44
  describe "When not logged in" do
45
45
  it "assigns all classification_types as @classification_types" do
46
46
  get :index
47
- expect(assigns(:classification_types)).to eq(ClassificationType.all)
47
+ expect(assigns(:classification_types)).to eq(ClassificationType.order(:position))
48
48
  end
49
49
  end
50
50
  end
@@ -105,7 +105,7 @@ describe ClassificationTypesController do
105
105
 
106
106
  it "should not assign the requested classification_type as @classification_type" do
107
107
  get :new
108
- expect(assigns(:classification_type)).not_to be_valid
108
+ expect(assigns(:classification_type)).to be_nil
109
109
  expect(response).to be_forbidden
110
110
  end
111
111
  end
@@ -115,7 +115,7 @@ describe ClassificationTypesController do
115
115
 
116
116
  it "should not assign the requested classification_type as @classification_type" do
117
117
  get :new
118
- expect(assigns(:classification_type)).not_to be_valid
118
+ expect(assigns(:classification_type)).to be_nil
119
119
  expect(response).to be_forbidden
120
120
  end
121
121
  end
@@ -123,7 +123,7 @@ describe ClassificationTypesController do
123
123
  describe "When not logged in" do
124
124
  it "should not assign the requested classification_type as @classification_type" do
125
125
  get :new
126
- expect(assigns(:classification_type)).not_to be_valid
126
+ expect(assigns(:classification_type)).to be_nil
127
127
  expect(response).to redirect_to(new_user_session_url)
128
128
  end
129
129
  end
@@ -209,7 +209,7 @@ describe ClassificationTypesController do
209
209
  describe "with valid params" do
210
210
  it "assigns a newly created classification_type as @classification_type" do
211
211
  post :create, :classification_type => @attrs
212
- expect(assigns(:classification_type)).to be_valid
212
+ expect(assigns(:classification_type)).to be_nil
213
213
  end
214
214
 
215
215
  it "should be forbidden" do
@@ -221,7 +221,7 @@ describe ClassificationTypesController do
221
221
  describe "with invalid params" do
222
222
  it "assigns a newly created but unsaved classification_type as @classification_type" do
223
223
  post :create, :classification_type => @invalid_attrs
224
- expect(assigns(:classification_type)).not_to be_valid
224
+ expect(assigns(:classification_type)).to be_nil
225
225
  end
226
226
 
227
227
  it "should be forbidden" do
@@ -237,7 +237,7 @@ describe ClassificationTypesController do
237
237
  describe "with valid params" do
238
238
  it "assigns a newly created classification_type as @classification_type" do
239
239
  post :create, :classification_type => @attrs
240
- expect(assigns(:classification_type)).to be_valid
240
+ expect(assigns(:classification_type)).to be_nil
241
241
  end
242
242
 
243
243
  it "should be forbidden" do
@@ -249,7 +249,7 @@ describe ClassificationTypesController do
249
249
  describe "with invalid params" do
250
250
  it "assigns a newly created but unsaved classification_type as @classification_type" do
251
251
  post :create, :classification_type => @invalid_attrs
252
- expect(assigns(:classification_type)).not_to be_valid
252
+ expect(assigns(:classification_type)).to be_nil
253
253
  end
254
254
 
255
255
  it "should be forbidden" do
@@ -263,7 +263,7 @@ describe ClassificationTypesController do
263
263
  describe "with valid params" do
264
264
  it "assigns a newly created classification_type as @classification_type" do
265
265
  post :create, :classification_type => @attrs
266
- expect(assigns(:classification_type)).to be_valid
266
+ expect(assigns(:classification_type)).to be_nil
267
267
  end
268
268
 
269
269
  it "should be forbidden" do
@@ -275,7 +275,7 @@ describe ClassificationTypesController do
275
275
  describe "with invalid params" do
276
276
  it "assigns a newly created but unsaved classification_type as @classification_type" do
277
277
  post :create, :classification_type => @invalid_attrs
278
- expect(assigns(:classification_type)).not_to be_valid
278
+ expect(assigns(:classification_type)).to be_nil
279
279
  end
280
280
 
281
281
  it "should be forbidden" do
@@ -108,7 +108,7 @@ describe ClassificationsController do
108
108
 
109
109
  it "assigns the requested classification as @classification" do
110
110
  get :new
111
- expect(assigns(:classification)).not_to be_valid
111
+ expect(assigns(:classification)).to be_nil
112
112
  end
113
113
  end
114
114
 
@@ -117,14 +117,14 @@ describe ClassificationsController do
117
117
 
118
118
  it "should assign the requested classification as @classification" do
119
119
  get :new
120
- expect(assigns(:classification)).not_to be_valid
120
+ expect(assigns(:classification)).to be_nil
121
121
  end
122
122
  end
123
123
 
124
124
  describe "When not logged in" do
125
125
  it "should not assign the requested classification as @classification" do
126
126
  get :new
127
- expect(assigns(:classification)).not_to be_valid
127
+ expect(assigns(:classification)).to be_nil
128
128
  response.should redirect_to(new_user_session_url)
129
129
  end
130
130
  end
@@ -210,7 +210,7 @@ describe ClassificationsController do
210
210
  describe "with valid params" do
211
211
  it "assigns a newly created classification as @classification" do
212
212
  post :create, :classification => @attrs
213
- expect(assigns(:classification)).to be_valid
213
+ expect(assigns(:classification)).to be_nil
214
214
  end
215
215
 
216
216
  it "should be forbidden" do
@@ -222,7 +222,7 @@ describe ClassificationsController do
222
222
  describe "with invalid params" do
223
223
  it "assigns a newly created but unsaved classification as @classification" do
224
224
  post :create, :classification => @invalid_attrs
225
- expect(assigns(:classification)).not_to be_valid
225
+ expect(assigns(:classification)).to be_nil
226
226
  end
227
227
 
228
228
  it "should be forbidden" do
@@ -238,7 +238,7 @@ describe ClassificationsController do
238
238
  describe "with valid params" do
239
239
  it "assigns a newly created classification as @classification" do
240
240
  post :create, :classification => @attrs
241
- expect(assigns(:classification)).to be_valid
241
+ expect(assigns(:classification)).to be_nil
242
242
  end
243
243
 
244
244
  it "should be forbidden" do
@@ -250,7 +250,7 @@ describe ClassificationsController do
250
250
  describe "with invalid params" do
251
251
  it "assigns a newly created but unsaved classification as @classification" do
252
252
  post :create, :classification => @invalid_attrs
253
- expect(assigns(:classification)).not_to be_valid
253
+ expect(assigns(:classification)).to be_nil
254
254
  end
255
255
 
256
256
  it "should be forbidden" do
@@ -264,7 +264,7 @@ describe ClassificationsController do
264
264
  describe "with valid params" do
265
265
  it "assigns a newly created classification as @classification" do
266
266
  post :create, :classification => @attrs
267
- expect(assigns(:classification)).to be_valid
267
+ expect(assigns(:classification)).to be_nil
268
268
  end
269
269
 
270
270
  it "should be forbidden" do
@@ -276,7 +276,7 @@ describe ClassificationsController do
276
276
  describe "with invalid params" do
277
277
  it "assigns a newly created but unsaved classification as @classification" do
278
278
  post :create, :classification => @invalid_attrs
279
- expect(assigns(:classification)).not_to be_valid
279
+ expect(assigns(:classification)).to be_nil
280
280
  end
281
281
 
282
282
  it "should be forbidden" do