enju_biblio 0.4.0.beta.2 → 0.4.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/items_controller.rb +5 -1
  3. data/app/controllers/manifestations_controller.rb +12 -6
  4. data/app/mailers/agent_import_mailer.rb +2 -2
  5. data/app/mailers/resource_export_mailer.rb +2 -2
  6. data/app/mailers/resource_import_mailer.rb +2 -2
  7. data/app/models/agent.rb +3 -4
  8. data/app/models/agent_import_file.rb +1 -8
  9. data/app/models/custom_property.rb +17 -0
  10. data/app/models/import_request.rb +0 -9
  11. data/app/models/isbn_record.rb +1 -1
  12. data/app/models/issn_record.rb +1 -1
  13. data/app/models/item.rb +49 -2
  14. data/app/models/manifestation.rb +109 -247
  15. data/app/models/resource_export_file.rb +3 -16
  16. data/app/models/resource_export_file_state_machine.rb +1 -1
  17. data/app/models/resource_import_file.rb +1 -9
  18. data/app/views/items/_custom_property_fields.html.erb +7 -0
  19. data/app/views/items/_form.html.erb +18 -6
  20. data/app/views/items/show.html.erb +8 -1
  21. data/app/views/layouts/items.html.erb +1 -1
  22. data/app/views/layouts/manifestations.html.erb +1 -1
  23. data/app/views/manifestations/_custom_property_fields.html.erb +7 -0
  24. data/app/views/manifestations/_form.html.erb +10 -0
  25. data/app/views/manifestations/_manifestation.txt.erb +1 -1
  26. data/app/views/manifestations/_paginate_id_link.html.erb +1 -1
  27. data/app/views/manifestations/_show_detail_librarian.html.erb +9 -1
  28. data/app/views/manifestations/_show_detail_user.html.erb +1 -1
  29. data/app/views/manifestations/index.txt.ruby +7 -0
  30. data/app/views/manifestations/show.txt.ruby +5 -0
  31. data/app/views/resource_import_files/_results.html.erb +6 -0
  32. data/app/views/resource_import_results/index.html.erb +0 -11
  33. data/app/views/series_statements/_form.html.erb +6 -8
  34. data/app/views/series_statements/show.html.erb +12 -0
  35. data/config/locales/translation_en.yml +12 -1
  36. data/config/locales/translation_ja.yml +14 -3
  37. data/db/migrate/001_create_agents.rb +0 -1
  38. data/db/migrate/005_create_manifestations.rb +0 -1
  39. data/db/migrate/006_create_items.rb +0 -1
  40. data/db/migrate/20191219122214_create_custom_properties.rb +12 -0
  41. data/lib/enju_biblio/version.rb +1 -1
  42. data/lib/generators/enju_biblio/setup/setup_generator.rb +2 -0
  43. data/spec/controllers/items_controller_spec.rb +25 -0
  44. data/spec/controllers/manifestations_controller_spec.rb +52 -0
  45. data/spec/dummy/app/controllers/application_controller.rb +0 -1
  46. data/spec/dummy/app/models/user.rb +0 -2
  47. data/spec/dummy/config/environments/development.rb +11 -24
  48. data/spec/dummy/config/environments/production.rb +16 -28
  49. data/spec/dummy/config/environments/test.rb +6 -6
  50. data/spec/dummy/config/initializers/assets.rb +1 -1
  51. data/spec/dummy/db/migrate/059_create_libraries.rb +1 -2
  52. data/spec/dummy/db/migrate/069_create_shelves.rb +1 -2
  53. data/spec/dummy/db/migrate/077_create_user_groups.rb +1 -2
  54. data/spec/dummy/db/migrate/080_create_library_groups.rb +1 -1
  55. data/spec/dummy/db/migrate/120_create_baskets.rb +1 -1
  56. data/spec/dummy/db/migrate/124_create_bookstores.rb +1 -2
  57. data/spec/dummy/db/migrate/130_create_request_status_types.rb +1 -1
  58. data/spec/dummy/db/migrate/131_create_request_types.rb +1 -1
  59. data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +1 -2
  60. data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +1 -1
  61. data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +1 -1
  62. data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +1 -1
  63. data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +1 -1
  64. data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +1 -1
  65. data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +1 -1
  66. data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +1 -1
  67. data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +1 -1
  68. data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +1 -1
  69. data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +1 -1
  70. data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +1 -1
  71. data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +1 -1
  72. data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +1 -1
  73. data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +2 -6
  74. data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +1 -1
  75. data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +1 -1
  76. data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +2 -6
  77. data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +1 -1
  78. data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +1 -1
  79. data/spec/dummy/db/migrate/20140821151023_create_colors.rb +1 -1
  80. data/spec/dummy/db/migrate/20150221063719_add_settings_to_library_group.rb +1 -1
  81. data/spec/dummy/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +1 -1
  82. data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +1 -1
  83. data/spec/dummy/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +1 -1
  84. data/spec/dummy/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +1 -1
  85. data/spec/dummy/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +1 -1
  86. data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +1 -1
  87. data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +1 -1
  88. data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +1 -1
  89. data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +1 -1
  90. data/spec/dummy/db/migrate/20170305064014_add_csv_charset_conversion_to_library_group.rb +1 -1
  91. data/spec/dummy/db/migrate/20171014084528_add_header_logo_to_library_group.rb +1 -1
  92. data/spec/dummy/db/migrate/20171126133835_rename_login_banner_to_old_login_banner.rb +1 -1
  93. data/spec/dummy/db/migrate/20171126135238_add_foreign_key_to_library_group_id_on_library.rb +1 -1
  94. data/spec/dummy/db/migrate/20180102162311_add_header_logo_meta_to_library_group.rb +1 -1
  95. data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +1 -1
  96. data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +1 -1
  97. data/spec/dummy/db/migrate/20191216131755_add_email_to_library_group.rb +6 -0
  98. data/spec/dummy/db/schema.rb +96 -91
  99. data/spec/dummy/db/test.sqlite3 +0 -0
  100. data/spec/dummy/public/500.html +1 -0
  101. data/spec/factories/custom_property.rb +18 -0
  102. data/spec/factories/series_statement.rb +4 -3
  103. data/spec/fixtures/agents.yml +0 -1
  104. data/spec/fixtures/bookstores.yml +0 -8
  105. data/spec/fixtures/budget_types.yml +10 -9
  106. data/spec/fixtures/events.yml +0 -9
  107. data/spec/fixtures/items.yml +10 -11
  108. data/spec/fixtures/library_groups.yml +6 -11
  109. data/spec/fixtures/manifestations.yml +0 -1
  110. data/spec/models/agent_spec.rb +0 -1
  111. data/spec/models/custom_property_spec.rb +18 -0
  112. data/spec/models/item_spec.rb +0 -1
  113. data/spec/models/manifestation_spec.rb +32 -8
  114. data/spec/rails_helper.rb +3 -3
  115. data/spec/system/custom_properties_spec.rb +84 -0
  116. data/spec/system/items_spec.rb +60 -0
  117. data/spec/system/series_statements_spec.rb +16 -0
  118. data/spec/views/manifestations/index.json.jbuilder_spec.rb +18 -0
  119. data/spec/views/manifestations/{index.txt.erb_spec.rb → index.txt.ruby_spec.rb} +1 -1
  120. data/spec/views/manifestations/{show.txt.erb_spec.rb → show.txt.ruby_spec.rb} +1 -1
  121. metadata +56 -58
  122. data/app/views/manifestations/index.txt.erb +0 -1
  123. data/app/views/manifestations/show.txt.erb +0 -1
  124. data/spec/dummy/db/migrate/20180709023037_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +0 -20
  125. data/spec/dummy/db/migrate/20180709023039_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +0 -15
