enju_biblio 0.3.10.rc.1 → 0.3.10.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/item_custom_properties_controller.rb +8 -3
  3. data/app/controllers/manifestation_custom_properties_controller.rb +8 -3
  4. data/app/controllers/manifestations_controller.rb +1 -1
  5. data/app/models/item.rb +8 -4
  6. data/app/models/item_custom_property.rb +7 -7
  7. data/app/models/item_custom_value.rb +3 -3
  8. data/app/models/manifestation.rb +38 -12
  9. data/app/models/manifestation_custom_property.rb +7 -7
  10. data/app/models/manifestation_custom_value.rb +3 -3
  11. data/app/models/picture_file.rb +0 -2
  12. data/app/models/resource_export_file.rb +4 -2
  13. data/app/models/resource_import_file.rb +74 -56
  14. data/app/policies/item_custom_property_policy.rb +3 -3
  15. data/app/policies/manifestation_custom_property_policy.rb +3 -3
  16. data/app/views/item_custom_properties/edit.html.erb +12 -5
  17. data/app/views/item_custom_properties/index.html.erb +14 -7
  18. data/app/views/item_custom_properties/new.html.erb +11 -4
  19. data/app/views/item_custom_properties/show.html.erb +24 -17
  20. data/app/views/manifestation_custom_properties/edit.html.erb +12 -5
  21. data/app/views/manifestation_custom_properties/index.html.erb +14 -7
  22. data/app/views/manifestation_custom_properties/new.html.erb +11 -4
  23. data/app/views/manifestation_custom_properties/show.html.erb +24 -17
  24. data/app/views/manifestations/_export_detail.html.erb +1 -0
  25. data/app/views/manifestations/_export_list.html.erb +1 -0
  26. data/app/views/manifestations/_form.html.erb +5 -0
  27. data/app/views/manifestations/_show_detail_librarian.html.erb +6 -0
  28. data/app/views/manifestations/_show_detail_user.html.erb +8 -0
  29. data/app/views/manifestations/show.json.jbuilder +2 -0
  30. data/config/locales/translation_en.yml +2 -0
  31. data/config/locales/translation_ja.yml +2 -0
  32. data/db/migrate/20081027150907_create_picture_files.rb +0 -2
  33. data/lib/enju_biblio/version.rb +1 -1
  34. data/spec/controllers/item_custom_properties_controller_spec.rb +449 -0
  35. data/spec/controllers/manifestation_custom_properties_controller_spec.rb +449 -0
  36. data/spec/dummy/db/schema.rb +0 -2
  37. data/spec/fixtures/item_custom_properties.yml +7 -7
  38. data/spec/fixtures/manifestation_custom_properties.yml +7 -7
  39. data/spec/fixtures/picture_files.yml +0 -2
  40. data/spec/models/item_custom_property_spec.rb +7 -7
  41. data/spec/models/item_custom_value_spec.rb +3 -3
  42. data/spec/models/manifestation_custom_property_spec.rb +7 -7
  43. data/spec/models/manifestation_custom_value_spec.rb +3 -3
  44. data/spec/models/manifestation_spec.rb +1 -1
  45. data/spec/models/picture_file_spec.rb +0 -2
  46. data/spec/models/resource_export_file_spec.rb +49 -8
  47. data/spec/models/resource_import_file_spec.rb +5 -1
  48. data/spec/views/item_custom_properties/index.html.erb_spec.rb +1 -0
  49. data/spec/views/manifestation_custom_properties/index.html.erb_spec.rb +1 -0
  50. data/spec/views/manifestations/show.json.jbuilder_spec.rb +16 -0
  51. metadata +543 -536
@@ -8,14 +8,14 @@ class ItemCustomPropertyPolicy < ApplicationPolicy
8
8
  end
9
9
 
10
10
  def create?
11
- true if user.try(:has_role?, 'Librarian')
11
+ true if user.try(:has_role?, 'Administrator')
12
12
  end
13
13
 
14
14
  def update?
15
- true if user.try(:has_role?, 'Librarian')
15
+ true if user.try(:has_role?, 'Administrator')
16
16
  end
17
17
 
18
18
  def destroy?
19
- true if user.try(:has_role?, 'Librarian')
19
+ true if user.try(:has_role?, 'Administrator')
20
20
  end
21
21
  end
@@ -8,14 +8,14 @@ class ManifestationCustomPropertyPolicy < ApplicationPolicy
8
8
  end
9
9
 
10
10
  def create?
11
- true if user.try(:has_role?, 'Librarian')
11
+ true if user.try(:has_role?, 'Administrator')
12
12
  end
13
13
 
14
14
  def update?
15
- true if user.try(:has_role?, 'Librarian')
15
+ true if user.try(:has_role?, 'Administrator')
16
16
  end
17
17
 
18
18
  def destroy?
