ddr-models 2.7.6 → 2.8.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/collection.rb +1 -1
  3. data/app/models/component.rb +22 -31
  4. data/config/initializers/active_fedora_base.rb +8 -0
  5. data/config/locales/ddr-models.en.yml +4 -0
  6. data/lib/ddr/datastreams.rb +12 -10
  7. data/lib/ddr/datastreams/administrative_metadata_datastream.rb +6 -0
  8. data/lib/ddr/datastreams/streamable_media_datastream.rb +5 -0
  9. data/lib/ddr/index/fields.rb +7 -5
  10. data/lib/ddr/managers/derivatives_manager.rb +12 -7
  11. data/lib/ddr/models.rb +19 -9
  12. data/lib/ddr/models/base.rb +10 -3
  13. data/lib/ddr/models/file_management.rb +1 -1
  14. data/lib/ddr/models/has_admin_metadata.rb +8 -9
  15. data/lib/ddr/models/indexing.rb +18 -3
  16. data/lib/ddr/models/language.rb +31 -0
  17. data/lib/ddr/models/media_type.rb +22 -0
  18. data/lib/ddr/models/{licenses/license.rb → rights_statement.rb} +3 -7
  19. data/lib/ddr/models/solr_document.rb +22 -2
  20. data/lib/ddr/models/streamable.rb +22 -0
  21. data/lib/ddr/models/version.rb +1 -1
  22. data/lib/ddr/utils.rb +4 -4
  23. data/lib/ddr/vocab/asset.rb +8 -0
  24. data/spec/factories/collection_factories.rb +1 -0
  25. data/spec/index/fields_spec.rb +18 -0
  26. data/spec/managers/derivatives_manager_spec.rb +2 -5
  27. data/spec/models/active_fedora_base_spec.rb +3 -0
  28. data/spec/models/admin_set_spec.rb +2 -1
  29. data/spec/models/attachment_spec.rb +1 -0
  30. data/spec/models/collection_spec.rb +4 -7
  31. data/spec/models/component_spec.rb +20 -5
  32. data/spec/models/has_struct_metadata_spec.rb +0 -1
  33. data/spec/models/indexing_spec.rb +91 -44
  34. data/spec/models/item_spec.rb +1 -0
  35. data/spec/models/language_spec.rb +59 -0
  36. data/spec/models/media_type_spec.rb +46 -0
  37. data/spec/models/{license_spec.rb → rights_statement_spec.rb} +9 -12
  38. data/spec/models/solr_document_spec.rb +57 -2
  39. data/spec/models/target_spec.rb +1 -0
  40. data/spec/spec_helper.rb +11 -0
  41. data/spec/support/shared_examples_for_ddr_models.rb +12 -0
  42. data/spec/support/shared_examples_for_governables.rb +2 -1
  43. data/spec/support/shared_examples_for_streamable_media.rb +22 -0
  44. metadata +17 -13
  45. data/lib/ddr/models/licenses/admin_policy_license.rb +0 -11
  46. data/lib/ddr/models/licenses/effective_license.rb +0 -9
  47. data/lib/ddr/models/licenses/inherited_license.rb +0 -9
  48. data/lib/ddr/models/licenses/parent_license.rb +0 -11
  49. data/spec/models/effective_license_spec.rb +0 -74
