enju_biblio 0.3.8 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/content_types_controller.rb +1 -1
  3. data/app/controllers/item_custom_properties_controller.rb +69 -0
  4. data/app/controllers/items_controller.rb +2 -3
  5. data/app/controllers/manifestation_custom_properties_controller.rb +69 -0
  6. data/app/controllers/manifestations_controller.rb +12 -15
  7. data/app/controllers/resource_import_results_controller.rb +6 -2
  8. data/app/models/agent.rb +6 -6
  9. data/app/models/agent_import_file.rb +7 -7
  10. data/app/models/agent_type.rb +0 -1
  11. data/app/models/carrier_type.rb +0 -1
  12. data/app/models/content_type.rb +0 -1
  13. data/app/models/form_of_work.rb +1 -2
  14. data/app/models/frequency.rb +0 -1
  15. data/app/models/identifier_type.rb +0 -1
  16. data/app/models/item.rb +15 -16
  17. data/app/models/item_custom_property.rb +18 -0
  18. data/app/models/item_custom_value.rb +17 -0
  19. data/app/models/license.rb +0 -1
  20. data/app/models/manifestation.rb +54 -22
  21. data/app/models/manifestation_custom_property.rb +18 -0
  22. data/app/models/manifestation_custom_value.rb +17 -0
  23. data/app/models/medium_of_performance.rb +1 -2
  24. data/app/models/picture_file.rb +0 -2
  25. data/app/models/resource_export_file.rb +4 -2
  26. data/app/models/resource_import_file.rb +157 -67
  27. data/app/policies/item_custom_property_policy.rb +21 -0
  28. data/app/policies/manifestation_custom_property_policy.rb +21 -0
  29. data/app/views/agent_import_results/index.txt.ruby +5 -0
  30. data/app/views/agent_relationship_types/_form.html.erb +1 -1
  31. data/app/views/agent_types/_form.html.erb +1 -1
  32. data/app/views/carrier_types/_form.html.erb +1 -1
  33. data/app/views/create_types/_form.html.erb +1 -1
  34. data/app/views/form_of_works/_form.html.erb +1 -1
  35. data/app/views/frequencies/_form.html.erb +1 -1
  36. data/app/views/item_custom_properties/_form.html.erb +32 -0
  37. data/app/views/item_custom_properties/edit.html.erb +13 -0
  38. data/app/views/item_custom_properties/index.html.erb +43 -0
  39. data/app/views/item_custom_properties/new.html.erb +12 -0
  40. data/app/views/item_custom_properties/show.html.erb +28 -0
  41. data/app/views/items/_form.html.erb +13 -10
  42. data/app/views/items/show.html.erb +3 -4
  43. data/app/views/licenses/_form.html.erb +1 -1
  44. data/app/views/manifestation_custom_properties/_form.html.erb +32 -0
  45. data/app/views/manifestation_custom_properties/edit.html.erb +13 -0
  46. data/app/views/manifestation_custom_properties/index.html.erb +43 -0
  47. data/app/views/manifestation_custom_properties/new.html.erb +12 -0
  48. data/app/views/manifestation_custom_properties/show.html.erb +28 -0
  49. data/app/views/manifestation_relationship_types/_form.html.erb +1 -1
  50. data/app/views/manifestations/_export_detail.html.erb +1 -0
  51. data/app/views/manifestations/_export_list.html.erb +1 -0
  52. data/app/views/manifestations/_form.html.erb +18 -10
  53. data/app/views/manifestations/_show_detail_librarian.html.erb +9 -3
  54. data/app/views/manifestations/_show_detail_user.html.erb +8 -0
  55. data/app/views/manifestations/show.json.jbuilder +2 -0
  56. data/app/views/medium_of_performances/_form.html.erb +1 -1
  57. data/app/views/picture_files/edit.html.erb +4 -0
  58. data/app/views/produce_types/_form.html.erb +1 -1
  59. data/app/views/realize_types/_form.html.erb +1 -1
  60. data/app/views/resource_import_results/index.txt.ruby +5 -0
  61. data/app/views/series_statement_merges/_form.html.erb +1 -1
  62. data/config/locales/translation_en.yml +22 -8
  63. data/config/locales/translation_ja.yml +22 -8
  64. data/config/routes.rb +2 -0
  65. data/db/migrate/20081027150907_create_picture_files.rb +0 -2
  66. data/db/migrate/20200425072340_create_manifestation_custom_properties.rb +12 -0
  67. data/db/migrate/20200425072349_create_item_custom_properties.rb +12 -0
  68. data/db/migrate/20200425074758_create_manifestation_custom_values.rb +12 -0
  69. data/db/migrate/20200425074822_create_item_custom_values.rb +12 -0
  70. data/lib/enju_biblio/version.rb +1 -1
  71. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_import_custom_values.yml +121 -0
  72. data/spec/cassette_library/resource_import_results/index_txt_ruby/renders_a_list_of_resource_import_results.yml +121 -0
  73. data/spec/controllers/content_types_controller_spec.rb +1 -1
  74. data/spec/controllers/item_custom_properties_controller_spec.rb +449 -0
  75. data/spec/controllers/items_controller_spec.rb +22 -25
  76. data/spec/controllers/manifestation_custom_properties_controller_spec.rb +449 -0
  77. data/spec/controllers/manifestations_controller_spec.rb +20 -23
  78. data/spec/dummy/db/schema.rb +43 -12
  79. data/spec/factories/item_custom_property.rb +6 -0
  80. data/spec/factories/item_custom_value.rb +6 -0
  81. data/spec/factories/manifestation_custom_property.rb +6 -0
  82. data/spec/factories/manifestation_custom_value.rb +6 -0
  83. data/spec/fixtures/creates.yml +2 -0
  84. data/spec/fixtures/item_custom_properties.yml +24 -0
  85. data/spec/fixtures/library_groups.yml +29 -15
  86. data/spec/fixtures/manifestation_custom_properties.yml +24 -0
  87. data/spec/fixtures/picture_files.yml +0 -2
  88. data/spec/fixtures/produces.yml +2 -0
  89. data/spec/fixtures/realizes.yml +2 -0
  90. data/spec/fixtures/resource_import_results.yml +2 -2
  91. data/spec/models/item_custom_property_spec.rb +18 -0
  92. data/spec/models/item_custom_value_spec.rb +17 -0
  93. data/spec/models/manifestation_custom_property_spec.rb +18 -0
  94. data/spec/models/manifestation_custom_value_spec.rb +17 -0
  95. data/spec/models/manifestation_spec.rb +11 -21
  96. data/spec/models/picture_file_spec.rb +0 -2
  97. data/spec/models/resource_export_file_spec.rb +61 -8
  98. data/spec/models/resource_import_file_spec.rb +43 -13
  99. data/spec/requests/item_custom_properties_spec.rb +129 -0
  100. data/spec/requests/manifestation_custom_properties_spec.rb +129 -0
  101. data/spec/routing/item_custom_properties_routing_spec.rb +38 -0
  102. data/spec/routing/manifestation_custom_properties_routing_spec.rb +38 -0
  103. data/spec/system/items_spec.rb +12 -0
  104. data/spec/system/manifestations_spec.rb +12 -0
  105. data/spec/views/agent_import_results/index.html.erb_spec.rb +29 -0
  106. data/spec/views/agent_import_results/index.txt.ruby_spec.rb +20 -0
  107. data/spec/views/agent_import_results/show.html.erb_spec.rb +24 -0
  108. data/spec/views/item_custom_properties/edit.html.erb_spec.rb +21 -0
  109. data/spec/views/item_custom_properties/index.html.erb_spec.rb +25 -0
  110. data/spec/views/item_custom_properties/new.html.erb_spec.rb +21 -0
  111. data/spec/views/item_custom_properties/show.html.erb_spec.rb +16 -0
  112. data/spec/views/manifestation_custom_properties/edit.html.erb_spec.rb +21 -0
  113. data/spec/views/manifestation_custom_properties/index.html.erb_spec.rb +25 -0
  114. data/spec/views/manifestation_custom_properties/new.html.erb_spec.rb +21 -0
  115. data/spec/views/manifestation_custom_properties/show.html.erb_spec.rb +16 -0
  116. data/spec/views/manifestations/show.json.jbuilder_spec.rb +16 -0
  117. data/spec/views/manifestations/show.txt.ruby_spec.rb +1 -1
  118. data/spec/views/resource_import_results/index.txt.ruby_spec.rb +22 -0
  119. data/spec/views/resource_import_results/show.html.erb_spec.rb +1 -1
  120. metadata +118 -37
  121. data/app/models/custom_property.rb +0 -17
  122. data/app/views/agent_import_results/index.txt.erb +0 -3
  123. data/app/views/items/_custom_property_fields.html.erb +0 -7
  124. data/app/views/manifestations/_custom_property_fields.html.erb +0 -7
  125. data/app/views/resource_import_results/index.txt.erb +0 -3
  126. data/db/migrate/20191219122214_create_custom_properties.rb +0 -12
  127. data/spec/factories/custom_property.rb +0 -18
  128. data/spec/models/custom_property_spec.rb +0 -18
  129. data/spec/system/custom_properties_spec.rb +0 -84