19
- true if user.try(:has_role?, 'Librarian')
19
+ true if user.try(:has_role?, 'Administrator')
20
20
  end
21
21
  end
@@ -1,6 +1,13 @@
1
- <h1><%= t('page.editing', model: t('activerecord.models.item_custom_property')) -%></h1>
1
+ <div id="content_detail" class="ui-corner-all ui-widget-content">
2
+ <h1 class="title"><%= t('page.editing', model: t('activerecord.models.item_custom_property')) -%></h1>
3
+ <div id="content_list">
4
+ <%= render 'form', item_custom_property: @item_custom_property %>
5
+ </div>
6
+ </div>
2
7
 
3
- <%= render 'form', item_custom_property: @item_custom_property %>
4
-
5
- <%= link_to t('page.show'), @item_custom_property %> |
6
- <%= link_to t('page.back'), item_custom_properties_path %>
8
+ <div id="submenu" class="ui-corner-all ui-widget-content">
9
+ <ul>
10
+ <li><%= link_to t('page.show'), @item_custom_property %></li>
11
+ <li><%= link_to t('page.back'), item_custom_properties_path %></li>
12
+ </ul>
13
+ </div>
@@ -1,5 +1,6 @@
1
- <div class="row">
2
- <div class="col-md-9">
1
+ <div id="content_detail" class="ui-corner-all ui-widget-content">
2
+ <h1 class="title"><%= t('page.listing', model: t('activerecord.models.item_custom_property')) -%></h1>
3
+ <div id="content_list">
3
4
  <p id="notice"><%= notice %></p>
4
5
 
5
6
  <h1><%= t('page.listing', model: t('activerecord.models.item_custom_property')) -%></h1>
@@ -7,6 +8,7 @@
7
8
  <table class='table table-striped index'>
8
9
  <thead>
9
10
  <tr>
11
+ <th id="position"></th>
10
12
  <th><%= t('activerecord.attributes.item_custom_property.name') %></th>
11
13
  <th><%= t('activerecord.attributes.item_custom_property.display_name') %></th>
12
14
  <th><%= t('activerecord.attributes.item_custom_property.note') %></th>
@@ -17,6 +19,11 @@
17
19
  <tbody>
18
20
  <% @item_custom_properties.each do |item_custom_property| %>
19
21
  <tr>
22
+ <td>
23
+ <%- if policy(item_custom_property).update? -%>
24
+ <%= move_position(item_custom_property) -%>
25
+ <%- end -%>
26
+ </td>
20
27
  <td><%= link_to item_custom_property.name, item_custom_property %></td>
21
28
  <td><%= item_custom_property.display_name.localize %></td>
22
29
  <td><%= item_custom_property.note %></td>
@@ -27,10 +34,10 @@
27
34
  </tbody>
28
35
  </table>
29
36
  </div>
37
+ </div>
30
38
 
31
- <div class="col">
32
- <div class="card card-body">
33
- <%= link_to t('page.new', model: t('activerecord.models.item_custom_property')), new_item_custom_property_path -%>
34
- </div>
35
- </div>
39
+ <div id="submenu" class="ui-corner-all ui-widget-content">
40
+ <ul>
41
+ <li><%= link_to t('page.new', model: t('activerecord.models.item_custom_property')), new_item_custom_property_path -%></li>
42
+ </ul>
36
43
  </div>
@@ -1,5 +1,12 @@
1
- <h1><%= t('page.new', model: t('activerecord.models.item_custom_property')) -%></h1>
1
+ <div id="content_detail" class="ui-corner-all ui-widget-content">
2
+ <h1 class="title"><%= t('page.new', model: t('activerecord.models.item_custom_property')) -%></h1>
3
+ <div id="content_list">
4
+ <%= render 'form', item_custom_property: @item_custom_property %>
5
+ </div>
6
+ </div>
2
7
 
3
- <%= render 'form', item_custom_property: @item_custom_property %>
4
-
5
- <%= link_to t('page.back'), item_custom_properties_path %>
8
+ <div id="submenu" class="ui-corner-all ui-widget-content">
9
+ <ul>
10
+ <li><%= link_to t('page.back'), item_custom_properties_path %></li>
11
+ </ul>
12
+ </div>
@@ -1,21 +1,28 @@
1
- <h1><%= t('page.showing', model: t('activerecord.models.item_custom_property')) -%></h1>
1
+ <div id="content_detail" class="ui-corner-all ui-widget-content">
2
+ <h1 class="title"><%= t('page.showing', model: t('activerecord.models.item_custom_property')) -%></h1>
3
+ <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
2
5
 
3
- <p id="notice"><%= notice %></p>
6
+ <p>
7
+ <strong><%= t('activerecord.attributes.item_custom_property.name') %>:</strong>
8
+ <%= @item_custom_property.name %>
9
+ </p>
4
10
 