Binary file
@@ -20,6 +20,7 @@
20
20
  <!-- This file lives in public/500.html -->
21
21
  <div class="dialog">
22
22
  <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
23
24
  </div>
24
25
  </body>
25
26
  </html>
@@ -0,0 +1,18 @@
1
+ FactoryBot.define do
2
+ factory :custom_property do
3
+ sequence(:label){|n| "custom property #{n}"}
4
+ sequence(:value){|n| "カスタム項目 #{n}"}
5
+ end
6
+
7
+ factory :manifestation_custom_property, class: CustomProperty do
8
+ association :resource, factory: :manifestation
9
+ sequence(:label){|n| "custom property #{n}"}
10
+ sequence(:value){|n| "カスタム項目 #{n}"}
11
+ end
12
+
13
+ factory :item_custom_property, class: CustomProperty do
14
+ association :resource, factory: :item
15
+ sequence(:label){|n| "custom property #{n}"}
16
+ sequence(:value){|n| "カスタム項目 #{n}"}
17
+ end
18
+ end
@@ -2,9 +2,10 @@ FactoryBot.define do
2
2
  factory :series_statement do |f|
3
3
  f.sequence(:original_title){|n| "series_statement_#{n}"}
4
4
  end
5
- factory :series_statement_serial, class: SeriesStatement do |f|
6
- f.sequence(:original_title){|n| "series_statement_serial_#{n}" }
5
+ factory :series_statement_serial, class: SeriesStatement do
6
+ sequence(:original_title){|n| "series_statement_serial_#{n}" }
7
+ sequence(:creator_string){|n| "シリーズの著者 #{n}" }
7
8
  #f.root_manifestation_id{FactoryBot.create(:manifestation_serial).id}
