active-fedora 9.13.0 → 10.0.0.beta1

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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -19
  3. data/lib/active_fedora.rb +0 -17
  4. data/lib/active_fedora/associations.rb +0 -16
  5. data/lib/active_fedora/associations/builder/association.rb +3 -19
  6. data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +1 -3
  7. data/lib/active_fedora/attached_files.rb +2 -108
  8. data/lib/active_fedora/attributes.rb +4 -100
  9. data/lib/active_fedora/core.rb +0 -6
  10. data/lib/active_fedora/datastreams.rb +0 -2
  11. data/lib/active_fedora/errors.rb +0 -9
  12. data/lib/active_fedora/file.rb +9 -22
  13. data/lib/active_fedora/file_configurator.rb +1 -32
  14. data/lib/active_fedora/identifiable.rb +0 -6
  15. data/lib/active_fedora/ldp_resource.rb +0 -12
  16. data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
  17. data/lib/active_fedora/query_result_builder.rb +0 -17
  18. data/lib/active_fedora/rdf/datastream_indexing.rb +0 -11
  19. data/lib/active_fedora/rdf/indexing_service.rb +1 -1
  20. data/lib/active_fedora/rdf/rdf_datastream.rb +0 -10
  21. data/lib/active_fedora/relation/finder_methods.rb +2 -21
  22. data/lib/active_fedora/solr_query_builder.rb +0 -16
  23. data/lib/active_fedora/solr_service.rb +2 -89
  24. data/lib/active_fedora/version.rb +1 -1
  25. data/lib/active_fedora/versionable.rb +0 -8
  26. data/spec/config_helper.rb +0 -4
  27. data/spec/integration/attached_files_spec.rb +1 -108
  28. data/spec/integration/attributes_spec.rb +14 -94
  29. data/spec/integration/direct_container_spec.rb +2 -2
  30. data/spec/integration/file_spec.rb +23 -13
  31. data/spec/integration/indexing_spec.rb +4 -4
  32. data/spec/integration/json_serialization_spec.rb +4 -57
  33. data/spec/integration/ntriples_datastream_spec.rb +77 -139
  34. data/spec/integration/relation_delegation_spec.rb +16 -18
  35. data/spec/integration/{model_spec.rb → scoping_spec.rb} +10 -14
  36. data/spec/integration/solr_hit_spec.rb +4 -20
  37. data/spec/integration/solr_instance_loader_spec.rb +1 -13
  38. data/spec/integration/versionable_spec.rb +0 -9
  39. data/spec/samples/models/mods_article.rb +1 -6
  40. data/spec/spec_helper.rb +0 -3
  41. data/spec/unit/attached_files_spec.rb +29 -127
  42. data/spec/unit/attributes_spec.rb +51 -475
  43. data/spec/unit/base_active_model_spec.rb +12 -47
  44. data/spec/unit/base_extra_spec.rb +1 -1
  45. data/spec/unit/code_configurator_spec.rb +2 -10
  46. data/spec/unit/core_spec.rb +3 -18
  47. data/spec/unit/file_configurator_spec.rb +0 -80
  48. data/spec/unit/file_spec.rb +0 -6
  49. data/spec/unit/has_and_belongs_to_many_association_spec.rb +0 -7
  50. data/spec/unit/inheritance_spec.rb +0 -12
  51. data/spec/unit/ntriples_datastream_spec.rb +2 -74
  52. data/spec/unit/property_spec.rb +0 -3
  53. data/spec/unit/query_spec.rb +0 -7
  54. data/spec/unit/querying_spec.rb +24 -0
  55. data/spec/unit/rdf/indexing_service_spec.rb +32 -20
  56. data/spec/unit/rdf_resource_datastream_spec.rb +37 -97
  57. data/spec/unit/solr_query_builder_spec.rb +0 -8
  58. data/spec/unit/solr_service_spec.rb +0 -13
  59. metadata +6 -19
  60. data/config/predicate_mappings.yml +0 -51
  61. data/lib/active_fedora/attributes/om_attribute.rb +0 -26
  62. data/lib/active_fedora/attributes/rdf_datastream_attribute.rb +0 -44
  63. data/lib/active_fedora/attributes/stream_attribute.rb +0 -43
  64. data/lib/active_fedora/datastream.rb +0 -9
  65. data/lib/active_fedora/model.rb +0 -31
  66. data/lib/active_fedora/predicates.rb +0 -122
  67. data/lib/active_fedora/simple_datastream.rb +0 -92
  68. data/spec/fixtures/rails_root/config/predicate_mappings.yml +0 -31
  69. data/spec/integration/field_to_solr_name_spec.rb +0 -36
  70. data/spec/unit/base_datastream_management_spec.rb +0 -19
  71. data/spec/unit/model_spec.rb +0 -30
  72. data/spec/unit/predicates_spec.rb +0 -126
  73. data/spec/unit/simple_datastream_spec.rb +0 -101
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "9.13.0".freeze
2
+ VERSION = "10.0.0.beta1".freeze
3
3
  end