5
- <p>
6
- <strong><%= t('activerecord.attributes.item_custom_property.name') %>:</strong>
7
- <%= @item_custom_property.name %>
8
- </p>
11
+ <p>
12
+ <strong><%= t('activerecord.attributes.item_custom_property.display_name') %>:</strong>
13
+ <%= @item_custom_property.display_name.localize %>
14
+ </p>
9
15
 
10
- <p>
11
- <strong><%= t('activerecord.attributes.item_custom_property.display_name') %>:</strong>
12
- <%= @item_custom_property.display_name.localize %>
13
- </p>
16
+ <p>
17
+ <strong><%= t('activerecord.attributes.item_custom_property.note') %>:</strong>
18
+ <%= @item_custom_property.note %>
19
+ </p>
20
+ </div>
21
+ </div>
14
22
 
15
- <p>
16
- <strong><%= t('activerecord.attributes.item_custom_property.note') %>:</strong>
17
- <%= @item_custom_property.note %>
18
- </p>
19
-
20
- <%= link_to t('page.edit'), edit_item_custom_property_path(@item_custom_property) %> |
21
- <%= link_to t('page.back'), item_custom_properties_path %>
23
+ <div id="submenu" class="ui-corner-all ui-widget-content">
24
+ <ul>
25
+ <li><%= link_to t('page.edit'), edit_item_custom_property_path(@item_custom_property) %></li>
26
+ <li><%= link_to t('page.back'), item_custom_properties_path %></li>
27
+ </ul>
28
+ </div>
@@ -1,6 +1,13 @@
1
- <h1><%= t('page.editing', model: t('activerecord.models.manifestation_custom_property')) -%></h1>
1
+ <div id="content_detail" class="ui-corner-all ui-widget-content">
2
+ <h1 class="title"><%= t('page.editing', model: t('activerecord.models.manifestation_custom_property')) -%></h1>
3
+ <div id="content_list">
4
+ <%= render 'form', manifestation_custom_property: @manifestation_custom_property %>
5
+ </div>
6
+ </div>
2
7
 
3
- <%= render 'form', manifestation_custom_property: @manifestation_custom_property %>
4
-
5
- <%= link_to t('page.show'), @manifestation_custom_property %> |
6
- <%= link_to t('page.back'), manifestation_custom_properties_path %>
8
+ <div id="submenu" class="ui-corner-all ui-widget-content">
9
+ <ul>
10
+ <li><%= link_to t('page.show'), @manifestation_custom_property %></li>
11
+ <li><%= link_to t('page.back'), manifestation_custom_properties_path %></li>
12
+ </ul>
13
+ </div>
@@ -1,5 +1,6 @@
1
- <div class="row">
2
- <div class="col-md-9">
1
+ <div id="content_detail" class="ui-corner-all ui-widget-content">
2
+ <h1 class="title"><%= t('page.listing', model: t('activerecord.models.manifestation_custom_property')) -%></h1>
3
+ <div id="content_list">
3
4
  <p id="notice"><%= notice %></p>
4
5
 
5
6
  <h1><%= t('page.listing', model: t('activerecord.models.manifestation_custom_property')) -%></h1>
@@ -7,6 +8,7 @@
7
8
  <table class='table table-striped index'>
8
9
  <thead>
9
10
  <tr>
11
+ <th id="position"></th>
10
12
  <th><%= t('activerecord.attributes.manifestation_custom_property.name') %></th>
11
13
  <th><%= t('activerecord.attributes.manifestation_custom_property.display_name') %></th>
12
14
  <th><%= t('activerecord.attributes.manifestation_custom_property.note') %></th>
@@ -17,6 +19,11 @@
17
19
  <tbody>
18
20
  <% @manifestation_custom_properties.each do |manifestation_custom_property| %>
19
21
  <tr>
22
+ <td>
23
+ <%- if policy(manifestation_custom_property).update? -%>
24
+ <%= move_position(manifestation_custom_property) -%>
25
+ <%- end -%>
26
+ </td>
20
27
  <td><%= link_to manifestation_custom_property.name, manifestation_custom_property %></td>
21
28
  <td><%= manifestation_custom_property.display_name.localize %></td>
22
29
  <td><%= manifestation_custom_property.note %></td>
@@ -27,10 +34,10 @@
27
34
  </tbody>
28
35
  </table>
29
36
  </div>
37
+ </div>
30
38
 
31
- <div class="col">
32
- <div class="card card-body">
33
- <%= link_to t('page.new', model: t('activerecord.models.manifestation_custom_property')), new_manifestation_custom_property_path -%>
34
- </div>
35
- </div>
39
+ <div id="submenu" class="ui-corner-all ui-widget-content">
40
+ <ul>
41
+ <li><%= link_to t('page.new', model: t('activerecord.models.manifestation_custom_property')), new_manifestation_custom_property_path -%></li>
42
+ </ul>
36
43
  </div>