8
- f.series_master{true}
9
+ series_master{true}
9
10
  end
10
11
  end
@@ -290,7 +290,6 @@ agent_00202:
290
290
  # full_name_alternative :text
291
291
  # created_at :datetime
292
292
  # updated_at :datetime
293
- # deleted_at :datetime
294
293
  # zip_code_1 :string
295
294
  # zip_code_2 :string
296
295
  # address_1 :text
@@ -3,7 +3,6 @@ bookstore_00001:
3
3
  name: unknown
4
4
  fax_number:
5
5
  updated_at: 2008-02-10 11:14:57.605329 +09:00
6
- deleted_at:
7
6
  telephone_number:
8
7
  id: 1
9
8
  note: ""
@@ -16,7 +15,6 @@ bookstore_00002:
16
15
 
17
16
  fax_number: ""
18
17
  updated_at: 2008-02-10 12:15:14.840711 +09:00
19
- deleted_at:
20
18
  telephone_number: ""
21
19
  id: 2
22
20
  note: ""
@@ -29,7 +27,6 @@ bookstore_00003:
29
27
 
30
28
  fax_number: ""
31
29
  updated_at: 2008-02-10 12:15:33.555463 +09:00
32
- deleted_at:
33
30
  telephone_number: ""
34
31
  id: 3
35
32
  note: ""
@@ -42,7 +39,6 @@ bookstore_00004:
42
39
 
43
40
  fax_number: ""
44
41
  updated_at: 2008-02-10 12:16:07.726445 +09:00
45
- deleted_at:
46
42
  telephone_number: ""
47
43
  id: 4
48
44
  note: ""
@@ -55,7 +51,6 @@ bookstore_00005:
55
51
 
56
52
  fax_number: ""
57
53
  updated_at: 2008-02-10 12:16:17.990285 +09:00
58
- deleted_at:
59
54
  telephone_number: ""
60
55
  id: 5
61
56
  note: ""
@@ -68,7 +63,6 @@ bookstore_00006:
68
63
 
69
64
  fax_number: ""
70
65
  updated_at: 2008-02-10 12:16:25.906073 +09:00
71
- deleted_at:
72
66
  telephone_number: ""
73
67
  id: 6
74
68
  note: ""
@@ -79,7 +73,6 @@ bookstore_00007:
79
73
  name: Example store
80
74
  fax_number: ""
81
75
  updated_at: 2008-02-10 12:16:25.906073 +09:00
