ddr-models 2.0.1 → 2.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -17
- data/app/models/collection.rb +1 -35
- data/ddr-models.gemspec +2 -1
- data/lib/ddr/actions.rb +1 -0
- data/lib/ddr/actions/virus_check.rb +28 -0
- data/lib/ddr/auth.rb +4 -0
- data/lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb +7 -5
- data/lib/ddr/auth/grouper_gateway.rb +9 -1
- data/lib/ddr/auth/permissions.rb +2 -1
- data/lib/ddr/auth/role_based_access_controls_enforcement.rb +5 -5
- data/lib/ddr/auth/roles/role_types.rb +2 -1
- data/lib/ddr/datastreams.rb +2 -2
- data/lib/ddr/datastreams/administrative_metadata_datastream.rb +27 -14
- data/lib/ddr/datastreams/datastream_behavior.rb +13 -0
- data/lib/ddr/datastreams/fits_datastream.rb +88 -0
- data/lib/ddr/derivatives/png_generator.rb +2 -0
- data/lib/ddr/derivatives/ptif_generator.rb +2 -0
- data/lib/ddr/events/fixity_check_event.rb +2 -2
- data/lib/ddr/events/virus_check_event.rb +2 -14
- data/lib/ddr/index.rb +29 -0
- data/lib/ddr/index/abstract_query_result.rb +23 -0
- data/lib/ddr/index/connection.rb +17 -0
- data/lib/ddr/index/csv_query_result.rb +61 -0
- data/lib/ddr/index/document_builder.rb +9 -0
- data/lib/ddr/index/field.rb +23 -0
- data/lib/ddr/index/fields.rb +83 -0
- data/lib/ddr/index/filter.rb +48 -0
- data/lib/ddr/index/filters.rb +19 -0
- data/lib/ddr/index/legacy_license_fields.rb +14 -0
- data/lib/ddr/index/query.rb +35 -0
- data/lib/ddr/index/query_builder.rb +74 -0
- data/lib/ddr/index/query_clause.rb +52 -0
- data/lib/ddr/index/query_result.rb +70 -0
- data/lib/ddr/index/query_value.rb +16 -0
- data/lib/ddr/index/response.rb +13 -0
- data/lib/ddr/index/unique_key_field.rb +12 -0
- data/lib/ddr/index_fields.rb +7 -53
- data/lib/ddr/jobs.rb +1 -1
- data/lib/ddr/jobs/fits_file_characterization.rb +51 -0
- data/lib/ddr/managers.rb +1 -0
- data/lib/ddr/managers/technical_metadata_manager.rb +104 -0
- data/lib/ddr/models.rb +39 -23
- data/lib/ddr/models/base.rb +0 -2
- data/lib/ddr/models/describable.rb +1 -1
- data/lib/ddr/models/effective_license.rb +9 -0
- data/lib/ddr/models/engine.rb +13 -0
- data/lib/ddr/models/file_management.rb +157 -160
- data/lib/ddr/models/governable.rb +0 -4
- data/lib/ddr/models/has_admin_metadata.rb +80 -72
- data/lib/ddr/models/has_children.rb +1 -1
- data/lib/ddr/models/has_content.rb +18 -0
- data/lib/ddr/models/has_struct_metadata.rb +5 -1
- data/lib/ddr/models/indexing.rb +32 -20
- data/lib/ddr/models/inherited_license.rb +13 -0
- data/lib/ddr/models/license.rb +38 -0
- data/lib/ddr/models/solr_document.rb +195 -211
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/models/year_facet.rb +154 -0
- data/lib/ddr/utils.rb +13 -1
- data/lib/ddr/vocab/roles.rb +0 -10
- data/spec/controllers/including_role_based_access_controls_enforcement_spec.rb +4 -4
- data/spec/datastreams/fits_datastream_spec.rb +84 -0
- data/spec/fixtures/fits/document.xml +65 -0
- data/spec/fixtures/fits/image.xml +59 -0
- data/spec/index/filter_spec.rb +47 -0
- data/spec/index/filters_spec.rb +17 -0
- data/spec/index/query_spec.rb +19 -0
- data/spec/jobs/fits_file_characterization_spec.rb +52 -0
- data/spec/managers/technical_metadata_manager_spec.rb +140 -0
- data/spec/models/active_fedora_datastream_spec.rb +44 -0
- data/spec/models/collection_spec.rb +7 -12
- data/spec/models/component_spec.rb +3 -6
- data/spec/models/effective_license_spec.rb +49 -0
- data/spec/models/has_admin_metadata_spec.rb +143 -194
- data/spec/models/has_struct_metadata_spec.rb +2 -2
- data/spec/models/indexing_spec.rb +40 -0
- data/spec/models/solr_document_spec.rb +96 -37
- data/spec/models/year_facet_spec.rb +65 -0
- data/spec/spec_helper.rb +1 -7
- data/spec/support/shared_examples_for_ddr_models.rb +0 -2
- data/spec/support/shared_examples_for_has_content.rb +37 -3
- metadata +79 -32
- data/lib/ddr/datastreams/properties_datastream.rb +0 -25
- data/lib/ddr/jobs/migrate_legacy_authorization.rb +0 -23
- data/lib/ddr/models/has_properties.rb +0 -15
- data/lib/ddr/models/licensable.rb +0 -28
- data/spec/auth/legacy_authorization_spec.rb +0 -94
- data/spec/auth/legacy_roles_spec.rb +0 -32
- data/spec/jobs/migrate_legacy_authorization_spec.rb +0 -43
- data/spec/support/shared_examples_for_has_properties.rb +0 -5
- data/spec/support/shared_examples_for_licensable.rb +0 -15
@@ -38,8 +38,8 @@ module Ddr
|
|
38
38
|
before { item.datastreams[Ddr::Datastreams::STRUCT_METADATA].content = multiple_struct_maps_structure }
|
39
39
|
it "should index the JSON representation of the structure" do
|
40
40
|
indexing = item.to_solr
|
41
|
-
expect(indexing.keys).to include(Ddr::
|
42
|
-
expect(indexing[Ddr::
|
41
|
+
expect(indexing.keys).to include(Ddr::Index::Fields::STRUCT_MAPS)
|
42
|
+
expect(indexing[Ddr::Index::Fields::STRUCT_MAPS]).to eq(expected_json)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Ddr::Models
|
2
|
+
RSpec.describe Indexing do
|
3
|
+
|
4
|
+
let(:obj) { FactoryGirl.build(:item) }
|
5
|
+
|
6
|
+
let(:role1) { FactoryGirl.build(:role, :curator, :person, :resource) }
|
7
|
+
let(:role2) { FactoryGirl.build(:role, :curator, :person, :policy) }
|
8
|
+
let(:role3) { FactoryGirl.build(:role, :editor, :group, :policy) }
|
9
|
+
let(:role4) { FactoryGirl.build(:role, :editor, :person, :policy) }
|
10
|
+
|
11
|
+
subject { obj.index_fields }
|
12
|
+
|
13
|
+
before do
|
14
|
+
obj.license = "cc-by-nc-nd-40"
|
15
|
+
obj.rightsMetadata.license.title = ["License Title"]
|
16
|
+
obj.rightsMetadata.license.description = ["License Description"]
|
17
|
+
obj.rightsMetadata.license.url = ["http://library.duke.edu"]
|
18
|
+
obj.local_id = "foo"
|
19
|
+
obj.adminMetadata.doi << "http://doi.org/10.1000/182"
|
20
|
+
obj.permanent_id = "ark:/99999/fk4zzz"
|
21
|
+
obj.permanent_url = "http://id.library.duke.edu/ark:/99999/fk4zzz"
|
22
|
+
obj.display_format = "Image"
|
23
|
+
obj.roles.grant role1, role2, role3, role4
|
24
|
+
end
|
25
|
+
|
26
|
+
its([Indexing::LICENSE]) { is_expected.to eq("cc-by-nc-nd-40") }
|
27
|
+
its([Indexing::LICENSE_TITLE]) { is_expected.to eq("License Title") }
|
28
|
+
its([Indexing::LICENSE_DESCRIPTION]) { is_expected.to eq("License Description") }
|
29
|
+
its([Indexing::LICENSE_URL]) { is_expected.to eq("http://library.duke.edu") }
|
30
|
+
its([Indexing::LOCAL_ID]) { is_expected.to eq("foo") }
|
31
|
+
its([Indexing::DOI]) { is_expected.to eq(["http://doi.org/10.1000/182"]) }
|
32
|
+
its([Indexing::PERMANENT_ID]) { is_expected.to eq("ark:/99999/fk4zzz") }
|
33
|
+
its([Indexing::PERMANENT_URL]) { is_expected.to eq("http://id.library.duke.edu/ark:/99999/fk4zzz") }
|
34
|
+
its([Indexing::DISPLAY_FORMAT]) { is_expected.to eq("Image") }
|
35
|
+
its([Indexing::ACCESS_ROLE]) { is_expected.to eq(obj.roles.to_json) }
|
36
|
+
its([Indexing::POLICY_ROLE]) { is_expected.to contain_exactly(role2.agent.first, role3.agent.first, role4.agent.first) }
|
37
|
+
its([Indexing::RESOURCE_ROLE]) { is_expected.to contain_exactly(role1.agent.first) }
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -2,32 +2,48 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe SolrDocument, type: :model, contacts: true do
|
4
4
|
|
5
|
-
describe "
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
describe "index field method access" do
|
6
|
+
describe "when there is an index field" do
|
7
|
+
before { Ddr::Index::Fields.const_set(:FOO_BAR, "foo_bar_ssim") }
|
8
|
+
after { Ddr::Index::Fields.send(:remove_const, :FOO_BAR) }
|
9
|
+
describe "and the field is not present" do
|
10
|
+
its(:foo_bar) { is_expected.to be_nil }
|
11
|
+
end
|
12
|
+
describe "and the field is a single value (not an array)" do
|
13
|
+
before { subject[Ddr::Index::Fields::FOO_BAR] = "foo" }
|
14
|
+
its(:foo_bar) { is_expected.to eq("foo") }
|
15
|
+
end
|
16
|
+
describe "and the field value is an array" do
|
17
|
+
before { subject[Ddr::Index::Fields::FOO_BAR] = ["foo", "bar"] }
|
18
|
+
its(:foo_bar) { is_expected.to eq("foo, bar") }
|
19
|
+
end
|
10
20
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
21
|
+
describe "when there is no index field" do
|
22
|
+
it "should raise an exception" do
|
23
|
+
expect { subject.foo_bar }.to raise_error(NoMethodError)
|
24
|
+
end
|
15
25
|
end
|
16
26
|
end
|
17
27
|
|
18
|
-
describe "#
|
19
|
-
|
20
|
-
|
28
|
+
describe "#admin_policy_uri" do
|
29
|
+
describe "when is_governed_by is not set" do
|
30
|
+
its(:admin_policy_uri) { is_expected.to be_nil }
|
31
|
+
end
|
32
|
+
describe "when is_governed_by is set" do
|
33
|
+
before { subject[Ddr::Index::Fields::IS_GOVERNED_BY] = "info:fedora/test:1" }
|
34
|
+
its(:admin_policy_uri) { should eq("info:fedora/test:1") }
|
35
|
+
end
|
21
36
|
end
|
22
37
|
|
23
38
|
describe "#admin_policy" do
|
24
|
-
describe "when there is not admin policy relationship" do
|
39
|
+
describe "when there is not an admin policy relationship" do
|
40
|
+
before { allow(subject).to receive(:admin_policy_pid) { nil } }
|
25
41
|
its(:admin_policy) { should be_nil }
|
26
42
|
end
|
27
43
|
describe "where there is an admin policy relationship" do
|
28
44
|
let(:admin_policy) { FactoryGirl.create(:collection) }
|
29
45
|
before do
|
30
|
-
subject[Ddr::
|
46
|
+
subject[Ddr::Index::Fields::IS_GOVERNED_BY] = [ admin_policy.internal_uri ]
|
31
47
|
end
|
32
48
|
it "should get the admin policy document" do
|
33
49
|
expect(subject.admin_policy.id).to eq(admin_policy.id)
|
@@ -35,19 +51,39 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
35
51
|
end
|
36
52
|
end
|
37
53
|
|
38
|
-
describe "#
|
39
|
-
|
40
|
-
|
54
|
+
describe "#parent_uri" do
|
55
|
+
describe "when is_part_of is present" do
|
56
|
+
before { subject[Ddr::Index::Fields::IS_PART_OF] = "info:fedora/test:1" }
|
57
|
+
its(:parent_uri) { is_expected.to eq("info:fedora/test:1") }
|
58
|
+
end
|
59
|
+
describe "when is_part_of is not present" do
|
60
|
+
describe "when is_member_of_collection is present" do
|
61
|
+
before { subject[Ddr::Index::Fields::IS_MEMBER_OF_COLLECTION] = "info:fedora/test:1" }
|
62
|
+
its(:parent_uri) { is_expected.to eq("info:fedora/test:1") }
|
63
|
+
end
|
64
|
+
describe "when is_member_of_collection is not present" do
|
65
|
+
its(:parent_uri) { is_expected.to be_nil }
|
66
|
+
end
|
67
|
+
end
|
41
68
|
end
|
42
69
|
|
43
|
-
describe "#
|
44
|
-
|
45
|
-
|
70
|
+
describe "#parent" do
|
71
|
+
describe "when there is a parent URI" do
|
72
|
+
let(:doc) { described_class.new({"id"=>"test:1"}) }
|
73
|
+
before do
|
74
|
+
allow(subject).to receive(:parent_uri) { "info:fedora/test:1" }
|
75
|
+
allow(described_class).to receive(:find).with("info:fedora/test:1") { doc }
|
76
|
+
end
|
77
|
+
its(:parent) { is_expected.to eq(doc) }
|
78
|
+
end
|
79
|
+
describe "when there is no parent URI" do
|
80
|
+
its(:parent) { is_expected.to be_nil }
|
81
|
+
end
|
46
82
|
end
|
47
83
|
|
48
84
|
describe "#roles" do
|
49
85
|
let(:json) { "[{\"role_type\":[\"Editor\"],\"agent\":[\"Editors\"],\"scope\":[\"policy\"]},{\"role_type\":[\"Contributor\"],\"agent\":[\"bob@example.com\"],\"scope\":[\"resource\"]}]" }
|
50
|
-
before { subject[Ddr::
|
86
|
+
before { subject[Ddr::Index::Fields::ACCESS_ROLE] = json }
|
51
87
|
it "should deserialize the roles from JSON" do
|
52
88
|
expect(subject.roles.to_a)
|
53
89
|
.to eq([Ddr::Auth::Roles::Role.build(type: "Editor", agent: "Editors", scope: "policy"),
|
@@ -55,11 +91,6 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
55
91
|
end
|
56
92
|
end
|
57
93
|
|
58
|
-
describe "#display_format" do
|
59
|
-
before { subject[Ddr::IndexFields::DISPLAY_FORMAT] = "Image" }
|
60
|
-
its(:display_format) { should eq("Image") }
|
61
|
-
end
|
62
|
-
|
63
94
|
describe "#struct_maps" do
|
64
95
|
context "no indexed struct maps" do
|
65
96
|
it "should return an empty hash" do
|
@@ -67,7 +98,7 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
67
98
|
end
|
68
99
|
end
|
69
100
|
context "indexed struct maps" do
|
70
|
-
before { subject[Ddr::
|
101
|
+
before { subject[Ddr::Index::Fields::STRUCT_MAPS] = multiple_struct_maps_structure_to_json }
|
71
102
|
it "should return a hash of the struct maps" do
|
72
103
|
expect(subject.struct_maps).to eq(JSON.parse(multiple_struct_maps_structure_to_json))
|
73
104
|
end
|
@@ -81,7 +112,7 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
81
112
|
end
|
82
113
|
end
|
83
114
|
context "indexed struct maps" do
|
84
|
-
before { subject[Ddr::
|
115
|
+
before { subject[Ddr::Index::Fields::STRUCT_MAPS] = multiple_struct_maps_structure_to_json }
|
85
116
|
context "requested struct map is indexed" do
|
86
117
|
it "should return the struct map" do
|
87
118
|
expect(subject.struct_map('default')).to eq(JSON.parse(multiple_struct_maps_structure_to_json)["default"])
|
@@ -95,11 +126,6 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
95
126
|
end
|
96
127
|
end
|
97
128
|
|
98
|
-
describe "#display_format" do
|
99
|
-
before { subject[Ddr::IndexFields::DISPLAY_FORMAT] = "Image" }
|
100
|
-
its(:display_format) { should eq("Image") }
|
101
|
-
end
|
102
|
-
|
103
129
|
describe "contacts" do
|
104
130
|
before do
|
105
131
|
allow(YAML).to receive(:load_file) { { 'xa' => { 'name' => 'Contact A', 'short_name' => 'A' },
|
@@ -108,17 +134,16 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
108
134
|
end
|
109
135
|
describe "#research_help" do
|
110
136
|
context "object has research help contact" do
|
111
|
-
before { subject[Ddr::
|
137
|
+
before { subject[Ddr::Index::Fields::RESEARCH_HELP_CONTACT] = 'yb' }
|
112
138
|
it "should return the object's research help contact" do
|
113
139
|
expect(subject.research_help.slug).to eq('yb')
|
114
140
|
end
|
115
141
|
end
|
116
142
|
context "object does not have research help contact" do
|
117
143
|
context "collection has research help contact" do
|
118
|
-
let(:
|
144
|
+
let(:admin_policy) { described_class.new({Ddr::Index::Fields::RESEARCH_HELP_CONTACT=>["xa"]}) }
|
119
145
|
before do
|
120
|
-
allow(subject).to receive(:
|
121
|
-
allow(ActiveFedora::SolrService).to receive(:query).and_return(apo_solr_response)
|
146
|
+
allow(subject).to receive(:admin_policy) { admin_policy }
|
122
147
|
end
|
123
148
|
it "should return the collection's research help contact" do
|
124
149
|
expect(subject.research_help.slug).to eq("xa")
|
@@ -133,4 +158,38 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
133
158
|
end
|
134
159
|
end
|
135
160
|
|
161
|
+
describe "structural metadata" do
|
162
|
+
describe "#multires_image_file_paths" do
|
163
|
+
context "no structural metadata" do
|
164
|
+
its(:multires_image_file_paths) { is_expected.to match([]) }
|
165
|
+
end
|
166
|
+
context "structural metadata" do
|
167
|
+
let(:struct_map) do
|
168
|
+
{"type"=>"default", "divs"=>
|
169
|
+
[{"id"=>"viccb010010010", "label"=>"1", "order"=>"1", "type"=>"Image", "fptrs"=>["test:5"], "divs"=>[]},
|
170
|
+
{"id"=>"viccb010020010", "label"=>"2", "order"=>"2", "type"=>"Image", "fptrs"=>["test:6"], "divs"=>[]},
|
171
|
+
{"id"=>"viccb010030010", "label"=>"3", "order"=>"3", "type"=>"Image", "fptrs"=>["test:7"], "divs"=>[]}]
|
172
|
+
}
|
173
|
+
end
|
174
|
+
before { allow(subject).to receive(:struct_map) { struct_map } }
|
175
|
+
context "no structural objects with multi-res images" do
|
176
|
+
before do
|
177
|
+
allow(SolrDocument).to receive(:find).with('test:5') { double(multires_image_file_path: nil) }
|
178
|
+
allow(SolrDocument).to receive(:find).with('test:6') { double(multires_image_file_path: nil) }
|
179
|
+
allow(SolrDocument).to receive(:find).with('test:7') { double(multires_image_file_path: nil) }
|
180
|
+
end
|
181
|
+
its(:multires_image_file_paths) { is_expected.to match([]) }
|
182
|
+
end
|
183
|
+
context "structural objects with multi-res images" do
|
184
|
+
let(:expected_result) { [ "/path/file1.ptif", "/path/file2.ptif" ] }
|
185
|
+
before do
|
186
|
+
allow(SolrDocument).to receive(:find).with('test:5') { double(multires_image_file_path: "/path/file1.ptif") }
|
187
|
+
allow(SolrDocument).to receive(:find).with('test:6') { double(multires_image_file_path: nil) }
|
188
|
+
allow(SolrDocument).to receive(:find).with('test:7') { double(multires_image_file_path: "/path/file2.ptif") }
|
189
|
+
end
|
190
|
+
its(:multires_image_file_paths) { is_expected.to match(expected_result) }
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
136
195
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Ddr::Models
|
2
|
+
RSpec.describe YearFacet do
|
3
|
+
|
4
|
+
subject { described_class.new(obj) }
|
5
|
+
let(:obj) { Item.new }
|
6
|
+
before { obj.date = [ date ] }
|
7
|
+
|
8
|
+
describe "splitting on semicolons" do
|
9
|
+
let(:date) { "1935; 1936; 1937; 1938" }
|
10
|
+
its(:values) { is_expected.to eq([1935, 1936, 1937, 1938]) }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "year range" do
|
14
|
+
%w( 1935-1940 1935/1940 ).each do |value|
|
15
|
+
describe value do
|
16
|
+
let(:date) { value }
|
17
|
+
its(:values) { is_expected.to eq((1935..1940).to_a) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "in decade" do
|
23
|
+
%w( 192x 192X 192? 192- 192-? ).each do |value|
|
24
|
+
describe value do
|
25
|
+
let(:date) { value }
|
26
|
+
its(:values) { is_expected.to eq((1920..1929).to_a) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "in century -- YYxx (19xx)" do
|
32
|
+
let(:date) { "19xx" }
|
33
|
+
its(:values) { is_expected.to eq((1900..1999).to_a) }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "decade" do
|
37
|
+
%w( 1920s 1920s? ).each do |value|
|
38
|
+
describe value do
|
39
|
+
let(:date) { value }
|
40
|
+
its(:values) { is_expected.to eq((1920..1929).to_a) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "year + month" do
|
46
|
+
%w( 2010-01 2010/01 ).each do |value|
|
47
|
+
describe value do
|
48
|
+
let(:date) { value }
|
49
|
+
its(:values) { is_expected.to eq([2010]) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "between" do
|
55
|
+
let(:date) { "Between 1965 and 1968" }
|
56
|
+
its(:values) { is_expected.to eq((1965..1968).to_a) }
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "year" do
|
60
|
+
let(:date) { "1965" }
|
61
|
+
its(:values) { is_expected.to eq([1965]) }
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -23,13 +23,6 @@ Dir[File.join(File.dirname(__FILE__), "support", "*.rb")].each { |f| require f }
|
|
23
23
|
|
24
24
|
DatabaseCleaner.strategy = :truncation
|
25
25
|
|
26
|
-
require "ddr-antivirus"
|
27
|
-
Ddr::Antivirus.configure do |config|
|
28
|
-
config.scanner_adapter = :null
|
29
|
-
require "logger"
|
30
|
-
config.logger = Logger.new(File::NULL)
|
31
|
-
end
|
32
|
-
|
33
26
|
RSpec.configure do |config|
|
34
27
|
|
35
28
|
config.include ActionDispatch::TestProcess
|
@@ -116,6 +109,7 @@ RSpec.configure do |config|
|
|
116
109
|
config.external_file_store = Dir.mktmpdir
|
117
110
|
config.multires_image_external_file_store = Dir.mktmpdir
|
118
111
|
config.external_file_subpath_pattern = "--"
|
112
|
+
config.fits_home = Dir.mktmpdir
|
119
113
|
end
|
120
114
|
end
|
121
115
|
|
@@ -2,9 +2,7 @@ RSpec.shared_examples "a DDR model" do
|
|
2
2
|
|
3
3
|
it_behaves_like "a describable object"
|
4
4
|
it_behaves_like "a governable object"
|
5
|
-
it_behaves_like "a licensable object"
|
6
5
|
it_behaves_like "an access controllable object"
|
7
|
-
it_behaves_like "an object that has properties"
|
8
6
|
it_behaves_like "an object that has a display title"
|
9
7
|
it_behaves_like "an object that has identifiers"
|
10
8
|
|
@@ -5,6 +5,8 @@ RSpec.shared_examples "an object that can have content" do
|
|
5
5
|
|
6
6
|
subject { described_class.new(title: [ "I Have Content!" ]) }
|
7
7
|
|
8
|
+
before { allow(Resque).to receive(:enqueue) }
|
9
|
+
|
8
10
|
it "should delegate :validate_checksum! to :content" do
|
9
11
|
checksum = "dea56f15b309e47b74fa24797f85245dda0ca3d274644a96804438bbd659555a"
|
10
12
|
expect(subject.content).to receive(:validate_checksum!).with(checksum, "SHA-256")
|
@@ -22,20 +24,20 @@ RSpec.shared_examples "an object that can have content" do
|
|
22
24
|
let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
|
23
25
|
before { subject.upload file }
|
24
26
|
it "should index the content ds control group" do
|
25
|
-
expect(subject.to_solr).to include(Ddr::
|
27
|
+
expect(subject.to_solr).to include(Ddr::Index::Fields::CONTENT_CONTROL_GROUP)
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
31
|
describe "extracted text" do
|
30
32
|
describe "when it is not present" do
|
31
33
|
its(:has_extracted_text?) { should be false }
|
32
|
-
its(:to_solr) { should_not include(Ddr::
|
34
|
+
its(:to_solr) { should_not include(Ddr::Index::Fields::EXTRACTED_TEXT) }
|
33
35
|
end
|
34
36
|
describe "when it is present" do
|
35
37
|
before { subject.extractedText.content = "This is my text. See Spot run." }
|
36
38
|
its(:has_extracted_text?) { should be true }
|
37
39
|
it "should be indexed" do
|
38
|
-
expect(subject.to_solr[Ddr::
|
40
|
+
expect(subject.to_solr[Ddr::Index::Fields::EXTRACTED_TEXT]).to eq("This is my text. See Spot run.")
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -71,6 +73,22 @@ RSpec.shared_examples "an object that can have content" do
|
|
71
73
|
expect(subject.derivatives).to receive(:update_derivatives)
|
72
74
|
subject.save
|
73
75
|
end
|
76
|
+
describe "file characterization" do
|
77
|
+
context "characterize files is false" do
|
78
|
+
before { allow(Ddr::Models).to receive(:characterize_files?) { false } }
|
79
|
+
it "should not enqueue a FITS file characterization job" do
|
80
|
+
expect(Resque).to_not receive(:enqueue).with(Ddr::Jobs::FitsFileCharacterization, instance_of(String))
|
81
|
+
subject.save
|
82
|
+
end
|
83
|
+
end
|
84
|
+
context "characterize files is true" do
|
85
|
+
before { allow(Ddr::Models).to receive(:characterize_files?) { true } }
|
86
|
+
it "should enqueue a FITS file characterization job" do
|
87
|
+
expect(Resque).to receive(:enqueue).with(Ddr::Jobs::FitsFileCharacterization, instance_of(String))
|
88
|
+
subject.save
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
74
92
|
end
|
75
93
|
|
76
94
|
context "and it's an existing object with content" do
|
@@ -80,6 +98,22 @@ RSpec.shared_examples "an object that can have content" do
|
|
80
98
|
expect(subject.derivatives).to receive(:update_derivatives)
|
81
99
|
subject.upload! file
|
82
100
|
end
|
101
|
+
describe "file characterization" do
|
102
|
+
context "characterize files is false" do
|
103
|
+
before { allow(Ddr::Models).to receive(:characterize_files?) { false } }
|
104
|
+
it "should not enqueue a FITS file characterization job" do
|
105
|
+
expect(Resque).to_not receive(:enqueue).with(Ddr::Jobs::FitsFileCharacterization, instance_of(String))
|
106
|
+
subject.upload! file
|
107
|
+
end
|
108
|
+
end
|
109
|
+
context "characterize files is true" do
|
110
|
+
before { allow(Ddr::Models).to receive(:characterize_files?) { true } }
|
111
|
+
it "should enqueue a FITS file characterization job" do
|
112
|
+
expect(Resque).to receive(:enqueue).with(Ddr::Jobs::FitsFileCharacterization, instance_of(String))
|
113
|
+
subject.upload! file
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
83
117
|
end
|
84
118
|
end
|
85
119
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddr-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Coble
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -67,20 +67,6 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0.5'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: ddr-antivirus
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 1.3.1
|
77
|
-
type: :runtime
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: 1.3.1
|
84
70
|
- !ruby/object:Gem::Dependency
|
85
71
|
name: devise
|
86
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,6 +185,34 @@ dependencies:
|
|
199
185
|
- - "~>"
|
200
186
|
- !ruby/object:Gem::Version
|
201
187
|
version: '1.12'
|
188
|
+
- !ruby/object:Gem::Dependency
|
189
|
+
name: ddr-aux-client
|
190
|
+
requirement: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '1.1'
|
195
|
+
type: :runtime
|
196
|
+
prerelease: false
|
197
|
+
version_requirements: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '1.1'
|
202
|
+
- !ruby/object:Gem::Dependency
|
203
|
+
name: ddr-antivirus
|
204
|
+
requirement: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - '='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 2.0.0
|
209
|
+
type: :runtime
|
210
|
+
prerelease: false
|
211
|
+
version_requirements: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - '='
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 2.0.0
|
202
216
|
- !ruby/object:Gem::Dependency
|
203
217
|
name: bundler
|
204
218
|
requirement: !ruby/object:Gem::Requirement
|
@@ -357,6 +371,7 @@ files:
|
|
357
371
|
- lib/ddr-models.rb
|
358
372
|
- lib/ddr/actions.rb
|
359
373
|
- lib/ddr/actions/fixity_check.rb
|
374
|
+
- lib/ddr/actions/virus_check.rb
|
360
375
|
- lib/ddr/auth.rb
|
361
376
|
- lib/ddr/auth/ability.rb
|
362
377
|
- lib/ddr/auth/ability_definitions.rb
|
@@ -412,9 +427,9 @@ files:
|
|
412
427
|
- lib/ddr/datastreams/administrative_metadata_datastream.rb
|
413
428
|
- lib/ddr/datastreams/datastream_behavior.rb
|
414
429
|
- lib/ddr/datastreams/descriptive_metadata_datastream.rb
|
430
|
+
- lib/ddr/datastreams/fits_datastream.rb
|
415
431
|
- lib/ddr/datastreams/metadata_datastream.rb
|
416
432
|
- lib/ddr/datastreams/plain_text_datastream.rb
|
417
|
-
- lib/ddr/datastreams/properties_datastream.rb
|
418
433
|
- lib/ddr/datastreams/structural_metadata_datastream.rb
|
419
434
|
- lib/ddr/derivatives.rb
|
420
435
|
- lib/ddr/derivatives/generator.rb
|
@@ -431,14 +446,32 @@ files:
|
|
431
446
|
- lib/ddr/events/update_event.rb
|
432
447
|
- lib/ddr/events/validation_event.rb
|
433
448
|
- lib/ddr/events/virus_check_event.rb
|
449
|
+
- lib/ddr/index.rb
|
450
|
+
- lib/ddr/index/abstract_query_result.rb
|
451
|
+
- lib/ddr/index/connection.rb
|
452
|
+
- lib/ddr/index/csv_query_result.rb
|
453
|
+
- lib/ddr/index/document_builder.rb
|
454
|
+
- lib/ddr/index/field.rb
|
455
|
+
- lib/ddr/index/fields.rb
|
456
|
+
- lib/ddr/index/filter.rb
|
457
|
+
- lib/ddr/index/filters.rb
|
458
|
+
- lib/ddr/index/legacy_license_fields.rb
|
459
|
+
- lib/ddr/index/query.rb
|
460
|
+
- lib/ddr/index/query_builder.rb
|
461
|
+
- lib/ddr/index/query_clause.rb
|
462
|
+
- lib/ddr/index/query_result.rb
|
463
|
+
- lib/ddr/index/query_value.rb
|
464
|
+
- lib/ddr/index/response.rb
|
465
|
+
- lib/ddr/index/unique_key_field.rb
|
434
466
|
- lib/ddr/index_fields.rb
|
435
467
|
- lib/ddr/jobs.rb
|
436
|
-
- lib/ddr/jobs/
|
468
|
+
- lib/ddr/jobs/fits_file_characterization.rb
|
437
469
|
- lib/ddr/jobs/permanent_id.rb
|
438
470
|
- lib/ddr/managers.rb
|
439
471
|
- lib/ddr/managers/derivatives_manager.rb
|
440
472
|
- lib/ddr/managers/manager.rb
|
441
473
|
- lib/ddr/managers/permanent_id_manager.rb
|
474
|
+
- lib/ddr/managers/technical_metadata_manager.rb
|
442
475
|
- lib/ddr/managers/workflow_manager.rb
|
443
476
|
- lib/ddr/metadata.rb
|
444
477
|
- lib/ddr/metadata/premis_event.rb
|
@@ -446,6 +479,7 @@ files:
|
|
446
479
|
- lib/ddr/models/access_controllable.rb
|
447
480
|
- lib/ddr/models/base.rb
|
448
481
|
- lib/ddr/models/describable.rb
|
482
|
+
- lib/ddr/models/effective_license.rb
|
449
483
|
- lib/ddr/models/engine.rb
|
450
484
|
- lib/ddr/models/error.rb
|
451
485
|
- lib/ddr/models/event_loggable.rb
|
@@ -457,15 +491,16 @@ files:
|
|
457
491
|
- lib/ddr/models/has_children.rb
|
458
492
|
- lib/ddr/models/has_content.rb
|
459
493
|
- lib/ddr/models/has_multires_image.rb
|
460
|
-
- lib/ddr/models/has_properties.rb
|
461
494
|
- lib/ddr/models/has_struct_metadata.rb
|
462
495
|
- lib/ddr/models/has_thumbnail.rb
|
463
496
|
- lib/ddr/models/indexing.rb
|
464
|
-
- lib/ddr/models/
|
497
|
+
- lib/ddr/models/inherited_license.rb
|
498
|
+
- lib/ddr/models/license.rb
|
465
499
|
- lib/ddr/models/solr_document.rb
|
466
500
|
- lib/ddr/models/struct_div.rb
|
467
501
|
- lib/ddr/models/structure.rb
|
468
502
|
- lib/ddr/models/version.rb
|
503
|
+
- lib/ddr/models/year_facet.rb
|
469
504
|
- lib/ddr/notifications.rb
|
470
505
|
- lib/ddr/utils.rb
|
471
506
|
- lib/ddr/vocab.rb
|
@@ -487,10 +522,8 @@ files:
|
|
487
522
|
- spec/auth/group_spec.rb
|
488
523
|
- spec/auth/groups_spec.rb
|
489
524
|
- spec/auth/ldap_gateway_spec.rb
|
490
|
-
- spec/auth/legacy_authorization_spec.rb
|
491
525
|
- spec/auth/legacy_default_permissions_spec.rb
|
492
526
|
- spec/auth/legacy_permissions_spec.rb
|
493
|
-
- spec/auth/legacy_roles_spec.rb
|
494
527
|
- spec/auth/roles/detached_role_set_spec.rb
|
495
528
|
- spec/auth/roles/property_role_set_spec.rb
|
496
529
|
- spec/auth/roles/role_set_query_spec.rb
|
@@ -503,6 +536,7 @@ files:
|
|
503
536
|
- spec/controllers/application_controller_spec.rb
|
504
537
|
- spec/controllers/including_role_based_access_controls_enforcement_spec.rb
|
505
538
|
- spec/controllers/users/sessions_controller_spec.rb
|
539
|
+
- spec/datastreams/fits_datastream_spec.rb
|
506
540
|
- spec/derivatives/png_generator_spec.rb
|
507
541
|
- spec/derivatives/ptif_generator_spec.rb
|
508
542
|
- spec/dummy/README.rdoc
|
@@ -563,6 +597,8 @@ files:
|
|
563
597
|
- spec/factories/user_factories.rb
|
564
598
|
- spec/fixtures/16bit.tif
|
565
599
|
- spec/fixtures/8bit.tif
|
600
|
+
- spec/fixtures/fits/document.xml
|
601
|
+
- spec/fixtures/fits/image.xml
|
566
602
|
- spec/fixtures/imageA.tif
|
567
603
|
- spec/fixtures/imageB.tif
|
568
604
|
- spec/fixtures/imageC.tif
|
@@ -570,24 +606,31 @@ files:
|
|
570
606
|
- spec/fixtures/sample.pdf
|
571
607
|
- spec/fixtures/target.png
|
572
608
|
- spec/helpers/models_helper_spec.rb
|
573
|
-
- spec/
|
609
|
+
- spec/index/filter_spec.rb
|
610
|
+
- spec/index/filters_spec.rb
|
611
|
+
- spec/index/query_spec.rb
|
612
|
+
- spec/jobs/fits_file_characterization_spec.rb
|
574
613
|
- spec/managers/derivatives_manager_spec.rb
|
614
|
+
- spec/managers/technical_metadata_manager_spec.rb
|
575
615
|
- spec/models/active_fedora_base_spec.rb
|
576
616
|
- spec/models/active_fedora_datastream_spec.rb
|
577
617
|
- spec/models/attachment_spec.rb
|
578
618
|
- spec/models/collection_spec.rb
|
579
619
|
- spec/models/component_spec.rb
|
580
620
|
- spec/models/descriptive_metadata_datastream_spec.rb
|
621
|
+
- spec/models/effective_license_spec.rb
|
581
622
|
- spec/models/events_spec.rb
|
582
623
|
- spec/models/file_management_spec.rb
|
583
624
|
- spec/models/has_admin_metadata_spec.rb
|
584
625
|
- spec/models/has_children_spec.rb
|
585
626
|
- spec/models/has_struct_metadata_spec.rb
|
627
|
+
- spec/models/indexing_spec.rb
|
586
628
|
- spec/models/item_spec.rb
|
587
629
|
- spec/models/solr_document_spec.rb
|
588
630
|
- spec/models/struct_div_spec.rb
|
589
631
|
- spec/models/structure_spec.rb
|
590
632
|
- spec/models/target_spec.rb
|
633
|
+
- spec/models/year_facet_spec.rb
|
591
634
|
- spec/routing/user_routing_spec.rb
|
592
635
|
- spec/spec_helper.rb
|
593
636
|
- spec/support/ezid_mock_identifier.rb
|
@@ -599,9 +642,7 @@ files:
|
|
599
642
|
- spec/support/shared_examples_for_events.rb
|
600
643
|
- spec/support/shared_examples_for_governables.rb
|
601
644
|
- spec/support/shared_examples_for_has_content.rb
|
602
|
-
- spec/support/shared_examples_for_has_properties.rb
|
603
645
|
- spec/support/shared_examples_for_indexing.rb
|
604
|
-
- spec/support/shared_examples_for_licensable.rb
|
605
646
|
- spec/support/shared_examples_for_non_collection_models.rb
|
606
647
|
- spec/support/shared_examples_for_role_sets.rb
|
607
648
|
- spec/support/structural_metadata_helper.rb
|
@@ -622,9 +663,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
622
663
|
version: '0'
|
623
664
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
624
665
|
requirements:
|
625
|
-
- - "
|
666
|
+
- - ">"
|
626
667
|
- !ruby/object:Gem::Version
|
627
|
-
version:
|
668
|
+
version: 1.3.1
|
628
669
|
requirements: []
|
629
670
|
rubyforge_project:
|
630
671
|
rubygems_version: 2.2.2
|
@@ -642,10 +683,8 @@ test_files:
|
|
642
683
|
- spec/auth/group_spec.rb
|
643
684
|
- spec/auth/groups_spec.rb
|
644
685
|
- spec/auth/ldap_gateway_spec.rb
|
645
|
-
- spec/auth/legacy_authorization_spec.rb
|
646
686
|
- spec/auth/legacy_default_permissions_spec.rb
|
647
687
|
- spec/auth/legacy_permissions_spec.rb
|
648
|
-
- spec/auth/legacy_roles_spec.rb
|
649
688
|
- spec/auth/roles/detached_role_set_spec.rb
|
650
689
|
- spec/auth/roles/property_role_set_spec.rb
|
651
690
|
- spec/auth/roles/role_set_query_spec.rb
|
@@ -658,6 +697,7 @@ test_files:
|
|
658
697
|
- spec/controllers/application_controller_spec.rb
|
659
698
|
- spec/controllers/including_role_based_access_controls_enforcement_spec.rb
|
660
699
|
- spec/controllers/users/sessions_controller_spec.rb
|
700
|
+
- spec/datastreams/fits_datastream_spec.rb
|
661
701
|
- spec/derivatives/png_generator_spec.rb
|
662
702
|
- spec/derivatives/ptif_generator_spec.rb
|
663
703
|
- spec/dummy/README.rdoc
|
@@ -718,6 +758,8 @@ test_files:
|
|
718
758
|
- spec/factories/user_factories.rb
|
719
759
|
- spec/fixtures/16bit.tif
|
720
760
|
- spec/fixtures/8bit.tif
|
761
|
+
- spec/fixtures/fits/document.xml
|
762
|
+
- spec/fixtures/fits/image.xml
|
721
763
|
- spec/fixtures/imageA.tif
|
722
764
|
- spec/fixtures/imageB.tif
|
723
765
|
- spec/fixtures/imageC.tif
|
@@ -725,24 +767,31 @@ test_files:
|
|
725
767
|
- spec/fixtures/sample.pdf
|
726
768
|
- spec/fixtures/target.png
|
727
769
|
- spec/helpers/models_helper_spec.rb
|
728
|
-
- spec/
|
770
|
+
- spec/index/filter_spec.rb
|
771
|
+
- spec/index/filters_spec.rb
|
772
|
+
- spec/index/query_spec.rb
|
773
|
+
- spec/jobs/fits_file_characterization_spec.rb
|
729
774
|
- spec/managers/derivatives_manager_spec.rb
|
775
|
+
- spec/managers/technical_metadata_manager_spec.rb
|
730
776
|
- spec/models/active_fedora_base_spec.rb
|
731
777
|
- spec/models/active_fedora_datastream_spec.rb
|
732
778
|
- spec/models/attachment_spec.rb
|
733
779
|
- spec/models/collection_spec.rb
|
734
780
|
- spec/models/component_spec.rb
|
735
781
|
- spec/models/descriptive_metadata_datastream_spec.rb
|
782
|
+
- spec/models/effective_license_spec.rb
|
736
783
|
- spec/models/events_spec.rb
|
737
784
|
- spec/models/file_management_spec.rb
|
738
785
|
- spec/models/has_admin_metadata_spec.rb
|
739
786
|
- spec/models/has_children_spec.rb
|
740
787
|
- spec/models/has_struct_metadata_spec.rb
|
788
|
+
- spec/models/indexing_spec.rb
|
741
789
|
- spec/models/item_spec.rb
|
742
790
|
- spec/models/solr_document_spec.rb
|
743
791
|
- spec/models/struct_div_spec.rb
|
744
792
|
- spec/models/structure_spec.rb
|
745
793
|
- spec/models/target_spec.rb
|
794
|
+
- spec/models/year_facet_spec.rb
|
746
795
|
- spec/routing/user_routing_spec.rb
|
747
796
|
- spec/spec_helper.rb
|
748
797
|
- spec/support/ezid_mock_identifier.rb
|
@@ -754,9 +803,7 @@ test_files:
|
|
754
803
|
- spec/support/shared_examples_for_events.rb
|
755
804
|
- spec/support/shared_examples_for_governables.rb
|
756
805
|
- spec/support/shared_examples_for_has_content.rb
|
757
|
-
- spec/support/shared_examples_for_has_properties.rb
|
758
806
|
- spec/support/shared_examples_for_indexing.rb
|
759
|
-
- spec/support/shared_examples_for_licensable.rb
|
760
807
|
- spec/support/shared_examples_for_non_collection_models.rb
|
761
808
|
- spec/support/shared_examples_for_role_sets.rb
|
762
809
|
- spec/support/structural_metadata_helper.rb
|