@@ -1,5 +1,12 @@
1
- <h1><%= t('page.new', model: t('activerecord.models.manifestation_custom_property')) -%></h1>
1
+ <div id="content_detail" class="ui-corner-all ui-widget-content">
2
+ <h1 class="title"><%= t('page.new', model: t('activerecord.models.item_custom_property')) -%></h1>
3
+ <div id="content_list">
4
+ <%= render 'form', manifestation_custom_property: @manifestation_custom_property %>
5
+ </div>
6
+ </div>
2
7
 
3
- <%= render 'form', manifestation_custom_property: @manifestation_custom_property %>
4
-
5
- <%= link_to t('page.back'), manifestation_custom_properties_path %>
8
+ <div id="submenu" class="ui-corner-all ui-widget-content">
9
+ <ul>
10
+ <li><%= link_to t('page.back'), manifestation_custom_properties_path %></li>
11
+ </ul>
12
+ </div>
@@ -1,21 +1,28 @@
1
- <h1><%= t('page.showing', model: t('activerecord.models.manifestation_custom_property')) -%></h1>
1
+ <div id="content_detail" class="ui-corner-all ui-widget-content">
2
+ <h1 class="title"><%= t('page.showing', model: t('activerecord.models.manifestation_custom_property')) -%></h1>
3
+ <div id="content_list">
4
+ <p id="notice"><%= notice %></p>
2
5
 
3
- <p id="notice"><%= notice %></p>
6
+ <p>
7
+ <strong><%= t('activerecord.attributes.manifestation_custom_property.name') %>:</strong>
8
+ <%= @manifestation_custom_property.name %>
9
+ </p>
4
10
 
5
- <p>
6
- <strong><%= t('activerecord.attributes.manifestation_custom_property.name') %>:</strong>
7
- <%= @manifestation_custom_property.name %>
8
- </p>
11
+ <p>
12
+ <strong><%= t('activerecord.attributes.manifestation_custom_property.display_name') %>:</strong>
13
+ <%= @manifestation_custom_property.display_name.localize %>
14
+ </p>
9
15
 
10
- <p>
11
- <strong><%= t('activerecord.attributes.manifestation_custom_property.display_name') %>:</strong>
12
- <%= @manifestation_custom_property.display_name.localize %>
13
- </p>
16
+ <p>
17
+ <strong><%= t('activerecord.attributes.manifestation_custom_property.note') %>:</strong>
18
+ <%= @manifestation_custom_property.note %>
19
+ </p>
20
+ </div>
21
+ </div>
14
22
 
15
- <p>
16
- <strong><%= t('activerecord.attributes.manifestation_custom_property.note') %>:</strong>
17
- <%= @manifestation_custom_property.note %>
18
- </p>
19
-
20
- <%= link_to t('page.edit'), edit_manifestation_custom_property_path(@manifestation_custom_property) %> |
21
- <%= link_to t('page.back'), manifestation_custom_properties_path %>
23
+ <div id="submenu" class="ui-corner-all ui-widget-content">
24
+ <ul>
25
+ <li><%= link_to t('page.edit'), edit_manifestation_custom_property_path(@manifestation_custom_property) %></li>
26
+ <li><%= link_to t('page.back'), manifestation_custom_properties_path %></li>
27
+ </ul>
28
+ </div>
@@ -4,4 +4,5 @@
4
4
  <li><%= link_to 'RDF/XML', manifestation_url(@manifestation, format: :rdf) %></li>
5
5
  <li><%= link_to 'MODS', manifestation_url(@manifestation, format: :mods) %></li>
6
6
  <li><%= link_to 'TSV', manifestation_url(@manifestation, format: :txt) %></li>
7
+ <li><%= link_to 'JSON', manifestation_url(@manifestation, format: :json) %></li>
7
8
  </ul>
@@ -3,4 +3,5 @@
3
3
  <li><%= link_to 'RDF/XML', url_for(filtered_params.merge(format: :rdf, only_path: true)) %>
4
4
  <li><%= link_to 'MODS', url_for(filtered_params.merge(format: :mods, only_path: true)) %></li>
5
5
  <li><%= link_to 'TSV', url_for(filtered_params.merge(format: :txt, only_path: true)) %></li>
6
+ <li><%= link_to 'JSON', url_for(filtered_params.merge(format: :json, only_path: true)) %></li>
6
7
  </ul>
@@ -201,6 +201,11 @@
201
201
  <% end %>
202
202
 
203
203
  <div class="field">
204
+ <%= f.label :abstract -%><br />
205
+ <%= f.text_area :abstract, class: 'resource_textarea' -%>
206
+ </div>
207
+
208
+ <div class="form-group">
204
209
  <%= f.label :description -%><br />
205
210
  <%= f.text_area :description, class: 'resource_textarea' -%>
206
211
  </div>
@@ -95,6 +95,12 @@
95
95
  <td><%= t('page.updated_at') -%>:</td>