82
- deleted_at:
83
76
  telephone_number: ""
84
77
  id: 7
85
78
  note: ""
@@ -100,7 +93,6 @@ bookstore_00007:
100
93
  # fax_number :string(255)
101
94
  # url :string(255)
102
95
  # position :integer
103
- # deleted_at :datetime
104
96
  # created_at :datetime
105
97
  # updated_at :datetime
106
98
  #
@@ -2,14 +2,14 @@
2
2
 
3
3
  public_fund:
4
4
  name: Public fund
5
- display_name: Public fund
5
+ display_name_translations: {"en": "Public fund", "ja": "公的資金"}
6
6
  note:
7
7
  position: 1
8
8
  id: 1
9
9
 
10
10
  donation:
11
11
  name: Donation
12
- display_name: Donation
12
+ display_name_translations: {"en": "Donation", "ja": "寄贈"}
13
13
  note:
14
14
  position: 2
15
15
  id: 2
@@ -18,12 +18,13 @@ donation:
18
18
  #
19
19
  # Table name: budget_types
20
20
  #
21
- # id :integer not null, primary key
22
- # name :string(255)
23
- # display_name :text
24
- # note :text
25
- # position :integer
26
- # created_at :datetime
27
- # updated_at :datetime
21
+ # id :bigint not null, primary key
22
+ # name :string
23
+ # display_name :text
24
+ # note :text
25
+ # position :integer
26
+ # created_at :datetime not null
27
+ # updated_at :datetime not null
28
+ # display_name_translations :jsonb not null
28
29
  #
29
30
 
@@ -5,7 +5,6 @@ event_00001:
5
5
  end_at: 2008-01-14 02:54:00 +09:00
6
6
  name: 仕事始め
7
7
  display_name: 仕事始め
8
- deleted_at:
9
8
  start_at: 2008-01-13 02:54:00 +09:00
10
9
  id: 1
11
10
  note: なんとかかんとか
@@ -17,7 +16,6 @@ event_00002:
17
16
  end_at: 2008-01-14 02:54:00 +09:00
18
17
  name: テスト
19
18
  display_name: テスト
20
- deleted_at:
21
19
  start_at: 2008-01-13 02:54:00 +09:00
22
20
  id: 2
23
21
  note: テスト用のイベントです。
@@ -29,7 +27,6 @@ event_00003:
29
27
  end_at: 2008-02-05 00:00:00 +09:00
30
28
  name: ミーティング
31
29
  display_name: ミーティング
32
- deleted_at:
33
30
  start_at: 2008-01-13 00:00:00 +09:00
34
31
  id: 3
35
32
  note: ""
@@ -41,7 +38,6 @@ event_00004:
41
38
  end_at: 2008-02-06 00:00:00 +09:00
42
39
  name: テスト
43
40
  display_name: テスト
44
- deleted_at:
45
41
  start_at: 2008-02-05 00:00:00 +09:00
46
42
  id: 4
47
43
  note: なんとかかんとか
@@ -53,7 +49,6 @@ event_00005:
53
49
  end_at: 2008-02-08 00:00:00 +09:00
54
50
  name: test
55
51
  display_name: test
56
- deleted_at:
57
52
  start_at: 2008-02-05 00:00:00 +09:00
58
53
  id: 5
59
54
  note: ""
@@ -65,7 +60,6 @@ event_00006:
65
60
  end_at: 2008-02-08 00:00:00 +09:00
66
61
  name: なんとかかんとか
67
62
  display_name: なんとかかんとか
68
- deleted_at:
69
63
  start_at: 2008-02-05 00:00:00 +09:00
70
64
  id: 6
71
65
  note: ""
@@ -77,7 +71,6 @@ event_00007:
77
71
  end_at: 2008-02-08 00:00:00 +09:00
78
72
  name: test
79
73
  display_name: test
80
- deleted_at:
81
74
  start_at: 2008-02-05 00:00:00 +09:00
82
75
  id: 7
83
76
  note: test