@@ -575,6 +575,12 @@ describe ManifestationsController do
575
575
  post :create, params: { manifestation: @attrs.merge(attachment: fixture_file_upload('/../../examples/resource_import_file_sample1.tsv', 'text/csv')) }
576
576
  expect(assigns(:manifestation)).to be_valid
577
577
  end
578
+
579
+ it 'accepts custom values' do
580
+ post :create, params: { manifestation: @attrs.merge(manifestation_custom_values_attributes: Array.new(3){FactoryBot.attributes_for(:manifestation_custom_value, manifestation_custom_property_id: FactoryBot.create(:manifestation_custom_property).id)}) }
581
+ expect(assigns(:manifestation)).to be_valid
582
+ expect(assigns(:manifestation).manifestation_custom_values.count).to eq 3
583
+ end
578
584
  end
579
585
 
580
586
  describe 'with invalid params' do
@@ -717,17 +723,20 @@ describe ManifestationsController do
717
723
  expect(assigns(:manifestation)).to eq @manifestation
718
724
  end
719
725
 
720
- it 'assigns custom properties to @manifestation' do
721
- manifestation = FactoryBot.create(:manifestation_custom_property).resource
722
- custom_properties_attrs = {
723
- custom_properties_attributes: [{label: 'test', value: 'テスト'}]
724
- }
725
- put :update, params: {
726
- id: manifestation.id, manifestation: @attrs.merge(custom_properties_attrs)
727
- }
728
- expect(assigns(:manifestation)).to eq manifestation
729
- expect(assigns(:manifestation).custom_properties.map{|property| property.label}).to eq ['custom property 1', 'test']
730
- expect(assigns(:manifestation).custom_properties.map{|property| property.value}).to eq ['カスタム項目 1', 'テスト']
726
+ it 'accepts custom values' do
727
+ @manifestation.manifestation_custom_values << FactoryBot.build(:manifestation_custom_value)
728
+ put :update, params: { id: @manifestation.id, manifestation: @attrs.merge(manifestation_custom_values_attributes: [{id: @manifestation.manifestation_custom_values.first.id, value: 'test'}]) }
729
+ expect(assigns(:manifestation)).to be_valid
730
+ expect(assigns(:manifestation).manifestation_custom_values.count).to eq 1
731
+ expect(assigns(:manifestation).manifestation_custom_values.first.value).to eq 'test'
732
+ end
733
+
734
+ it 'accepts custom values when the value is empty' do
735
+ @manifestation.manifestation_custom_values << FactoryBot.build(:manifestation_custom_value)
736
+ put :update, params: { id: @manifestation.id, manifestation: @attrs.merge(manifestation_custom_values_attributes: [{id: @manifestation.manifestation_custom_values.first.id, value: ''}]) }
737
+ expect(assigns(:manifestation)).to be_valid
738
+ expect(assigns(:manifestation).manifestation_custom_values.count).to eq 1
739
+ expect(assigns(:manifestation).manifestation_custom_values.first.value).to eq ''
731
740
  end