96
96
  <td><%=l manifestation.updated_at if manifestation.updated_at -%></td>
97
97
  </tr>
98
+ <tr>
99
+ <td><%= t('activerecord.attributes.manifestation.abstract') -%>:</td>
100
+ <td>
101
+ <%= raw simple_format(h(manifestation.abstract)) -%>
102
+ </td>
103
+ </tr>
98
104
  <tr>
99
105
  <td><%= t('activerecord.attributes.manifestation.description') -%>:</td>
100
106
  <td>
@@ -91,6 +91,14 @@
91
91
  <td><%= t('page.updated_at') -%>:</td>
92
92
  <td><%=l manifestation.updated_at if manifestation.updated_at -%></td>
93
93
  </tr>
94
+ <% if manifestation.abstract.present? %>
95
+ <tr>
96
+ <td><%= t('activerecord.attributes.manifestation.abstract') -%>:</td>
97
+ <td>
98
+ <%= raw simple_format(h(manifestation.abstract)) -%>
99
+ </td>
100
+ </tr>
101
+ <% end %>
94
102
  <% if manifestation.description.present? %>
95
103
  <tr>
96
104
  <td><%= t('activerecord.attributes.manifestation.description') -%>:</td>
@@ -0,0 +1,2 @@
1
+ json.partial!(@manifestation)
2
+
@@ -88,6 +88,7 @@ en:
88
88
  lccn: LCCN
89
89
  issn: ISSN
90
90
  subscription_master: Subscription master
91
+ abstract: Abstract
91
92
  description: Description
92
93
  creator_string: Creator
93
94
  contributor_string: Contributor
@@ -104,6 +105,7 @@ en:
104
105
  extent: Extent
105
106
  dimensions: Dimensions
106
107
  fulltext_content: Fulltext content
108
+ date_copyrighted: Date copyrighted
107
109
  manifestation/subjects:
108
110
  term: Subject
109
111
  manifestation/classifications:
@@ -88,6 +88,7 @@ ja:
88
88
  lccn: LCCN
89
89
  issn: ISSN
90
90
  subscription_master: 購読マスタ
91
+ abstract: 内容細目
91
92
  description: 説明
92
93
  creator_string: 著者
93
94
  contributor_string: 協力者・編者
@@ -104,6 +105,7 @@ ja:
104
105
  extent: ページ数
105
106
  dimensions: 大きさ
106
107
  fulltext_content: 全文あり
108
+ date_copyrighted: 著作権発行日
107
109
  manifestation/subjects:
108
110
  term: 件名
109
111
  manifestation/classifications:
@@ -3,9 +3,7 @@ class CreatePictureFiles < ActiveRecord::Migration[4.2]
3
3
  create_table :picture_files do |t|
4
4
  t.integer :picture_attachable_id
5
5
  t.string :picture_attachable_type
6
- t.string :content_type
7
6
  t.text :title
8
- t.string :thumbnail
9
7
  t.integer :position
10
8
 
11
9
  t.timestamps
@@ -1,3 +1,3 @@
1
1
  module EnjuBiblio
2
- VERSION = "0.3.10.rc.1".freeze
2
+ VERSION = "0.3.10.rc.2".freeze
3
3
  end