@@ -0,0 +1,31 @@
1
+ require "active_resource"
2
+
3
+ module Ddr::Models
4
+ class Language < ActiveResource::Base
5
+
6
+ self.site = ENV["DDR_AUX_API_URL"]
7
+
8
+ def self.call(obj)
9
+ obj.language.map do |lang|
10
+ find_by_code(lang)
11
+ end
12
+ rescue ActiveResource::ResourceNotFound => e
13
+ raise Ddr::Models::NotFoundError, e
14
+ end
15
+
16
+ def self.find_by_code(code)
17
+ return unless code
18
+ new get(:find, code: code)
19
+ end
20
+
21
+ def self.codes
22
+ all.map(&:code)
23
+ end
24
+
25
+ def to_s
26
+ label
27
+ end
28
+
29
+ end
30
+ end
31
+
@@ -0,0 +1,22 @@
1
+ module Ddr::Models
2
+ class MediaType
3
+
4
+ def self.call(file_or_path)
5
+ path = file_or_path.respond_to?(:path) ? file_or_path.path : file_or_path
6
+ # Use preferred media type, if available
7
+ media_type = Ddr::Models.preferred_media_types[File.extname(path)]
8
+ if !media_type
9
+ if file_or_path.respond_to?(:content_type)
10
+ # Rails ActionDispatch::Http::UploadedFile
11
+ media_type = file_or_path.content_type
12
+ else
13
+ # Fall back to first MIME type or default
14
+ mime_types = MIME::Types.of(path)
15
+ media_type = mime_types.empty? ? Ddr::Models.default_mime_type : mime_types.first.content_type
16
+ end
17
+ end
18
+ media_type
19
+ end
20
+
21
+ end
22
+ end
@@ -1,17 +1,13 @@
1
1
  require "active_resource"
2
2
 
3
3
  module Ddr::Models
4
- class License < ActiveResource::Base
4
+ class RightsStatement < ActiveResource::Base
5
5
 
6
6
  self.site = ENV["DDR_AUX_API_URL"]
7
7
 
8
- attr_accessor :pid
9
-
10
8
  def self.call(obj)
11
- if obj.license
12
- license = new get(:find, url: obj.license)
13
- license.pid = obj.pid
14
- license
9
+ if obj.rights.present?
10
+ new get(:find, url: obj.rights.first)
15
11
  end
16
12
  rescue ActiveResource::ResourceNotFound => e
17
13
  raise Ddr::Models::NotFoundError, e
@@ -3,6 +3,9 @@ require 'json'
3
3
  module Ddr::Models
4
4
  module SolrDocument
5
5
  extend ActiveSupport::Concern
6
+ extend Deprecation
7
+
8
+ self.deprecation_horizon = 'ddr-models v3.0'
6
9
 
7
10
  included do
8
11
  alias_method :pid, :id
@@ -176,9 +179,11 @@ module Ddr::Models
176
179
  active_fedora_model.tableize
177
180
  end
178
181
 
179
- def effective_license
180
- @effective_license ||= EffectiveLicense.call(self)
182
+ def rights_statement
183
+ @rights_statement ||= RightsStatement.call(self)
181
184
  end
185
+ alias_method :effective_license, :rights_statement
186
+ deprecation_deprecate :effective_license
182
187
 
183
188
  def roles
184
189
  @roles ||= Ddr::Auth::Roles::DetachedRoleSet.from_json(access_role)
@@ -228,6 +233,21 @@ module Ddr::Models
228
233
  end
229
234
  end
230
235
 
236
+ def streamable?
237
+ has_datastream?(Ddr::Datastreams::STREAMABLE_MEDIA)
238
+ end
239
+
240
+ def streamable_media_path
241
+ if streamable?
242
+ Ddr::Utils.path_from_uri(datastreams[Ddr::Datastreams::STREAMABLE_MEDIA]["dsLocation"])
243
+ end
244
+ end
245
+
246
+ # FIXME - Probably need a more general solution mapping object reader methods to index field names.
247
+ def rights
248
+ self["rights_tesim"]
249
+ end
250
+
231
251
  private
232
252
 
233
253
  def targets_query
@@ -0,0 +1,22 @@
1
+ module Ddr::Models
2
+ module Streamable
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_file_datastream name: Ddr::Datastreams::STREAMABLE_MEDIA,
7
+ type: Ddr::Datastreams::StreamableMediaDatastream,
8
+ versionable: true,
9
+ label: "Streamable media file for this object",
10
+ control_group: "E"
11
+ end
12
+
13
+ def streamable_media_type
14
+ datastreams[Ddr::Datastreams::STREAMABLE_MEDIA].mimeType
15
+ end
16
+
17
+ def streamable_media_path
18
+ datastreams[Ddr::Datastreams::STREAMABLE_MEDIA].file_path
19
+ end
20
+
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "2.7.6"
3
+ VERSION = "2.8.0.rc1"
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  require 'openssl'
2
2
 