732
741
  end
733
742
 
@@ -754,18 +763,6 @@ describe ManifestationsController do
754
763
  }
755
764
  expect(assigns(:manifestation)).to_not be_valid
756
765
  end
757
-
758
- it 'assigns custom properties to @manifestation' do
759
- manifestation = FactoryBot.create(:manifestation_custom_property).resource
760
- custom_properties_attrs = {
761
- custom_properties_attributes: [{name: 'test', value: 'テスト'}]
762
- }
763
- put :update, params: {
764
- id: manifestation.id, manifestation: @invalid_attrs.merge(custom_properties_attrs)
765
- }
766
- expect(assigns(:manifestation).custom_properties.count).to eq 1
767
- expect(assigns(:manifestation)).to_not be_valid
768
- end
769
766
  end
770
767
  end
771
768
 
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2019_12_19_122214) do
13
+ ActiveRecord::Schema.define(version: 2020_04_25_074822) do
14
14
 
15
15
  create_table "accepts", force: :cascade do |t|
16
16
  t.integer "basket_id"
@@ -433,15 +433,6 @@ ActiveRecord::Schema.define(version: 2019_12_19_122214) do
433
433
  t.index ["work_id"], name: "index_creates_on_work_id"
434
434
  end
435
435
 
436
- create_table "custom_properties", force: :cascade do |t|
437
- t.integer "resource_id", null: false
438
- t.string "resource_type", null: false
439
- t.text "label", null: false
440
- t.text "value"
441
- t.datetime "created_at", null: false
442
- t.datetime "updated_at", null: false
443
- end
444
-
445
436
  create_table "demands", force: :cascade do |t|
