active-fedora 9.10.0.pre2 → 9.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/History.txt +141 -0
- data/lib/active_fedora/associations/association.rb +38 -12
- data/lib/active_fedora/associations/association_scope.rb +6 -2
- data/lib/active_fedora/associations/basic_contains_association.rb +2 -3
- data/lib/active_fedora/associations/belongs_to_association.rb +23 -4
- data/lib/active_fedora/associations/builder/association.rb +37 -56
- data/lib/active_fedora/associations/builder/belongs_to.rb +27 -1
- data/lib/active_fedora/associations/builder/collection_association.rb +33 -2
- data/lib/active_fedora/associations/builder/contains.rb +3 -3
- data/lib/active_fedora/associations/builder/directly_contains.rb +1 -7
- data/lib/active_fedora/associations/builder/directly_contains_one.rb +20 -17
- data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +1 -1
- data/lib/active_fedora/associations/builder/has_many.rb +2 -43
- data/lib/active_fedora/associations/builder/indirectly_contains.rb +1 -7
- data/lib/active_fedora/associations/builder/property.rb +2 -13
- data/lib/active_fedora/associations/builder/singular_association.rb +2 -6
- data/lib/active_fedora/associations/builder/singular_property.rb +2 -3
- data/lib/active_fedora/associations/collection_association.rb +6 -14
- data/lib/active_fedora/associations/directly_contains_one_association.rb +1 -2
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +1 -1
- data/lib/active_fedora/associations/has_many_association.rb +23 -0
- data/lib/active_fedora/attached_files.rb +1 -1
- data/lib/active_fedora/core.rb +2 -1
- data/lib/active_fedora/errors.rb +13 -0
- data/lib/active_fedora/file.rb +16 -1
- data/lib/active_fedora/file/attributes.rb +6 -6
- data/lib/active_fedora/reflection.rb +200 -76
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/with_metadata/metadata_node.rb +2 -1
- data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +4 -0
- data/lib/generators/active_fedora/config/fedora/templates/.fcrepo_wrapper +3 -0
- data/lib/generators/active_fedora/config/solr/solr_generator.rb +4 -0
- data/lib/generators/active_fedora/config/solr/templates/.solr_wrapper +5 -0
- data/spec/integration/attached_files_spec.rb +4 -4
- data/spec/integration/file_spec.rb +1 -1
- data/spec/integration/om_datastream_spec.rb +6 -6
- data/spec/unit/collection_proxy_spec.rb +1 -1
- data/spec/unit/file_spec.rb +19 -0
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +4 -4
- data/spec/unit/has_many_association_spec.rb +2 -2
- data/spec/unit/reflection_spec.rb +2 -2
- metadata +6 -4
@@ -2,6 +2,7 @@ module ActiveFedora
|
|
2
2
|
module WithMetadata
|
3
3
|
class MetadataNode < ActiveTriples::Resource
|
4
4
|
include ActiveModel::Dirty
|
5
|
+
property :mime_type, predicate: ::RDF::URI("http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#hasMimeType")
|
5
6
|
attr_reader :file
|
6
7
|
|
7
8
|
def initialize(file)
|
@@ -45,7 +46,7 @@ module ActiveFedora
|
|
45
46
|
|
46
47
|
def changed_attributes
|
47
48
|
super.tap do |changed|
|
48
|
-
changed['type'] = true if type.present?
|
49
|
+
changed['type'] = true if type.present? && new_record?
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -63,13 +63,13 @@ describe ActiveFedora::AttachedFiles do
|
|
63
63
|
|
64
64
|
it "creates datastreams from the spec on new objects" do
|
65
65
|
has_file.file_ds.content = "blah blah blah"
|
66
|
-
expect(has_file.file_ds).to
|
67
|
-
expect(has_file.file_ds2).to_not
|
66
|
+
expect(has_file.file_ds).to be_content_changed
|
67
|
+
expect(has_file.file_ds2).to_not be_content_changed # no autocreate
|
68
68
|
expect(has_file.file_ds2).to be_new_record
|
69
69
|
has_file.save
|
70
70
|
has_file.reload
|
71
|
-
expect(has_file.file_ds).to_not
|
72
|
-
expect(has_file.file_ds2).to_not
|
71
|
+
expect(has_file.file_ds).to_not be_content_changed
|
72
|
+
expect(has_file.file_ds2).to_not be_content_changed # no autocreate
|
73
73
|
expect(has_file.file_ds2).to be_new_record
|
74
74
|
end
|
75
75
|
end
|
@@ -109,7 +109,7 @@ describe ActiveFedora::File do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it "is not changed" do
|
112
|
-
expect(test_object.attached_files[path]).to_not
|
112
|
+
expect(test_object.attached_files[path]).to_not be_content_changed
|
113
113
|
end
|
114
114
|
|
115
115
|
it "is able to read the content from fedora" do
|
@@ -30,15 +30,15 @@ describe ActiveFedora::OmDatastream do
|
|
30
30
|
end
|
31
31
|
it "does not be changed if the new xml matches the old xml" do
|
32
32
|
subject.content = subject.content
|
33
|
-
expect(subject).to_not
|
33
|
+
expect(subject).to_not be_content_changed
|
34
34
|
end
|
35
35
|
|
36
36
|
it "is changed if there are minor differences in whitespace" do
|
37
37
|
subject.content = "<a><b>1</b></a>"
|
38
38
|
obj.save
|
39
|
-
expect(subject).to_not
|
39
|
+
expect(subject).to_not be_content_changed
|
40
40
|
subject.content = "<a>\n<b>1</b>\n</a>"
|
41
|
-
expect(subject).to
|
41
|
+
expect(subject).to be_content_changed
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -56,11 +56,11 @@ describe ActiveFedora::OmDatastream do
|
|
56
56
|
obj.reload
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
59
|
+
it "is not dirty after .update_values is saved" do
|
60
60
|
obj.descMetadata.update_values([{ name: 0 }, { role: 0 }, :text] => "Funder")
|
61
|
-
expect(obj.descMetadata).to
|
61
|
+
expect(obj.descMetadata).to be_content_changed
|
62
62
|
obj.save
|
63
|
-
expect(obj.descMetadata).to_not
|
63
|
+
expect(obj.descMetadata).to_not be_content_changed
|
64
64
|
expect(obj.descMetadata.term_values({ name: 0 }, { role: 0 }, :text)).to eq ["Funder"]
|
65
65
|
end
|
66
66
|
end
|
@@ -14,7 +14,7 @@ describe ActiveFedora::Associations::CollectionProxy do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#spawn" do
|
17
|
-
let(:reflection) {
|
17
|
+
let(:reflection) { ActiveFedora::Reflection.create(:has_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Book) }
|
18
18
|
let(:association) { ActiveFedora::Associations::HasManyAssociation.new(Book.new, reflection) }
|
19
19
|
let(:proxy) { described_class.new(association) }
|
20
20
|
|
data/spec/unit/file_spec.rb
CHANGED
@@ -185,6 +185,25 @@ describe ActiveFedora::File do
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
+
describe "#mime_type" do
|
189
|
+
let(:parent) { ActiveFedora::Base.create }
|
190
|
+
before do
|
191
|
+
parent.add_file('banana', path: 'apple', mime_type: 'video/webm')
|
192
|
+
parent.save!
|
193
|
+
end
|
194
|
+
it "persists" do
|
195
|
+
expect(parent.reload.apple.mime_type).to eq "video/webm"
|
196
|
+
end
|
197
|
+
it "can be updated" do
|
198
|
+
parent.reload
|
199
|
+
parent.apple.mime_type = "text/awesome"
|
200
|
+
expect(parent.apple.mime_type).to eq "text/awesome"
|
201
|
+
parent.save
|
202
|
+
|
203
|
+
expect(parent.reload.apple.mime_type).to eq "text/awesome"
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
188
207
|
context "original_name" do
|
189
208
|
subject { file.original_name }
|
190
209
|
|
@@ -23,7 +23,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
23
23
|
context "a one way relationship " do
|
24
24
|
describe "adding memeber" do
|
25
25
|
it "sets the relationship attribute" do
|
26
|
-
reflection =
|
26
|
+
reflection = ActiveFedora::Reflection.create(:has_and_belongs_to_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Book)
|
27
27
|
allow(ActiveFedora::SolrService).to receive(:query).and_return([])
|
28
28
|
ac = described_class.new(subject, reflection)
|
29
29
|
expect(ac).to receive(:callback).twice
|
@@ -41,7 +41,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
41
41
|
|
42
42
|
describe "finding member" do
|
43
43
|
let(:ids) { (0..15).map(&:to_s) }
|
44
|
-
let(:reflection) {
|
44
|
+
let(:reflection) { ActiveFedora::Reflection.create(:has_and_belongs_to_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Book) }
|
45
45
|
let(:association) { described_class.new(subject, reflection) }
|
46
46
|
it "calls ActiveFedora::Base.find" do
|
47
47
|
expect(subject).to receive(:[]).with('page_ids').and_return(ids)
|
@@ -59,8 +59,8 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
context "with an inverse reflection" do
|
62
|
-
let!(:inverse) {
|
63
|
-
let(:reflection) {
|
62
|
+
let!(:inverse) { ActiveFedora::Reflection.create(:has_and_belongs_to_many, :books, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Page) }
|
63
|
+
let(:reflection) { ActiveFedora::Reflection.create(:has_and_belongs_to_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, inverse_of: 'books' }, Book) }
|
64
64
|
let(:ac) { described_class.new(subject, reflection) }
|
65
65
|
let(:object) { Page.new }
|
66
66
|
|
@@ -22,7 +22,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
22
22
|
allow(ActiveFedora::SolrService).to receive(:query).and_return([])
|
23
23
|
end
|
24
24
|
|
25
|
-
let(:reflection) {
|
25
|
+
let(:reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
|
26
26
|
let(:association) { described_class.new(book, reflection) }
|
27
27
|
|
28
28
|
it "sets the book_id attribute" do
|
@@ -38,7 +38,7 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
38
38
|
Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
39
39
|
Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
40
40
|
end
|
41
|
-
let(:book_reflection) {
|
41
|
+
let(:book_reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
|
42
42
|
let(:association) { described_class.new(book, book_reflection) }
|
43
43
|
|
44
44
|
subject { association.send(:find_polymorphic_inverse, page) }
|
@@ -5,7 +5,7 @@ describe ActiveFedora::Reflection::AssociationReflection do
|
|
5
5
|
let(:name) { 'dummy' }
|
6
6
|
let(:options) { { inverse_of: :default_permissions } }
|
7
7
|
let(:active_fedora) { double }
|
8
|
-
let(:instance) { described_class.new(macro, name, options, active_fedora) }
|
8
|
+
let(:instance) { described_class.new(macro, name, nil, options, active_fedora) }
|
9
9
|
subject { instance.send :derive_foreign_key }
|
10
10
|
|
11
11
|
context "when a has_many" do
|
@@ -30,7 +30,7 @@ describe ActiveFedora::Reflection::AssociationReflection do
|
|
30
30
|
let(:name) { 'dummy' }
|
31
31
|
let(:options) { { as: 'foothing' } }
|
32
32
|
let(:active_fedora) { double }
|
33
|
-
let(:instance) { described_class.new(macro, name, options, active_fedora) }
|
33
|
+
let(:instance) { described_class.new(macro, name, nil, options, active_fedora) }
|
34
34
|
subject { instance.send :automatic_inverse_of }
|
35
35
|
|
36
36
|
context "when a has_many" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.10.0
|
4
|
+
version: 9.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-03-
|
13
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -532,8 +532,10 @@ files:
|
|
532
532
|
- lib/generators/active_fedora/config/USAGE
|
533
533
|
- lib/generators/active_fedora/config/config_generator.rb
|
534
534
|
- lib/generators/active_fedora/config/fedora/fedora_generator.rb
|
535
|
+
- lib/generators/active_fedora/config/fedora/templates/.fcrepo_wrapper
|
535
536
|
- lib/generators/active_fedora/config/fedora/templates/fedora.yml
|
536
537
|
- lib/generators/active_fedora/config/solr/solr_generator.rb
|
538
|
+
- lib/generators/active_fedora/config/solr/templates/.solr_wrapper
|
537
539
|
- lib/generators/active_fedora/config/solr/templates/solr.yml
|
538
540
|
- lib/generators/active_fedora/config/solr/templates/solr/config/_rest_managed.json
|
539
541
|
- lib/generators/active_fedora/config/solr/templates/solr/config/admin-extra.html
|
@@ -734,9 +736,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
734
736
|
version: '2.0'
|
735
737
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
736
738
|
requirements:
|
737
|
-
- - "
|
739
|
+
- - ">="
|
738
740
|
- !ruby/object:Gem::Version
|
739
|
-
version:
|
741
|
+
version: '0'
|
740
742
|
requirements: []
|
741
743
|
rubyforge_project:
|
742
744
|
rubygems_version: 2.5.1
|