3
3
  module Ddr::Utils
4
+ extend Deprecation
4
5
 
5
6
  def self.digest content, algorithm
6
7
  raise TypeError, "Algorithm must be a string: #{algorithm.inspect}" unless algorithm.is_a?(String)
@@ -14,10 +15,9 @@ module Ddr::Utils
14
15
  # file can be a File object or file path (String)
15
16
  # @return [String] the mime type or default
16
17
  def self.mime_type_for(file, file_name=nil)
17
- return file.content_type if file.respond_to?(:content_type) # E.g., Rails uploaded file
18
- path = file_name || file_path(file) rescue nil
19
- mime_types = MIME::Types.of(path) rescue [] # MIME::Types.of blows up on nil
20
- mime_types.empty? ? Ddr::Models.default_mime_type : mime_types.first.content_type
18
+ Deprecation.warn(self, "`Ddr::Utils.mime_type_for` is deprecated and will be removed in ddr-models 3.0." \
19
+ " Use `Ddr::Models::MediaType.call(file)` instead. (called from #{caller.first})")
20
+ Ddr::Models::MediaType.call(file_name || file)
21
21
  end
22
22
 
23
23
  def self.file_or_path?(file)
@@ -35,5 +35,13 @@ module Ddr::Vocab
35
35
  label: "Rights Note",
36
36
  comment: "Free-text statement about the rights status of the resource."
37
37
 
38
+ property "alephId",
39
+ label: "Aleph ID",
40
+ comment: "The Aleph identifier for a catalog record corresponding to the object."
41
+
42
+ property "affiliation",
43
+ label: "Affiliation",
44
+ comment: "An organizational entity associated with the object content."
45
+
38
46
  end
39
47
  end
@@ -2,6 +2,7 @@ FactoryGirl.define do
2
2
 
3
3
  factory :collection do
4
4
  title [ "Test Collection" ]
5
+ admin_set "foo"
5
6
  sequence(:identifier) { |n| [ "coll%05d" % n ] }
6
7
  end
7
8
 
@@ -141,6 +141,18 @@ module Ddr::Index
141
141
  its(:heading) { is_expected.to eq "interviewer_name_facet" }
142
142
  end
143
143
 
144
+ describe "LANGUAGE_FACET" do
145
+ subject { Fields::LANGUAGE_FACET }
146
+ its(:label) { is_expected.to eq "Language Facet" }
147
+ its(:heading) { is_expected.to eq "language_facet" }
148
+ end
149
+
150
+ describe "LANGUAGE_NAME" do
151
+ subject { Fields::LANGUAGE_NAME }
152
+ its(:label) { is_expected.to eq "Language Name" }
153
+ its(:heading) { is_expected.to eq "language_name" }
154
+ end
155
+
144
156
  describe "LITHOGRAPHER_FACET" do
145
157
  subject { Fields::LITHOGRAPHER_FACET }
146
158
  its(:label) { is_expected.to eq "Lithographer Facet" }
@@ -225,6 +237,12 @@ module Ddr::Index
225
237
  its(:heading) { is_expected.to eq "setting_facet" }
226
238
  end
227
239
 
240
+ describe "STREAMABLE_MEDIA_TYPE" do
241
+ subject { Fields::STREAMABLE_MEDIA_TYPE }
242
+ its(:label) { is_expected.to eq "Streamable Media Type" }
243
+ its(:heading) { is_expected.to eq "streamable_media_type" }
244
+ end
245
+
228
246
  describe "SUBSERIES_FACET" do
229
247
  subject { Fields::SUBSERIES_FACET }
230
248
  its(:label) { is_expected.to eq "Subseries Facet" }