@@ -89,7 +82,6 @@ event_00008:
89
82
  end_at: 2008-02-05 15:00:00 +09:00
90
83
  name: test
91
84
  display_name: test
92
- deleted_at:
93
85
  start_at: 2008-02-05 15:00:00 +09:00
94
86
  id: 8
95
87
  note: test
@@ -108,7 +100,6 @@ event_00008:
108
100
  # start_at :datetime
109
101
  # end_at :datetime
110
102
  # all_day :boolean default(FALSE), not null
111
- # deleted_at :datetime
112
103
  # created_at :datetime
113
104
  # updated_at :datetime
114
105
  # display_name :text
@@ -231,7 +231,7 @@ item_00021:
231
231
  include_supplements: false
232
232
  created_at: 2007-08-24 23:46:20.484813 +09:00
233
233
  item_00022:
234
- updated_at: 2007-08-24 23:46:20.484813 +09:00
234
+ updated_at: 2007-08-24 23:46:21.484813 +09:00
235
235
  item_identifier: '00022'
236
236
  circulation_status_id: 2
237
237
  checkout_type_id: 3
@@ -240,9 +240,9 @@ item_00022:
240
240
  manifestation_id: 11
241
241
  id: 22
242
242
  include_supplements: false
243
- created_at: 2007-08-24 23:46:20.484813 +09:00
243
+ created_at: 2007-08-24 23:46:21.484813 +09:00
244
244
  item_00023:
245
- updated_at: 2007-08-24 23:46:20.484813 +09:00
245
+ updated_at: 2007-08-24 23:46:22.484813 +09:00
246
246
  item_identifier: '00023'
247
247
  circulation_status_id: 16
248
248
  checkout_type_id: 3
@@ -251,9 +251,9 @@ item_00023:
251
251
  manifestation_id: 11
252
252
  id: 23
253
253
  include_supplements: false
254
- created_at: 2007-08-24 23:46:20.484813 +09:00
254
+ created_at: 2007-08-24 23:46:22.484813 +09:00
255
255
  item_00024:
256
- updated_at: 2007-08-24 23:46:08.607081 +09:00
256
+ updated_at: 2007-08-24 23:46:23.607081 +09:00
257
257
  item_identifier: '00024'
258
258
  circulation_status_id: 2
259
259
  checkout_type_id: 1
@@ -262,10 +262,10 @@ item_00024:
262
262
  manifestation_id: 102
263
263
  id: 24
264
264
  include_supplements: false
265
- created_at: 2007-08-24 23:46:08.607081 +09:00
266
- acquired_at: 2015-08-25 23:46:08.607081 +09:00
265
+ created_at: 2007-08-24 23:23:08.607081 +09:00
266
+ acquired_at: 2015-08-25 23:23:08.607081 +09:00
267
267
  item_00025:
268
- updated_at: 2007-08-24 23:46:08.607081 +09:00
268
+ updated_at: 2007-08-24 23:46:24.607081 +09:00
269
269
  item_identifier: '00025'
270
270
  circulation_status_id: 2
271
271
  checkout_type_id: 1
@@ -274,8 +274,8 @@ item_00025:
274
274
  manifestation_id: 102
275
275
  id: 25
276
276
  include_supplements: false
277
- created_at: 2007-08-24 23:46:08.607081 +09:00
278
- acquired_at: 2015-09-25 23:46:08.607081 +09:00
277
+ created_at: 2007-08-24 23:46:24.607081 +09:00
278
+ acquired_at: 2015-09-25 23:46:24.607081 +09:00
279
279
 
280
280
  # == Schema Information
281
281
  #
@@ -286,7 +286,6 @@ item_00025:
286
286
  # item_identifier :string
287
287
  # created_at :datetime
288
288
  # updated_at :datetime
289
- # deleted_at :datetime
290
289
  # shelf_id :integer default(1), not null
291
290
  # include_supplements :boolean default(FALSE), not null
292
291
  # note :text