446
437
  t.integer "user_id"
447
438
  t.integer "item_id"
@@ -653,6 +644,27 @@ ActiveRecord::Schema.define(version: 2019_12_19_122214) do
653
644
  t.index ["user_id"], name: "index_inventory_files_on_user_id"
654
645
  end
655
646
 
647
+ create_table "item_custom_properties", force: :cascade do |t|
648
+ t.string "name", null: false
649
+ t.text "display_name", null: false
650
+ t.text "note"
651
+ t.integer "position", default: 1, null: false
652
+ t.datetime "created_at", null: false
653
+ t.datetime "updated_at", null: false
654
+ t.index ["name"], name: "index_item_custom_properties_on_name", unique: true
655
+ end
656
+
657
+ create_table "item_custom_values", force: :cascade do |t|
658
+ t.integer "item_custom_property_id", null: false
659
+ t.integer "item_id", null: false
660
+ t.text "value"
661
+ t.datetime "created_at", null: false
662
+ t.datetime "updated_at", null: false
663
+ t.index ["item_custom_property_id", "item_id"], name: "index_item_custom_values_on_custom_item_property_and_item_id", unique: true
664
+ t.index ["item_custom_property_id"], name: "index_item_custom_values_on_custom_property_id"
665
+ t.index ["item_id"], name: "index_item_custom_values_on_item_id"
666
+ end
667
+
656
668
  create_table "item_has_use_restrictions", force: :cascade do |t|
657
669
  t.integer "item_id", null: false
658
670
  t.integer "use_restriction_id", null: false
@@ -831,6 +843,27 @@ ActiveRecord::Schema.define(version: 2019_12_19_122214) do
831
843
  t.index ["user_id"], name: "index_manifestation_checkout_stats_on_user_id"
832
844
  end
833
845
 
846
+ create_table "manifestation_custom_properties", force: :cascade do |t|
847
+ t.string "name", null: false
848
+ t.text "display_name", null: false
849
+ t.text "note"
850
+ t.integer "position", default: 1, null: false
851
+ t.datetime "created_at", null: false
852
+ t.datetime "updated_at", null: false
853
+ t.index ["name"], name: "index_manifestation_custom_properties_on_name", unique: true
854
+ end
855
+
856
+ create_table "manifestation_custom_values", force: :cascade do |t|
857
+ t.integer "manifestation_custom_property_id", null: false
858
+ t.integer "manifestation_id", null: false
859
+ t.text "value"
860
+ t.datetime "created_at", null: false
861
+ t.datetime "updated_at", null: false
862
+ t.index ["manifestation_custom_property_id", "manifestation_id"], name: "index_manifestation_custom_values_on_property_manifestation", unique: true
863
+ t.index ["manifestation_custom_property_id"], name: "index_manifestation_custom_values_on_custom_property_id"
864
+ t.index ["manifestation_id"], name: "index_manifestation_custom_values_on_manifestation_id"
865
+ end
866
+
834
867
  create_table "manifestation_relationship_types", force: :cascade do |t|