@@ -101,15 +101,12 @@ module Ddr::Managers
101
101
  object.reload
102
102
  end
103
103
  it "uses the intermediate file as the derivative source" do
104
- expect(object.intermediateFile).to receive(:content).and_call_original
105
- expect(object.content).to_not receive(:content)
106
- object.derivatives.generate_derivative! Ddr::Derivatives::DERIVATIVES[:multires_image]
104
+ expect(object.derivatives.source_datastream).to equal(object.datastreams[Ddr::Datastreams::INTERMEDIATE_FILE])
107
105
  end
108
106
  end
109
107
  describe "object does not have intermediate file" do
110
108
  it "uses the content file as the derivative source" do
111
- expect(object.content).to receive(:content).and_call_original
112
- object.derivatives.generate_derivative! Ddr::Derivatives::DERIVATIVES[:multires_image]
109
+ expect(object.derivatives.source_datastream).to equal(object.datastreams[Ddr::Datastreams::CONTENT])
113
110
  end
114
111
  end
115
112
  end
@@ -24,4 +24,7 @@ RSpec.describe ActiveFedora::Base do
24
24
  end
25
25
  end
26
26
 
27
+ its(:can_be_streamable?) { is_expected.to be false }
28
+ it { is_expected.not_to be_streamable }
29
+
27
30
  end
@@ -1,5 +1,5 @@
1
1
  module Ddr::Models
2
- RSpec.describe AdminSet, ddr_aux: true do
2
+ RSpec.describe AdminSet, ddr_aux: true, admin_set: true do
3
3
 
4
4
  describe ".call" do
5
5
  let(:obj) { Item.new }
@@ -30,6 +30,7 @@ module Ddr::Models
30
30
 
31
31
  describe "when the object does not have an admin set" do
32
32
  it "returns nil" do
33
+ expect(described_class).to receive(:find_by_code).and_call_original
33
34
  expect(described_class.call(obj)).to be_nil
34
35
  end
35
36
  end
@@ -5,5 +5,6 @@ RSpec.describe Attachment, type: :model, attachments: true do
5
5
  it_behaves_like "it has an association", :belongs_to, :attached_to, :is_attached_to, "ActiveFedora::Base"
6
6
  it_behaves_like "a non-collection model"
7
7
  it_behaves_like "an unpublishable object"
8
+ it_behaves_like "an object that cannot be streamable"
8
9
 
9
10
  end
@@ -1,22 +1,19 @@
1
- require 'spec_helper'
2
-
3
1
  RSpec.describe Collection, type: :model do
4
2
 
5
- subject { described_class.new(title: ["Test Collection"]) }
3
+ subject { described_class.new(title: ["Test Collection"], admin_set: "foo") }
6
4
 
7
5
  it_behaves_like "a DDR model"
8
6
  it_behaves_like "it has an association", :has_many, :children, :is_member_of_collection, "Item"
9
7
  it_behaves_like "it has an association", :has_many, :targets, :is_external_target_for, "Target"
10
8
  it_behaves_like "a publishable object"
9
+ it_behaves_like "an object that cannot be streamable"
11
10
 
12
11
  describe "admin set" do
13
- let(:admin_set) { Ddr::Models::AdminSet.new(code: "foobar", title: "FooBar") }
14
12
  before do
15
- allow(Ddr::Models::AdminSet).to receive(:find_by_code).with("foobar") { admin_set }
16
- subject.admin_set = "foobar"
13
+ subject.admin_set = "foo"
17
14
  end
18
15
  it "indexes the admin set title" do
19
- expect(subject.to_solr[Ddr::Index::Fields::ADMIN_SET_TITLE]).to eq("FooBar")
16
+ expect(subject.to_solr[Ddr::Index::Fields::ADMIN_SET_TITLE]).to eq("Foo Admin Set")
20
17
  end
21
18
  end
22
19
 