@@ -15,25 +15,25 @@ one:
15
15
  "ja":"[Next-L Enju Leaf __VERSION__](https://github.com/next-l/enju_leaf), オープンソース統合図書館システム | [このシステムについて](/page/about) | [不具合を報告する](https://github.com/next-l/enju_leaf/issues) | [マニュアル](https://next-l.github.io/manual/1.3/)"}
16
16
  admin_networks: "0.0.0.0/0\r\n\
17
17
  ::/0"
18
- user_id: 1
18
+ email: library@example.jp
19
19
  pub_year_facet_range_interval: 10
20
20
 
21
21
  # == Schema Information
22
22
  #
23
23
  # Table name: library_groups
24
24
  #
25
- # id :integer not null, primary key
25
+ # id :bigint not null, primary key
26
26
  # name :string not null
27
- # display_name :text
28
27
  # short_name :string not null
29
28
  # my_networks :text
30
29
  # old_login_banner :text
31
30
  # note :text
32
31
  # country_id :integer
33
32
  # position :integer
34
- # created_at :datetime
35
- # updated_at :datetime
33
+ # created_at :datetime not null
34
+ # updated_at :datetime not null
36
35
  # admin_networks :text
36
+ # allow_bookmark_external_url :boolean default(FALSE), not null
37
37
  # url :string default("http://localhost:3000/")
38
38
  # settings :text
39
39
  # html_snippet :text
@@ -42,14 +42,9 @@ one:
42
42
  # family_name_first :boolean default(TRUE)
43
43
  # screenshot_generator :string
44
44
  # pub_year_facet_range_interval :integer default(10)
45
- # user_id :integer
46
45
  # csv_charset_conversion :boolean default(FALSE), not null
47
- # header_logo_file_name :string
48
- # header_logo_content_type :string
49
- # header_logo_file_size :bigint
50
- # header_logo_updated_at :datetime
51
- # header_logo_meta :text
52
46
  # display_name_translations :jsonb not null
53
47
  # login_banner_translations :jsonb not null
54
48
  # footer_banner_translations :jsonb not null
49
+ # email :string
55
50
  #
@@ -1841,7 +1841,6 @@ manifestation_00217:
1841
1841
  # date_copyrighted :datetime
1842
1842
  # created_at :datetime
1843
1843
  # updated_at :datetime
1844
- # deleted_at :datetime
1845
1844
  # access_address :string
1846
1845
  # language_id :integer default(1), not null
1847
1846
  # carrier_type_id :integer default(1), not null
@@ -87,7 +87,6 @@ end
87
87
  # full_name_alternative :text
88
88
  # created_at :datetime
89
89
  # updated_at :datetime
90
- # deleted_at :datetime
91
90
  # zip_code_1 :string
92
91
  # zip_code_2 :string
93
92
  # address_1 :text
@@ -0,0 +1,18 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CustomProperty, type: :model do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
6
+
7
+ # == Schema Information
8
+ #
9
+ # Table name: custom_properties
10
+ #
11
+ # id :bigint not null, primary key
12
+ # resource_id :integer not null
13
+ # resource_type :string not null
14
+ # label :text not null
15
+ # value :text
16
+ # created_at :datetime not null
17
+ # updated_at :datetime not null
18
+ #
@@ -18,7 +18,6 @@ end
18
18
  # item_identifier :string
19
19
  # created_at :datetime
20
20
  # updated_at :datetime
21
- # deleted_at :datetime
22
21
  # shelf_id :integer default(1), not null
23
22
  # include_supplements :boolean default(FALSE), not null
24
23
  # note :text
@@ -227,8 +227,8 @@ describe Manifestation, solr: true do
227
227
  csv["item_id"].compact.should_not be_empty
228
228
  csv["item_created_at"].compact.should_not be_empty
229
229
  csv["item_updated_at"].compact.should_not be_empty