@@ -1,19 +1,11 @@
1
1
  module ActiveFedora
2
2
  module Versionable
3
3
  extend ActiveSupport::Concern
4
- extend Deprecation
5
4
 
6
5
  included do
7
6
  class_attribute :versionable
8
7
  end
9
8
 
10
- module ClassMethods
11
- def has_many_versions
12
- Deprecation.warn Versionable, "has_many_versions is deprecated and will be removed in ActiveFedora 11."
13
- # self.versionable = true
14
- end
15
- end
16
-
17
9
  def model_type
18
10
  if respond_to?(:metadata)
19
11
  metadata.ldp_source.graph.query(predicate: ::RDF.type).objects
@@ -5,10 +5,6 @@ def mock_yaml(hash, path)
5
5
  allow(Psych).to receive(:load).and_return(hash)
6
6
  end
7
7
 
8
- def default_predicate_mapping_file
9
- File.expand_path(File.join(File.dirname(__FILE__), "..", "config", "predicate_mappings.yml"))
10
- end
11
-
12
8
  def stub_rails(opts = {})
13
9
  Object.const_set("Rails", Class)
14
10
  Rails.send(:undef_method, :env) if Rails.respond_to?(:env)
@@ -26,113 +26,6 @@ describe ActiveFedora::AttachedFiles do
26
26
  end
27
27
  end
28
28
 