@@ -7,6 +7,7 @@ RSpec.describe Component, type: :model, components: true do
7
7
  it_behaves_like "a non-collection model"
8
8
  it_behaves_like "a potentially publishable object"
9
9
  it_behaves_like "an object that can have an intermediate file"
10
+ it_behaves_like "an object that can be streamable"
10
11
 
11
12
  describe "indexing" do
12
13
  subject { FactoryGirl.build(:component) }
@@ -50,18 +51,32 @@ RSpec.describe Component, type: :model, components: true do
50
51
  end
51
52
  end
52
53
  describe "service file" do
53
- describe "with multires image" do
54
+ let(:service_files) { struct.uses[Ddr::Models::Structure::USE_SERVICE_FILE].map(&:href) }
55
+ describe "with multires image but not streamable media" do
56
+ before { allow(subject).to receive(:has_multires_image?) { true } }
57
+ it "has the correct structure file" do
58
+ expect(service_files).to contain_exactly(Ddr::Datastreams::MULTIRES_IMAGE)
59
+ end
60
+ end
61
+ describe "with streamable media but not multires image" do
62
+ before { allow(subject).to receive(:streamable?) { true } }
63
+ it "has the correct structure file" do
64
+ expect(service_files).to contain_exactly(Ddr::Datastreams::STREAMABLE_MEDIA)
65
+ end
66
+ end
67
+ describe "with both multires image and streamable media" do
54
68
  before do
55
69
  allow(subject).to receive(:has_multires_image?) { true }
70
+ allow(subject).to receive(:streamable?) { true }
56
71
  end
57
72
  it "has the correct structure file" do
58
- expect(struct.uses[Ddr::Models::Structure::USE_SERVICE_FILE].first.href)
59
- .to eq(Ddr::Datastreams::MULTIRES_IMAGE)
73
+ expect(service_files).to contain_exactly(Ddr::Datastreams::MULTIRES_IMAGE,
74
+ Ddr::Datastreams::STREAMABLE_MEDIA)
60
75
  end
61
76
  end
62
- describe "without multires image" do
77
+ describe "with neither multires image nor streamable media" do
63
78
  it "has the correct structure file" do
64
- expect(struct.uses[Ddr::Models::Structure::USE_SERVICE_FILE].first.href).to eq(Ddr::Datastreams::CONTENT)
79
+ expect(service_files).to contain_exactly(Ddr::Datastreams::CONTENT)
65
80
  end
66
81
  end
67
82
  end
@@ -33,7 +33,6 @@ module Ddr::Models
33
33
  end
34
34
  it "should index the JSON representation of the structures" do
35
35
  indexing = item.to_solr
36
- expect(indexing[Ddr::Index::Fields::STRUCT]).to eq(expected_json)
37
36
  expect(indexing[Ddr::Index::Fields::STRUCTURE]).to eq(expected_json)
38
37
  end
39
38
  describe "structure source" do
@@ -13,6 +13,8 @@ module Ddr::Models
13
13
 
14
14
  before do
15
15
  obj.adminMetadata.doi << "http://doi.org/10.1000/182"
16
+ obj.affiliation << "Talk to me in the back alley."
17
+ obj.aleph_id = "lkheajklfwbsef"
16
18
  obj.aspace_id = "aspace_dccea43034e1b8261e14cf999e86449d"
17
19
  obj.display_format = "Image"
18
20
  obj.ingested_by = "foo@bar.com"
@@ -52,47 +54,53 @@ module Ddr::Models
52
54
  obj.set_desc_metadata_values(:volume, "100")
53
55
  end
54
56
 