230
- csv["subject:unknown"].compact.should eq manifestations(:manifestation_00001).items.count.times.map{"next-l"}
231
- csv["classification:ndc9"].compact.should eq manifestations(:manifestation_00001).items.count.times.map{"400"}
230
+ csv["subject:unknown"].compact.inject(0){|count, a| count += 1 if a == 'next-l'; count}.should eq manifestations(:manifestation_00001).items.count
231
+ csv["classification:ndc9"].compact.inject(0){|count, a| count += 1 if a == '400'; count}.should eq manifestations(:manifestation_00001).items.count
232
232
  csv["extent"].compact.should_not be_empty
233
233
  csv["dimensions"].compact.should_not be_empty
234
234
  end
@@ -274,13 +274,13 @@ describe Manifestation, solr: true do
274
274
 
275
275
  it "should respect the role of the user" do
276
276
  FactoryBot.create(:item, bookstore_id: 1, price: 100, budget_type_id: 1)
277
- lines = Manifestation.export
277
+ lines = Manifestation.export(role: 'Guest')
278
278
  csv = CSV.parse(lines, headers: true, col_sep: "\t")
279
279
  expect(csv["bookstore"].compact).to be_empty
280
280
  expect(csv["item_price"].compact).to be_empty
281
281
  expect(csv["budget_type"].compact).to be_empty
282
282
 
283
- lines = Manifestation.export(format: :txt, role: :Librarian)
283
+ lines = Manifestation.export(role: 'Librarian')
284
284
  csv = CSV.parse(lines, headers: true, col_sep: "\t")
285
285
  expect(csv["bookstore"].compact).not_to be_empty
286
286
  expect(csv["item_price"].compact).not_to be_empty
@@ -296,9 +296,34 @@ describe Manifestation, solr: true do
296
296
  expect(csv["note"].compact).not_to be_empty
297
297
  expect(csv["item_note"].compact).not_to be_empty
298
298
  m = csv.find{|row| row["manifestation_id"].to_i == manifestation.id }
299
- expect(m["description"]).to eq 'test\ntest'
300
- expect(m["note"]).to eq 'test\ntest'
301
- expect(m["item_note"]).to eq 'test\ntest'
299
+ expect(m["description"]).to eq "test\ntest"
300
+ expect(m["note"]).to eq "test\ntest"
301
+ expect(m["item_note"]).to eq "test\ntest"
302
+ end
303
+
304
+ it 'should export custom properties with Librarian role' do
305
+ item = FactoryBot.create(:item)
306
+ item.manifestation.custom_properties << FactoryBot.build(:custom_property, label: 'テスト項目1', value: 'テスト')
307
+ 2.times do
308
+ item.custom_properties << FactoryBot.build(:custom_property, label: 'テスト項目2', value: 'test')
309
+ end
310
+
311
+ lines = Manifestation.export(role: 'Librarian')
312
+ csv = CSV.parse(lines, headers: true, col_sep: "\t")
313
+ m = csv.find{|row| row["manifestation_id"].to_i == item.manifestation_id }
314
+ expect(m['manifestation_custom_property_1']).to eq 'テスト項目1: テスト'
315
+ expect(m['item_custom_property_2']).to eq 'テスト項目2: test'
316
+ end
317
+
318
+ it 'should not export custom properties with User role' do
319
+ item = FactoryBot.create(:item)
320
+ item.manifestation.custom_properties << FactoryBot.build(:custom_property, label: 'テスト項目1', value: 'テスト')
321
+ item.custom_properties << FactoryBot.build(:custom_property, label: 'テスト項目2', value: 'test')
322
+
323
+ lines = Manifestation.export(role: 'User')
324
+ csv = CSV.parse(lines, headers: true, col_sep: "\t")
325
+ expect(csv['manifestation_custom_property_1'].compact).to be_empty
326
+ expect(csv['item_custom_property_2'].compact).to be_empty
302
327
  end
303
328
  end
304
329
  end
@@ -317,7 +342,6 @@ end
317
342
  # date_copyrighted :datetime
318
343
  # created_at :datetime
319
344
  # updated_at :datetime
320
- # deleted_at :datetime
321
345
  # access_address :string
322
346
  # language_id :integer default(1), not null
323
347
  # carrier_type_id :integer default(1), not null