29
- describe "#has_metadata" do
30
- describe "autosave" do
31
- before :each do
32
- class MockAFBaseRelationship < ActiveFedora::Base
33
- extend Deprecation
34
- Deprecation.silence(MockAFBaseRelationship) do
35
- has_metadata 'foo', type: Hydra::ModsArticleDatastream
36
- end
37
- end
38
- end
39
- after :each do
40
- Object.send(:remove_const, :MockAFBaseRelationship)
41
- end
42
- describe "a new document" do
43
- before do
44
- @obj = MockAFBaseRelationship.new
45
-
46
- @obj.foo.person = "bob"
47
- @obj.save
48
- end
49
-
50
- it "saves the datastream." do
51
- obj = MockAFBaseRelationship.find(@obj.id)
52
- expect(obj.foo).to_not be_new_record
53
- expect(obj.foo.person).to eq ['bob']
54
- person_field = ActiveFedora.index_field_mapper.solr_name('foo__person', type: :string)
55
- solr_result = ActiveFedora::SolrService.query("{!field f=id}#{@obj.id}", fl: "id #{person_field}").first
56
- expect(solr_result).to eq("id" => @obj.id, person_field => ['bob'])
57
- end
58
- end
59
-
60
- describe "that already exists in the repo" do
61
- before do
62
- @release = MockAFBaseRelationship.create
63
- @release.foo.person = "test foo content"
64
- @release.save
65
- end
66
- describe "and has been changed" do
67
- before do
68
- @release.foo.person = 'frank'
69
- @release.save!
70
- end
71
- it "saves the datastream." do
72
- expect(MockAFBaseRelationship.find(@release.id).foo.person).to eq ['frank']
73
- person_field = ActiveFedora.index_field_mapper.solr_name('foo__person', type: :string)
74
- expect(ActiveFedora::SolrService.query("id:\"#{@release.id}\"", fl: "id #{person_field}").first).to eq("id" => @release.id, person_field => ['frank'])
75
- end
76
- end
77
- end
78
- end
79
-
80
- describe "serializing datastreams" do
81
- before do
82
- class TestingMetadataSerializing < ActiveFedora::Base
83
- extend Deprecation
84
- Deprecation.silence(TestingMetadataSerializing) do
85
- has_metadata "nokogiri_autocreate_on", autocreate: true, type: ActiveFedora::OmDatastream
86
- has_metadata "nokogiri_autocreate_off", autocreate: false, type: ActiveFedora::OmDatastream
87
- end
88
- end
89
- end
90
-
91
- after do
92
- Object.send(:remove_const, :TestingMetadataSerializing)
93
- end
94
-
95
- subject { TestingMetadataSerializing.new }
96
-
97
- it "works" do
98
- subject.save(validate: false)
99
- expect(subject.nokogiri_autocreate_on).to_not be_new_record
100
- expect(subject.nokogiri_autocreate_off).to be_new_record
101
- end
102
- end
103
- end
104
-
105
- describe "#has_file_datastream" do
106
- before do
107
- class HasFile < ActiveFedora::Base
108
- extend Deprecation
109
- Deprecation.silence(HasFile) do
110
- has_file_datastream "file_ds"
111
- has_file_datastream "file_ds2", autocreate: false
112
- end
113
- end
114
- end
115
-
116
- after do
117
- has_file.delete
118
- Object.send(:remove_const, :HasFile)
119
- end
120
-
121
- let(:has_file) { HasFile.create("test:ds_versionable_has_file") }
122
-
123
- it "creates datastreams from the spec on new objects" do
124
- has_file.file_ds.content = "blah blah blah"
125
- expect(has_file.file_ds).to be_changed
126
- expect(has_file.file_ds2).to_not be_changed # no autocreate
127
- expect(has_file.file_ds2).to be_new_record
128
- has_file.save
129
- has_file.reload
130
- expect(has_file.file_ds).to_not be_changed
131
- expect(has_file.file_ds2).to_not be_changed # no autocreate
132
- expect(has_file.file_ds2).to be_new_record
133
- end
134
- end
135
-
136
29
  describe "Datastreams synched together" do
137
30
  before do
138
31
  class DSTest < ActiveFedora::Base
@@ -233,7 +126,7 @@ describe ActiveFedora::AttachedFiles do
233
126
  let(:obj) { ActiveFedora::Base.create }
234
127
  after { obj.destroy }
235
128
 
236
- let(:ds) { ActiveFedora::File.new(obj.uri + '/DS1').tap { |ds| ds.content = "foo"; ds.save } }
129
+ let(:ds) { ActiveFedora::File.new(obj.uri + '/DS1') { |ds| ds.content = "foo"; ds.save } }
237
130
 
238
131
  it "retrieves blobs that match the saved blobs" do
239
132
  obj.attach_file(ds, 'DS1')
@@ -2,28 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe "delegating attributes" do
4
4
  before :all do
5
- class PropertiesDatastream < ActiveFedora::OmDatastream
6
- set_terminology do |t|
7
- t.root(path: "fields")
8
- t.depositor index_as: [:symbol, :stored_searchable]
9
- t.wrangler index_as: [:facetable]
10
- end
11
- end
12
5
  class TitledObject < ActiveFedora::Base
13
- has_subresource 'foo', class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
14
- Deprecation.silence(ActiveFedora::Attributes) do
15
- has_attributes :title, datastream: 'foo', multiple: false
16
- end
6
+ property :title, predicate: ::RDF::Vocab::DC.title
17
7
  end
18
8
 
19
9
  class RdfObject < ActiveFedora::Base
20
- has_subresource 'foo', class_name: 'PropertiesDatastream'
21
- Deprecation.silence(ActiveFedora::Attributes) do
22
- has_attributes :depositor, datastream: :foo, multiple: false do |index|
23
- index.as :stored_searchable
24
- end
25
- has_attributes :wrangler, datastream: :foo, multiple: true
26
- end
27
10
  property :resource_type, predicate: ::RDF::Vocab::DC.type do |index|
28
11
  index.as :stored_searchable, :facetable