835
868
  t.string "name", null: false
836
869
  t.text "display_name"
@@ -1039,9 +1072,7 @@ ActiveRecord::Schema.define(version: 2019_12_19_122214) do
1039
1072
  create_table "picture_files", force: :cascade do |t|
1040
1073
  t.integer "picture_attachable_id"
1041
1074
  t.string "picture_attachable_type"
1042
- t.string "content_type"
1043
1075
  t.text "title"
1044
- t.string "thumbnail"
1045
1076
  t.integer "position"
1046
1077
  t.datetime "created_at"
1047
1078
  t.datetime "updated_at"
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :item_custom_property do
3
+ sequence(:name){|n| "property_name_#{n}"}
4
+ sequence(:display_name){|n| "プロパティ名_#{n}"}
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :item_custom_value do
3
+ association :item_custom_property
4
+ sequence(:value){|n| "value_#{n}"}
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :manifestation_custom_property do
3
+ sequence(:name){|n| "property_name_#{n}"}
4
+ sequence(:display_name){|n| "プロパティ名_#{n}"}
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :manifestation_custom_value do
3
+ association :manifestation_custom_property
4
+ sequence(:value){|n| "value_#{n}"}
5
+ end
6
+ end
@@ -2,6 +2,7 @@
2
2
  create_00001:
3
3
  updated_at: 2007-12-13 19:56:07.002082 +09:00
4
4
  agent_id: 1
5
+ create_type_id: 1
5
6
  id: 1
6
7
  work_id: 1
7
8
  position: 1
@@ -9,6 +10,7 @@ create_00001:
9
10
  create_00002:
10
11
  updated_at: 2007-12-13 19:56:48.538796 +09:00
11
12
  agent_id: 1
13
+ create_type_id: 1
12
14
  id: 2
13
15
  work_id: 2
14
16
  position: 1
@@ -0,0 +1,24 @@
1
+ one:
2
+ id: 1
3
+ name: custom_1
4
+ display_name: "カスタム項目1"
5
+ position: 1
6
+
7
+ two:
8
+ id: 2
9
+ name: custom_2
10
+ display_name: "カスタム項目1"
11
+ position: 2
12
+
13
+ # == Schema Information
14
+ #
15
+ # Table name: item_custom_properties
16
+ #
17
+ # id :integer not null, primary key
18
+ # name :string not null
19
+ # display_name :text not null
20
+ # note :text
21
+ # position :integer default(1), not null
22
+ # created_at :datetime not null
23
+ # updated_at :datetime not null
24
+ #
@@ -13,24 +13,38 @@ one:
13
13
  admin_networks: "0.0.0.0/0\r\n\
14
14
  ::/0"
15
15
  user_id: 1
16
- max_number_of_results: 200
17
- family_name_first: true
16
+ pub_year_facet_range_interval: 10
18
17
 
19
18
  # == Schema Information
20
19
  #
21
20
  # Table name: library_groups
22
21
  #
23
- # id :integer not null, primary key
24
- # name :string(255) not null
25
- # display_name :text
26
- # short_name :string(255) not null
27
- # my_networks :text
28
- # login_banner :text
29
- # note :text
30
- # country_id :integer
31
- # position :integer
32
- # created_at :datetime not null
33
- # updated_at :datetime not null
34
- # admin_networks :text
35
- # url :string(255) default("http://localhost:3000/")
22
+ # id :integer not null, primary key
23
+ # name :string not null
24
+ # display_name :text
25
+ # short_name :string not null
26
+ # my_networks :text
27
+ # old_login_banner :text
28
+ # note :text
29
+ # country_id :integer
30
+ # position :integer
31
+ # created_at :datetime
32
+ # updated_at :datetime
33
+ # admin_networks :text
34
+ # allow_bookmark_external_url :boolean default(FALSE), not null
35
+ # url :string default("http://localhost:3000/")
36
+ # settings :text
37
+ # html_snippet :text
38
+ # book_jacket_source :string
39
+ # max_number_of_results :integer default(500)
40
+ # family_name_first :boolean default(TRUE)
41
+ # screenshot_generator :string
42
+ # pub_year_facet_range_interval :integer default(10)
43
+ # user_id :integer
44
+ # csv_charset_conversion :boolean default(FALSE), not null
45
+ # header_logo_file_name :string
46
+ # header_logo_content_type :string
47
+ # header_logo_file_size :integer
48
+ # header_logo_updated_at :datetime
49
+ # header_logo_meta :text
36
50
  #