55
- its([Indexing::ACCESS_ROLE]) { is_expected.to eq(obj.roles.to_json) }
56
- its([Indexing::ARRANGER_FACET]) { is_expected.to eq(["Arranger Value"]) }
57
- its([Indexing::ASPACE_ID]) { is_expected.to eq("aspace_dccea43034e1b8261e14cf999e86449d") }
58
- its([Indexing::CATEGORY_FACET]) { is_expected.to eq(["Category Value"]) }
59
- its([Indexing::COMPANY_FACET]) { is_expected.to eq(["Company Value"]) }
60
- its([Indexing::COMPOSER_FACET]) { is_expected.to eq(["Composer Value"]) }
61
- its([Indexing::DC_IS_PART_OF]) { is_expected.to eq(["RL10059CS1010"])}
62
- its([Indexing::DISPLAY_FORMAT]) { is_expected.to eq("Image") }
63
- its([Indexing::DOI]) { is_expected.to eq(["http://doi.org/10.1000/182"]) }
64
- its([Indexing::ENGRAVER_FACET]) { is_expected.to eq(["Engraver Value"]) }
65
- its([Indexing::FOLDER_FACET]) { is_expected.to eq(["Folder Value"]) }
66
- its([Indexing::GENRE_FACET]) { is_expected.to eq(["Genre Value"]) }
67
- its([Indexing::ILLUSTRATED_FACET]) { is_expected.to eq(["Illustrated Value"]) }
68
- its([Indexing::ILLUSTRATOR_FACET]) { is_expected.to eq(["Illustrator Value"]) }
69
- its([Indexing::INGESTED_BY]) { is_expected.to eq("foo@bar.com") }
70
- its([Indexing::INGESTION_DATE]) { is_expected.to eq("2017-01-13T18:55:29Z") }
71
- its([Indexing::INSTRUMENTATION_FACET]) { is_expected.to eq(["Instrumentation Value"]) }
72
- its([Indexing::INTERVIEWER_NAME_FACET]) { is_expected.to eq(["Interviewer Name Value"]) }
73
- its([Indexing::IS_FORMAT_OF]) { is_expected.to eq(["ark:/99999/fk4aaa"]) }
74
- its([Indexing::LICENSE]) { is_expected.to eq("cc-by-nc-nd-40") }
75
- its([Indexing::LITHOGRAPHER_FACET]) { is_expected.to eq(["Lithographer Value"]) }
76
- its([Indexing::LOCAL_ID]) { is_expected.to eq("foo") }
77
- its([Indexing::LYRICIST_FACET]) { is_expected.to eq(["Lyricist Value"]) }
78
- its([Indexing::MEDIUM_FACET]) { is_expected.to eq(["Medium Value"]) }
79
- its([Indexing::PERFORMER_FACET]) { is_expected.to eq(["Performer Value"]) }
80
- its([Indexing::PERMANENT_ID]) { is_expected.to eq("ark:/99999/fk4zzz") }
81
- its([Indexing::PERMANENT_URL]) { is_expected.to eq("http://id.library.duke.edu/ark:/99999/fk4zzz") }
82
- its([Indexing::PLACEMENT_COMPANY_FACET]) { is_expected.to eq(["Placement Company Value"]) }
83
- its([Indexing::POLICY_ROLE]) { is_expected.to contain_exactly(role2.agent.first, role3.agent.first, role4.agent.first) }
84
- its([Indexing::PRODUCER_FACET]) { is_expected.to eq(["Producer Value"]) }
85
- its([Indexing::PRODUCT_FACET]) { is_expected.to eq(["Product Value"]) }
86
- its([Indexing::PUBLICATION_FACET]) { is_expected.to eq(["Publication Value"]) }
87
- its([Indexing::RESOURCE_ROLE]) { is_expected.to contain_exactly(role1.agent.first) }
88
- its([Indexing::RIGHTS_NOTE]) { is_expected.to eq(["Public domain"]) }
89
- its([Indexing::ROLL_NUMBER_FACET]) { is_expected.to eq(["10"]) }
90
- its([Indexing::SETTING_FACET]) { is_expected.to eq(["Setting Value"]) }
91
- its([Indexing::SUBSERIES_FACET]) { is_expected.to eq(["Subseries Value"]) }
92
- its([Indexing::TEMPORAL_FACET]) { is_expected.to eq(["Temporal Value"]) }
93
- its([Indexing::TONE_FACET]) { is_expected.to eq(["Tone Value"]) }
94
- its([Indexing::VOLUME_FACET]) { is_expected.to eq(["100"]) }
95
-
57
+ specify {
58
+ expect(subject[Indexing::ACCESS_ROLE]).to eq(obj.roles.to_json)
59
+ expect(subject[Indexing::ADMIN_SET_TITLE]).to be_nil
60
+ expect(subject[Indexing::AFFILIATION]).to eq(["Talk to me in the back alley."])
61
+ expect(subject[Indexing::AFFILIATION_FACET]).to eq(["Talk to me in the back alley."])
62
+ expect(subject[Indexing::ALEPH_ID]).to eq "lkheajklfwbsef"
63
+ expect(subject[Indexing::ARRANGER_FACET]).to eq(["Arranger Value"])
64
+ expect(subject[Indexing::ASPACE_ID]).to eq("aspace_dccea43034e1b8261e14cf999e86449d")
65
+ expect(subject[Indexing::CATEGORY_FACET]).to eq(["Category Value"])
66
+ expect(subject[Indexing::COMPANY_FACET]).to eq(["Company Value"])
67
+ expect(subject[Indexing::COMPOSER_FACET]).to eq(["Composer Value"])
68
+ expect(subject[Indexing::DC_IS_PART_OF]).to eq(["RL10059CS1010"])
69
+ expect(subject[Indexing::DISPLAY_FORMAT]).to eq("Image")
70
+ expect(subject[Indexing::DOI]).to eq(["http://doi.org/10.1000/182"])
71
+ expect(subject[Indexing::ENGRAVER_FACET]).to eq(["Engraver Value"])
72
+ expect(subject[Indexing::FOLDER_FACET]).to eq(["Folder Value"])
73
+ expect(subject[Indexing::GENRE_FACET]).to eq(["Genre Value"])
74
+ expect(subject[Indexing::ILLUSTRATED_FACET]).to eq(["Illustrated Value"])
75
+ expect(subject[Indexing::ILLUSTRATOR_FACET]).to eq(["Illustrator Value"])
76
+ expect(subject[Indexing::INGESTED_BY]).to eq("foo@bar.com")
77
+ expect(subject[Indexing::INGESTION_DATE]).to eq("2017-01-13T18:55:29Z")
78
+ expect(subject[Indexing::INSTRUMENTATION_FACET]).to eq(["Instrumentation Value"])
79
+ expect(subject[Indexing::INTERVIEWER_NAME_FACET]).to eq(["Interviewer Name Value"])
80
+ expect(subject[Indexing::IS_FORMAT_OF]).to eq(["ark:/99999/fk4aaa"])
81
+ expect(subject[Indexing::LICENSE]).to eq("cc-by-nc-nd-40")
82
+ expect(subject[Indexing::LITHOGRAPHER_FACET]).to eq(["Lithographer Value"])
83
+ expect(subject[Indexing::LOCAL_ID]).to eq("foo")
84
+ expect(subject[Indexing::LYRICIST_FACET]).to eq(["Lyricist Value"])
85
+ expect(subject[Indexing::MEDIUM_FACET]).to eq(["Medium Value"])
86
+ expect(subject[Indexing::PERFORMER_FACET]).to eq(["Performer Value"])
87
+ expect(subject[Indexing::PERMANENT_ID]).to eq("ark:/99999/fk4zzz")
88
+ expect(subject[Indexing::PERMANENT_URL]).to eq("http://id.library.duke.edu/ark:/99999/fk4zzz")
89
+ expect(subject[Indexing::PLACEMENT_COMPANY_FACET]).to eq(["Placement Company Value"])
90
+ expect(subject[Indexing::POLICY_ROLE]).to contain_exactly(role2.agent.first, role3.agent.first, role4.agent.first)
91
+ expect(subject[Indexing::PRODUCER_FACET]).to eq(["Producer Value"])
92
+ expect(subject[Indexing::PRODUCT_FACET]).to eq(["Product Value"])
93
+ expect(subject[Indexing::PUBLICATION_FACET]).to eq(["Publication Value"])
94
+ expect(subject[Indexing::RESOURCE_ROLE]).to contain_exactly(role1.agent.first)
95
+ expect(subject[Indexing::RIGHTS_NOTE]).to eq(["Public domain"])
96
+ expect(subject[Indexing::ROLL_NUMBER_FACET]).to eq(["10"])
97
+ expect(subject[Indexing::SETTING_FACET]).to eq(["Setting Value"])
98
+ expect(subject[Indexing::STREAMABLE_MEDIA_TYPE]).to be_nil
99
+ expect(subject[Indexing::SUBSERIES_FACET]).to eq(["Subseries Value"])
100
+ expect(subject[Indexing::TEMPORAL_FACET]).to eq(["Temporal Value"])
101
+ expect(subject[Indexing::TONE_FACET]).to eq(["Tone Value"])
102
+ expect(subject[Indexing::VOLUME_FACET]).to eq(["100"])
103
+ }
96
104
  end