29
12
  end
@@ -33,7 +16,6 @@ describe "delegating attributes" do
33
16
  after :all do
34
17
  Object.send(:remove_const, :TitledObject)
35
18
  Object.send(:remove_const, :RdfObject)
36
- Object.send(:remove_const, :PropertiesDatastream)
37
19
  end
38
20
 
39
21
  describe "#index_config" do
@@ -41,7 +23,6 @@ describe "delegating attributes" do
41
23
  subject { RdfObject.index_config }
42
24
  it "has configuration" do
43
25
  expect(subject[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
44
- expect(subject[:depositor].behaviors).to eq [:stored_searchable]
45
26
  end
46
27
  end
47
28
 
@@ -59,7 +40,6 @@ describe "delegating attributes" do
59
40
 
60
41
  it "has configuration" do
61
42
  expect(subject[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
62
- expect(subject[:depositor].behaviors).to eq [:stored_searchable]
63
43
  end
64
44
 
65
45
  context "when the inherited config is modifed" do
@@ -75,83 +55,23 @@ describe "delegating attributes" do
75
55
  end
76
56
  end
77
57
 
78
- context "with a simple datastream" do
79
- describe "save" do
80
- subject do
81
- obj = TitledObject.create
82
- obj.title = "Hydra for Dummies"
83
- obj.save
84
- obj
85
- end
86
- it "keeps a list of changes after a successful save" do
87
- expect(subject.previous_changes).to_not be_empty
88
- expect(subject.previous_changes.keys).to include("title")
89
- end
90
- it "cleans out changes" do
91
- expect(subject).to_not be_title_changed
92
- expect(subject.changes).to be_empty
93
- end
58
+ describe "previous_changes" do
59
+ subject do
60
+ TitledObject.create(title: ["Hydra for Dummies"])
94
61
  end
95
- end
96
-
97
- context "with multiple datastreams" do
98
- subject { RdfObject.create }
99
-
100
- describe "getting attributes" do
101
- before do
102
- subject.depositor = "foo"
103
- subject.resource_type = ["bar"]
104
- subject.save
105
- end
106
-
107
- specify "using strings for keys" do
108
- expect(subject["depositor"]).to eql("foo")
109
- expect(subject["resource_type"]).to eql(["bar"])
110
- end
111
- specify "using symbols for keys" do
112
- expect(subject[:depositor]).to eql("foo")
113
- expect(subject[:resource_type]).to eql(["bar"])
114
- end
115
- end
116
-
117
- describe "setting attributes" do
118
- specify "using strings for keys" do
119
- subject["depositor"] = "foo"
120
- subject["resource_type"] = ["bar"]
121
- subject.save
122
- expect(subject.depositor).to eql("foo")
123
- expect(subject.resource_type).to eql(["bar"])
124
- end
125
-
126
- specify "using symbols for keys" do
127
- subject[:depositor] = "foo"
128
- subject[:resource_type] = ["bar"]
129
- subject.save
130
- expect(subject.depositor).to eql("foo")
131
- expect(subject.resource_type).to eql(["bar"])
132
- end
133
-
134
- # TODO: bug logged in issue #540
135
- describe "using shift", pending: "has_changed? not returning true" do
136
- specify "with rdf properties" do
137
- subject.resource_type << "bar"
138
- subject.save
139
- expect(subject.resource_type).to eql(["bar"])
140
- end
141
- specify "with om terms" do
142
- subject.wrangler << "bar"
143
- subject.save
144
- expect(subject.wrangler).to eql(["bar"])
145
- end
146
- end
62
+ it "keeps a list of changes after a successful save" do
63
+ expect(subject.previous_changes).to_not be_empty
64
+ expect(subject.previous_changes.keys).to include("title")
147
65
  end
148
66
  end
149
67
 
150
- describe 'dangerous attributes' do
151
- it 'raises an exception if a dangerous attribute is defined' do
152
- Deprecation.silence(ActiveFedora::Attributes) do
153
- expect { TitledObject.has_attributes :save, datastream: 'foo', multiple: false }.to raise_error ActiveFedora::DangerousAttributeError
154
- end
68
+ describe "#changes" do
69
+ subject do
70
+ TitledObject.create(title: ["Hydra for Dummies"])
71
+ end
72
+ it "cleans out changes" do
73
+ expect(subject).to_not be_title_changed
74
+ expect(subject.changes).to be_empty
155
75
  end
156
76
  end
157
77
  end
@@ -226,7 +226,7 @@ describe "Direct containers" do
226
226
  end
227
227
 
228
228
  context "and it doesn't contain the file" do
229
- let!(:file2) { ActiveFedora::File.new.tap { |f| f.content = 'hmm'; f.save } }
229
+ let!(:file2) { ActiveFedora::File.new { |f| f.content = 'hmm'; f.save } }
230
230
  subject { foo.reload.files.include? file2 }
231
231
  it { is_expected.to be false }
232
232
  end
@@ -241,7 +241,7 @@ describe "Direct containers" do
241
241
  end
242
242
 
243
243
  context "and it doesn't contain the file" do
244
- let!(:file2) { ActiveFedora::File.new.tap { |f| f.content = 'hmm'; f.save } }
244
+ let!(:file2) { ActiveFedora::File.new { |f| f.content = 'hmm'; f.save } }
245
245
  subject { foo.files.include? file2 }
246
246
  it { is_expected.to be false }
247
247
  end
@@ -50,13 +50,10 @@ describe ActiveFedora::File do
50
50
  end
51
51
  end
52
52
 
53
- context "when autocreate is true" do
53
+ context "with a sub-resource that autocreates" do
54
54
  before do
55
55
  class MockAFBase < ActiveFedora::Base
56
- extend Deprecation
57
- Deprecation.silence(MockAFBase) do
58
- has_metadata "descMetadata", type: ActiveFedora::QualifiedDublinCoreDatastream, autocreate: true
59
- end
56
+ has_subresource "descMetadata", class_name: 'ActiveFedora::QualifiedDublinCoreDatastream', autocreate: true
60
57
  end
61
58
  end
62
59
 
@@ -65,13 +62,7 @@ describe ActiveFedora::File do
65
62
  end
66
63
 
67
64
  let(:test_object) { MockAFBase.create }
68
-
69
- let(:descMetadata) { test_object.attached_files["descMetadata"] }
70
-
71
- describe "the metadata file" do
72
- subject { descMetadata }
73
- it { should be_a_kind_of(described_class) }
74
- end
65
+ let(:descMetadata) { test_object.descMetadata }
75
66
 
76
67
  describe "#content" do
77
68
  subject { descMetadata.content }
@@ -89,7 +80,6 @@ describe ActiveFedora::File do
89
80
  before do
90
81
  title.content = "Test Title"
91
82
  xml_content.root.add_child title
92
-
93
83
  allow(descMetadata).to receive(:before_save)
94
84
  descMetadata.content = xml_content.to_s
95
85
  descMetadata.save
@@ -100,6 +90,26 @@ describe ActiveFedora::File do
100
90
  subject { found.xpath('//dc/title/text()').first.inner_text }
101
91
  it { should eq title.content }
102
92
  end
93
+ end
94
+
95
+ context "with a sub-resource" do
96
+ before do
97
+ class MockAFBase < ActiveFedora::Base
98
+ has_subresource "descMetadata", class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
99
+ end
100
+ end
101
+
102
+ after do
103
+ Object.send(:remove_const, :MockAFBase)
104
+ end
105
+
106
+ let(:test_object) { MockAFBase.create }
107
+ let(:descMetadata) { test_object.descMetadata }
108
+
109
+ describe "the metadata file" do
110
+ subject { descMetadata }
111
+ it { should be_a_kind_of(described_class) }
112
+ end
103
113
 
104
114
  context "a binary file" do
105
115
  let(:path) { "ds#{Time.now.to_i}" }
@@ -31,15 +31,15 @@ describe ActiveFedora::Base do
31
31
 
32
32
  context 'when some of the decendants are not RDFSources' do
33
33
  let(:ids) { ['foo', 'foo/bar'] }
34
- let(:datastream) { ActiveFedora::Datastream.new(described_class.id_to_uri('foo/bar/bax')) }
34
+ let(:file) { ActiveFedora::File.new(described_class.id_to_uri('foo/bar/bax')) }
35
35
 
36
36
  before do
37
- datastream.content = "Hello!!!"
38
- datastream.save
37
+ file.content = "Hello!!!"
38
+ file.save
39
39
  end
40
40
 
41
41
  it "does not put the datastream in the decendants list" do
42
- expect(described_class.descendant_uris(root_uri(ids))).not_to include datastream.uri
42
+ expect(described_class.descendant_uris(root_uri(ids))).not_to include file.uri
43
43
  end
44
44
  end
45
45
 
@@ -5,32 +5,19 @@ describe "Objects should be serialized to JSON" do
5
5
  expect(ActiveFedora::Base.new.to_json).to eq "{\"id\":null}"
6
6
  end
7
7
 
8
- context "with properties and datastream attributes" do
8
+ context "with properties" do
9
9
  before do
10
- class MyDS < ActiveFedora::OmDatastream
11
- set_terminology do |t|
12
- t.root(path: "durh")
13
- t.foo
14
- t.bar
15
- end
16
- end
17
-
18
10
  class Foo < ActiveFedora::Base
19
- has_subresource 'descMetadata', class_name: 'MyDS'
20
- Deprecation.silence(ActiveFedora::Attributes) do
21
- has_attributes :foo, datastream: 'descMetadata', multiple: true
22
- has_attributes :bar, datastream: 'descMetadata', multiple: false
23
- end
24
11
  property :title, predicate: ::RDF::Vocab::DC.title
12
+ property :description, predicate: ::RDF::Vocab::DC.description, multiple: false
25
13
  end
26
14
  end
27
15
 
28
16
  after do
29
17
  Object.send(:remove_const, :Foo)
30
- Object.send(:remove_const, :MyDS)
31
18
  end
32
19
 
33
- let(:obj) { Foo.new(foo: ["baz"], bar: 'quix', title: ['My Title']) }
20
+ let(:obj) { Foo.new(title: ['My Title'], description: 'Wonderful stuff') }
34
21
 
35
22
  before { allow(obj).to receive(:id).and_return('test-123') }
36
23
 
@@ -38,48 +25,8 @@ describe "Objects should be serialized to JSON" do
38
25
 
39
26
  it "has to_json" do
40
27
  expect(subject['id']).to eq "test-123"
41
- expect(subject['foo']).to eq ["baz"]
42
- expect(subject['bar']).to eq "quix"
43
28
  expect(subject['title']).to eq ["My Title"]
29
+ expect(subject['description']).to eq "Wonderful stuff"
44
30
  end
45
31
  end
46
-
47
- context "with nested nodes" do
48
- before do
49
- class DummySubnode < ActiveTriples::Resource
50
- property :relation, predicate: ::RDF::Vocab::DC[:relation]
51
- end
52
-
53
- class DummyResource < ActiveFedora::RDFDatastream
54
- Deprecation.silence(ActiveFedora::RDFDatastream) do
55
- property :license, predicate: ::RDF::Vocab::DC[:license], class_name: DummySubnode do |index|
56
- index.as :searchable, :displayable
57
- end
58
- end
59
- def serialization_format
60
- :ntriples
61
- end
62
- end
63
-
64
- class DummyAsset < ActiveFedora::Base
65
- has_subresource 'descMetadata', class_name: 'DummyResource'
66
- Deprecation.silence(ActiveFedora::Attributes) do
67
- has_attributes :relation, datastream: 'descMetadata', at: [:license, :relation], multiple: false
68
- end
69
- end
70
- end
71
-
72
- after do
73
- Object.send(:remove_const, "DummyAsset")
74
- Object.send(:remove_const, "DummyResource")
75
- Object.send(:remove_const, "DummySubnode")
76
- end
77
-
78
- let(:obj) { DummyAsset.new { |a| a.relation = 'Great Grandchild' } }
79
- before { allow(obj).to receive(:id).and_return('test-123') }
80
-
81
- subject { JSON.parse(obj.to_json) }
82
-
83
- it { should eq("id" => "test-123", "relation" => "Great Grandchild") }
84
- end
85
32
  end