@@ -0,0 +1,24 @@
1
+ one:
2
+ id: 1
3
+ name: custom_1
4
+ display_name: "カスタム項目1"
5
+ position: 1
6
+
7
+ two:
8
+ id: 2
9
+ name: custom_2
10
+ display_name: "カスタム項目1"
11
+ position: 2
12
+
13
+ # == Schema Information
14
+ #
15
+ # Table name: manifestation_custom_properties
16
+ #
17
+ # id :integer not null, primary key
18
+ # name :string not null
19
+ # display_name :text not null
20
+ # note :text
21
+ # position :integer default(1), not null
22
+ # created_at :datetime not null
23
+ # updated_at :datetime not null
24
+ #
@@ -47,9 +47,7 @@ picture_file_00004:
47
47
  # id :integer not null, primary key
48
48
  # picture_attachable_id :integer
49
49
  # picture_attachable_type :string
50
- # content_type :string
51
50
  # title :text
52
- # thumbnail :string
53
51
  # position :integer
54
52
  # created_at :datetime
55
53
  # updated_at :datetime
@@ -3,6 +3,7 @@ produce_00001:
3
3
  updated_at: 2008-01-11 23:28:19.277110 +09:00
4
4
  manifestation_id: 1
5
5
  agent_id: 1
6
+ produce_type_id: 1
6
7
  id: 1
7
8
  position: 1
8
9
  created_at: 2008-01-11 23:28:19.277110 +09:00
@@ -10,6 +11,7 @@ produce_00002:
10
11
  updated_at: 2008-01-11 23:28:57.068191 +09:00
11
12
  manifestation_id: 2
12
13
  agent_id: 2
14
+ produce_type_id: 1
13
15
  id: 2
14
16
  position: 1
15
17
  created_at: 2008-01-11 23:28:57.068191 +09:00
@@ -3,6 +3,7 @@ realize_00001:
3
3
  updated_at: 2008-01-11 23:28:19.277110 +09:00
4
4
  expression_id: 1
5
5
  agent_id: 1
6
+ realize_type_id: 1
6
7
  id: 1
7
8
  position: 1
8
9
  created_at: 2008-01-11 23:28:19.277110 +09:00
@@ -10,6 +11,7 @@ realize_00002:
10
11
  updated_at: 2008-01-11 23:28:57.068191 +09:00
11
12
  expression_id: 2
12
13
  agent_id: 2
14
+ realize_type_id: 1
13
15
  id: 2
14
16
  position: 2
15
17
  created_at: 2008-01-11 23:28:57.068191 +09:00
@@ -5,14 +5,14 @@ one:
5
5
  resource_import_file_id: 1
6
6
  manifestation_id: 1
7
7
  item_id: 1
8
- body: MyText
8
+ body: "original_title\tmanifestation_id"
9
9
 
10
10
  two:
11
11
  id: 2
12
12
  resource_import_file_id: 1
13
13
  manifestation_id: 1
14
14
  item_id: 1
15
- body: MyText
15
+ body: "MyText\t10"
16
16
 
17
17
  # == Schema Information
18
18
  #