97
105
 
98
106
  describe "content-bearing object indexing" do
@@ -102,9 +110,48 @@ module Ddr::Models
102
110
  allow(obj.content).to receive(:createDate) { create_date }
103
111
  }
104
112
 
105
- its([Indexing::CONTENT_CREATE_DATE]) { is_expected.to eq "2016-01-22T21:50:33Z" }
106
- its([Indexing::ATTACHED_FILES_HAVING_CONTENT]) {
107
- is_expected.to contain_exactly("content", "RELS-EXT", "descMetadata", "adminMetadata")
113
+ specify {
114
+ expect(subject[Indexing::CONTENT_CREATE_DATE]).to eq "2016-01-22T21:50:33Z"
115
+ expect(subject[Indexing::ATTACHED_FILES_HAVING_CONTENT]).to contain_exactly("content", "RELS-EXT", "descMetadata", "adminMetadata")
116
+ expect(subject[Indexing::CONTENT_SIZE]).to eq 230714
117
+ expect(subject[Indexing::CONTENT_SIZE_HUMAN]).to eq "225 KB"
118
+ expect(subject[Indexing::MEDIA_TYPE]).to eq "image/tiff"
119
+ expect(subject[Indexing::MEDIA_MAJOR_TYPE]).to eq "image"
120
+ expect(subject[Indexing::MEDIA_SUB_TYPE]).to eq "tiff"
121
+ }
122
+
123
+ describe "streamable object indexing" do
124
+ before {
125
+ obj.add_file(fixture_file_upload('bird.jpg', 'image/jpeg'), 'streamableMedia')
126
+ obj.save!
127
+ }
128
+ specify {
129
+ expect(subject[Indexing::STREAMABLE_MEDIA_TYPE]).to eq "image/jpeg"
130
+ }
131
+ end
132
+ end
133
+
134
+ describe "admin set title" do
135
+ subject { FactoryGirl.build(:item) }
136
+ let(:coll) { FactoryGirl.create(:collection) }
137
+ before do
138
+ subject.parent = coll
139
+ subject.admin_policy = coll
140
+ end
141
+ specify {
142
+ expect(subject.index_fields[Indexing::ADMIN_SET_TITLE]).to eq "Foo Admin Set"
143
+ }
144
+ end
145
+
146
+ describe "language name" do
147
+ subject { FactoryGirl.build(:item) }
148
+ before do
149
+ subject.language = ["cym", "Not a Code"]
150
+ subject.save!
151
+ end
152
+ specify {
153
+ expect(subject.index_fields[Indexing::LANGUAGE_FACET]).to eq ["Welsh", "Not a Code"]
154
+ expect(subject.index_fields[Indexing::LANGUAGE_NAME]).to eq ["Welsh", "Not a Code"]
108
155
  }
109
156
  end
110
157