@@ -0,0 +1,449 @@
1
+ require 'rails_helper'
2
+ require 'sunspot/rails/spec_helper'
3
+
4
+ describe ItemCustomPropertiesController do
5
+ fixtures :all
6
+ disconnect_sunspot
7
+
8
+ def valid_attributes
9
+ @attrs = FactoryBot.attributes_for(:item_custom_property)
10
+ end
11
+
12
+ describe 'GET index' do
13
+ before(:each) do
14
+ FactoryBot.create(:item_custom_property)
15
+ end
16
+
17
+ describe 'When logged in as Administrator' do
18
+ login_fixture_admin
19
+
20
+ it 'assigns all item_custom_properties as @item_custom_properties' do
21
+ get :index
22
+ expect(assigns(:item_custom_properties)).to eq(ItemCustomProperty.order(:position))
23
+ end
24
+ end
25
+
26
+ describe 'When logged in as Librarian' do
27
+ login_fixture_librarian
28
+
29
+ it 'assigns all item_custom_properties as @item_custom_properties' do
30
+ get :index
31
+ expect(assigns(:item_custom_properties)).to eq(ItemCustomProperty.order(:position))
32
+ end
33
+ end
34
+
35
+ describe 'When logged in as User' do
36
+ login_fixture_user
37
+
38
+ it 'assigns all item_custom_properties as @item_custom_properties' do
39
+ get :index
40
+ expect(assigns(:item_custom_properties)).to eq nil
41
+ end
42
+ end
43
+
44
+ describe 'When not logged in' do
45
+ it 'assigns all item_custom_properties as @item_custom_properties' do
46
+ get :index
47
+ expect(assigns(:item_custom_properties)).to eq nil
48
+ end
49
+ end
50
+ end
51
+
52
+ describe 'GET show' do
53
+ describe 'When logged in as Administrator' do
54
+ login_fixture_admin
55
+
56
+ it 'assigns the requested item_custom_property as @item_custom_property' do
57
+ item_custom_property = FactoryBot.create(:item_custom_property)
58
+ get :show, params: { id: item_custom_property.id }
59
+ expect(assigns(:item_custom_property)).to eq(item_custom_property)
60
+ end
61
+ end
62
+
63
+ describe 'When logged in as Librarian' do
64
+ login_fixture_librarian
65
+
66
+ it 'assigns the requested item_custom_property as @item_custom_property' do
67
+ item_custom_property = FactoryBot.create(:item_custom_property)
68
+ get :show, params: { id: item_custom_property.id }
69
+ expect(assigns(:item_custom_property)).to eq(item_custom_property)
70
+ end
71
+ end
72
+
73
+ describe 'When logged in as User' do
74
+ login_fixture_user
75
+
76
+ it 'assigns the requested item_custom_property as @item_custom_property' do
77
+ item_custom_property = FactoryBot.create(:item_custom_property)
78
+ get :show, params: { id: item_custom_property.id }
79
+ expect(assigns(:item_custom_property)).to eq(item_custom_property)
80
+ end
81
+ end
82
+
83
+ describe 'When not logged in' do
84
+ it 'assigns the requested item_custom_property as @item_custom_property' do
85
+ item_custom_property = FactoryBot.create(:item_custom_property)
86
+ get :show, params: { id: item_custom_property.id }
87
+ expect(assigns(:item_custom_property)).to eq(item_custom_property)
88
+ end
89
+ end
90
+ end
91
+
92
+ describe 'GET new' do
93
+ describe 'When logged in as Administrator' do
94
+ login_fixture_admin
95
+
96
+ it 'assigns the requested item_custom_property as @item_custom_property' do
97
+ get :new
98
+ expect(assigns(:item_custom_property)).to be_a_new(ItemCustomProperty)
99
+ expect(response).to be_successful
100
+ end
101
+ end
102
+
103
+ describe 'When logged in as Librarian' do
104
+ login_fixture_librarian
105
+
106
+ it 'should not assign the requested item_custom_property as @item_custom_property' do
107
+ get :new
108
+ expect(assigns(:item_custom_property)).to be_nil
109
+ expect(response).to be_forbidden
110
+ end
111
+ end
112
+
113
+ describe 'When logged in as User' do
114
+ login_fixture_user
115
+
116
+ it 'should not assign the requested item_custom_property as @item_custom_property' do
117
+ get :new
118
+ expect(assigns(:item_custom_property)).to be_nil
119
+ expect(response).to be_forbidden
120
+ end
121
+ end
122
+
123
+ describe 'When not logged in' do
124
+ it 'should not assign the requested item_custom_property as @item_custom_property' do
125
+ get :new
126
+ expect(assigns(:item_custom_property)).to be_nil
127
+ expect(response).to redirect_to(new_user_session_url)
128
+ end
129
+ end
130
+ end
131
+
132
+ describe 'GET edit' do
133
+ describe 'When logged in as Administrator' do
134
+ login_fixture_admin
135
+
136
+ it 'assigns the requested item_custom_property as @item_custom_property' do
137
+ item_custom_property = FactoryBot.create(:item_custom_property)
138
+ get :edit, params: { id: item_custom_property.id }
139
+ expect(assigns(:item_custom_property)).to eq(item_custom_property)
140
+ end
141
+ end
142
+
143
+ describe 'When logged in as Librarian' do
144
+ login_fixture_librarian
145
+
146
+ it 'assigns the requested item_custom_property as @item_custom_property' do
147
+ item_custom_property = FactoryBot.create(:item_custom_property)
148
+ get :edit, params: { id: item_custom_property.id }
149
+ expect(assigns(:item_custom_property)).to eq(item_custom_property)
150
+ end
151
+ end
152
+
153
+ describe 'When logged in as User' do
154
+ login_fixture_user
155
+
156
+ it 'assigns the requested item_custom_property as @item_custom_property' do
157
+ item_custom_property = FactoryBot.create(:item_custom_property)
158
+ get :edit, params: { id: item_custom_property.id }
159
+ expect(response).to be_forbidden
160
+ end
161
+ end
162
+
163
+ describe 'When not logged in' do
164
+ it 'should not assign the requested item_custom_property as @item_custom_property' do
165
+ item_custom_property = FactoryBot.create(:item_custom_property)
166
+ get :edit, params: { id: item_custom_property.id }
167
+ expect(response).to redirect_to(new_user_session_url)
168
+ end
169
+ end
170
+ end
171
+
172
+ describe 'POST create' do
173
+ before(:each) do
174
+ @attrs = valid_attributes
175
+ @invalid_attrs = { name: '' }
176
+ end
177
+
178
+ describe 'When logged in as Administrator' do
179
+ login_fixture_admin
180
+
181
+ describe 'with valid params' do
182
+ it 'assigns a newly created item_custom_property as @item_custom_property' do
183
+ post :create, params: { item_custom_property: @attrs }
184
+ expect(assigns(:item_custom_property)).to be_valid
185
+ end
186
+
187
+ it 'redirects to the created item' do
188
+ post :create, params: { item_custom_property: @attrs }
189
+ expect(response).to redirect_to(assigns(:item_custom_property))
190
+ end
191
+ end
192
+
193
+ describe 'with invalid params' do
194
+ it 'assigns a newly created but unsaved item_custom_property as @item_custom_property' do
195
+ post :create, params: { item_custom_property: @invalid_attrs }
196
+ expect(assigns(:item_custom_property)).not_to be_valid
197
+ end
198
+
199
+ it "re-renders the 'new' template" do
200
+ post :create, params: { item_custom_property: @invalid_attrs }
201
+ expect(response).to render_template('new')
202
+ end
203
+ end
204
+ end
205
+
206
+ describe 'When logged in as Librarian' do
207
+ login_fixture_librarian
208
+
209
+ describe 'with valid params' do
210
+ it 'assigns a newly created item_custom_property as @item_custom_property' do
211
+ post :create, params: { item_custom_property: @attrs }
212
+ expect(assigns(:item_custom_property)).to be_nil
213
+ end
214
+
215
+ it 'redirects to the created item' do
216
+ post :create, params: { item_custom_property: @attrs }
217
+ expect(response).to be_forbidden
218
+ end
219
+ end
220
+
221
+ describe 'with invalid params' do
222
+ it 'assigns a newly created but unsaved item_custom_property as @item_custom_property' do
223
+ post :create, params: { item_custom_property: @invalid_attrs }
224
+ expect(assigns(:item_custom_property)).to be_nil
225
+ end
226
+
227
+ it "re-renders the 'new' template" do
228
+ post :create, params: { item_custom_property: @invalid_attrs }
229
+ expect(response).to be_forbidden
230
+ end
231
+ end
232
+ end
233
+
234
+ describe 'When logged in as User' do
235
+ login_fixture_user
236
+
237
+ describe 'with valid params' do
238
+ it 'assigns a newly created item_custom_property as @item_custom_property' do
239
+ post :create, params: { item_custom_property: @attrs }
240
+ expect(assigns(:item_custom_property)).to be_nil
241
+ end
242
+
243
+ it 'should be forbidden' do
244
+ post :create, params: { item_custom_property: @attrs }
245
+ expect(response).to be_forbidden
246
+ end
247
+ end
248
+
249
+ describe 'with invalid params' do
250
+ it 'assigns a newly created but unsaved item_custom_property as @item_custom_property' do
251
+ post :create, params: { item_custom_property: @invalid_attrs }
252
+ expect(assigns(:item_custom_property)).to be_nil
253
+ end
254
+
255
+ it 'should be forbidden' do
256
+ post :create, params: { item_custom_property: @invalid_attrs }
257
+ expect(response).to be_forbidden
258
+ end
259
+ end
260
+ end
261
+
262
+ describe 'When not logged in' do
263
+ describe 'with valid params' do
264
+ it 'assigns a newly created item_custom_property as @item_custom_property' do
265
+ post :create, params: { item_custom_property: @attrs }
266
+ expect(assigns(:item_custom_property)).to be_nil
267
+ end
268
+
269
+ it 'should be forbidden' do
270
+ post :create, params: { item_custom_property: @attrs }
271
+ expect(response).to redirect_to(new_user_session_url)
272
+ end
273
+ end
274
+
275
+ describe 'with invalid params' do
276
+ it 'assigns a newly created but unsaved item_custom_property as @item_custom_property' do
277
+ post :create, params: { item_custom_property: @invalid_attrs }
278
+ expect(assigns(:item_custom_property)).to be_nil
279
+ end
280
+
281
+ it 'should be forbidden' do
282
+ post :create, params: { item_custom_property: @invalid_attrs }
283
+ expect(response).to redirect_to(new_user_session_url)
284
+ end
285
+ end
286
+ end
287
+ end
288
+
289
+ describe 'PUT update' do
290
+ before(:each) do
291
+ @item_custom_property = FactoryBot.create(:item_custom_property)
292
+ @attrs = valid_attributes
293
+ @invalid_attrs = { name: '' }
294
+ end
295
+
296
+ describe 'When logged in as Administrator' do
297
+ login_fixture_admin
298
+
299
+ describe 'with valid params' do
300
+ it 'updates the requested item_custom_property' do
301
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @attrs }
302
+ end
303
+
304
+ it 'assigns the requested item_custom_property as @item_custom_property' do
305
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @attrs }
306
+ expect(assigns(:item_custom_property)).to eq(@item_custom_property)
307
+ expect(response).to redirect_to(@item_custom_property)
308
+ end
309
+ end
310
+
311
+ describe 'with invalid params' do
312
+ it 'assigns the requested item_custom_property as @item_custom_property' do
313
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @invalid_attrs }
314
+ expect(response).to render_template('edit')
315
+ end
316
+ end
317
+
318
+ it 'moves its position when specified' do
319
+ item_custom_property = ItemCustomProperty.create! valid_attributes
320
+ position = item_custom_property.position
321
+ put :update, params: { id: item_custom_property.id, move: 'higher' }
322
+ expect(response).to redirect_to item_custom_properties_url
323
+ assigns(:item_custom_property).reload.position.should eq position - 1
324
+ end
325
+ end
326
+
327
+ describe 'When logged in as Librarian' do
328
+ login_fixture_librarian
329
+
330
+ describe 'with valid params' do
331
+ it 'updates the requested item_custom_property' do
332
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @attrs }
333
+ end
334
+
335
+ it 'assigns the requested item_custom_property as @item_custom_property' do
336
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @attrs }
337
+ expect(assigns(:item_custom_property)).to eq @item_custom_property
338
+ expect(response).to be_forbidden
339
+ end
340
+ end
341
+
342
+ describe 'with invalid params' do
343
+ it 'assigns the requested item_custom_property as @item_custom_property' do
344
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @invalid_attrs }
345
+ expect(response).to be_forbidden
346
+ end
347
+ end
348
+ end
349
+
350
+ describe 'When logged in as User' do
351
+ login_fixture_user
352
+
353
+ describe 'with valid params' do
354
+ it 'updates the requested item_custom_property' do
355
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @attrs }
356
+ end
357
+
358
+ it 'assigns the requested item_custom_property as @item_custom_property' do
359
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @attrs }
360
+ expect(assigns(:item_custom_property)).to eq(@item_custom_property)
361
+ expect(response).to be_forbidden
362
+ end
363
+ end
364
+
365
+ describe 'with invalid params' do
366
+ it 'assigns the requested item_custom_property as @item_custom_property' do
367
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @invalid_attrs }
368
+ expect(response).to be_forbidden
369
+ end
370
+ end
371
+ end
372
+
373
+ describe 'When not logged in' do
374
+ describe 'with valid params' do
375
+ it 'updates the requested item_custom_property' do
376
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @attrs }
377
+ end
378
+
379
+ it 'should be forbidden' do
380
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @attrs }
381
+ expect(response).to redirect_to(new_user_session_url)
382
+ end
383
+ end
384
+
385
+ describe 'with invalid params' do
386
+ it 'assigns the requested item_custom_property as @item_custom_property' do
387
+ put :update, params: { id: @item_custom_property.id, item_custom_property: @invalid_attrs }
388
+ expect(response).to redirect_to(new_user_session_url)
389
+ end
390
+ end
391
+ end
392
+ end
393
+
394
+ describe 'DELETE destroy' do
395
+ before(:each) do
396
+ @item_custom_property = FactoryBot.create(:item_custom_property)
397
+ end
398
+
399
+ describe 'When logged in as Administrator' do
400
+ login_fixture_admin
401
+
402
+ it 'destroys the requested item_custom_property' do
403
+ delete :destroy, params: { id: @item_custom_property.id }
404
+ end
405
+
406
+ it 'redirects to the item_custom_properties list' do
407
+ delete :destroy, params: { id: @item_custom_property.id }
408
+ expect(response).to redirect_to(item_custom_properties_url)
409
+ end
410
+ end
411
+
412
+ describe 'When logged in as Librarian' do
413
+ login_fixture_librarian
414
+
415
+ it 'destroys the requested item_custom_property' do
416
+ delete :destroy, params: { id: @item_custom_property.id }
417
+ end
418
+
419
+ it 'should be forbidden' do
420
+ delete :destroy, params: { id: @item_custom_property.id }
421
+ expect(response).to be_forbidden
422
+ end
423
+ end
424
+
425
+ describe 'When logged in as User' do
426
+ login_fixture_user
427
+
428
+ it 'destroys the requested item_custom_property' do
429
+ delete :destroy, params: { id: @item_custom_property.id }
430
+ end
431
+
432
+ it 'should be forbidden' do
433
+ delete :destroy, params: { id: @item_custom_property.id }
434
+ expect(response).to be_forbidden
435
+ end
436
+ end
437
+
438
+ describe 'When not logged in' do
439
+ it 'destroys the requested item_custom_property' do
440
+ delete :destroy, params: { id: @item_custom_property.id }
441
+ end
442
+
443
+ it 'should be forbidden' do
444
+ delete :destroy, params: { id: @item_custom_property.id }
445
+ expect(response).to redirect_to(new_user_session_url)
446
+ end
447
+ end
448
+ end
449
+ end