@@ -0,0 +1,18 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe ItemCustomProperty, type: :model do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
6
+
7
+ # == Schema Information
8
+ #
9
+ # Table name: item_custom_properties
10
+ #
11
+ # id :integer not null, primary key
12
+ # name :string not null
13
+ # display_name :text not null
14
+ # note :text
15
+ # position :integer default(1), not null
16
+ # created_at :datetime not null
17
+ # updated_at :datetime not null
18
+ #
@@ -0,0 +1,17 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe ItemCustomValue, type: :model do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
6
+
7
+ # == Schema Information
8
+ #
9
+ # Table name: item_custom_values
10
+ #
11
+ # id :integer not null, primary key
12
+ # item_custom_property_id :integer not null
13
+ # item_id :integer not null
14
+ # value :text
15
+ # created_at :datetime not null
16
+ # updated_at :datetime not null
17
+ #
@@ -0,0 +1,18 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe ManifestationCustomProperty, type: :model do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
6
+
7
+ # == Schema Information
8
+ #
9
+ # Table name: manifestation_custom_properties
10
+ #
11
+ # id :integer not null, primary key
12
+ # name :string not null
13
+ # display_name :text not null
14
+ # note :text
15
+ # position :integer default(1), not null
16
+ # created_at :datetime not null
17
+ # updated_at :datetime not null
18
+ #
@@ -0,0 +1,17 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe ManifestationCustomValue, type: :model do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end
6
+
7
+ # == Schema Information
8
+ #
9
+ # Table name: manifestation_custom_values
10
+ #
11
+ # id :integer not null, primary key
12
+ # manifestation_custom_property_id :integer not null
13
+ # manifestation_id :integer not null
14
+ # value :text
15
+ # created_at :datetime not null
16
+ # updated_at :datetime not null
17
+ #
@@ -261,7 +261,7 @@ describe Manifestation, solr: true do
261
261
  lines = Manifestation.export()
262
262
  csv = CSV.parse(lines, headers: true, col_sep: "\t")
263
263
  m = csv.find{|row| row["manifestation_id"].to_i == manifestation.id }
264
- expect(m["isbn"]).to eq "9784043898039//9784840239219"
264
+ expect(m["identifier:isbn"]).to eq "9784043898039//9784840239219"
265
265
  end
266
266
 
267
267
  it "should respect the role of the user" do
@@ -293,29 +293,19 @@ describe Manifestation, solr: true do
293
293
  expect(m["item_note"]).to eq "test\ntest"
294
294
  end
295
295
 
296
- it 'should export custom properties with Librarian role' do
296
+ it 'should export custom properties"' do
297
297
  item = FactoryBot.create(:item)
298
- item.manifestation.custom_properties << FactoryBot.build(:custom_property, label: 'テスト項目1', value: 'テスト')
299
- 2.times do
300
- item.custom_properties << FactoryBot.build(:custom_property, label: 'テスト項目2', value: 'test')
301
- end
302
-
298
+ item.item_custom_values << FactoryBot.build(:item_custom_value)
299
+ item.manifestation.manifestation_custom_values << FactoryBot.build(:manifestation_custom_value)
303
300
  lines = Manifestation.export(role: 'Librarian')
304
301
  csv = CSV.parse(lines, headers: true, col_sep: "\t")
305
- m = csv.find{|row| row["manifestation_id"].to_i == item.manifestation_id }
306
- expect(m['manifestation_custom_property_1']).to eq 'テスト項目1: テスト'
307
- expect(m['item_custom_property_2']).to eq 'テスト項目2: test'
308
- end
309
-
310
- it 'should not export custom properties with User role' do
311
- item = FactoryBot.create(:item)
312
- item.manifestation.custom_properties << FactoryBot.build(:custom_property, label: 'テスト項目1', value: 'テスト')
313
- item.custom_properties << FactoryBot.build(:custom_property, label: 'テスト項目2', value: 'test')
314
-
315
- lines = Manifestation.export(role: 'User')
316
- csv = CSV.parse(lines, headers: true, col_sep: "\t")
317
- expect(csv['manifestation_custom_property_1'].compact).to be_empty
318
- expect(csv['item_custom_property_2'].compact).to be_empty
302
+ m = csv.find{|row| row["manifestation_id"].to_i == item.manifestation.id }
303
+ item.item_custom_values.each do |custom_value|
304
+ expect(m["item:#{custom_value.item_custom_property.name}"]).to eq custom_value.value
305
+ end
306
+ item.manifestation.manifestation_custom_values.each do |custom_value|
307
+ expect(m["manifestation:#{custom_value.manifestation_custom_property.name}"]).to eq custom_value.value
308
+ end
319
309
  end
320
310
  end
321
311
  end