active-fedora 12.0.0 → 12.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/active_fedora/relation/finder_methods.rb +5 -1
- data/lib/active_fedora/version.rb +1 -1
- data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +1 -1
- data/lib/generators/active_fedora/config/fedora/templates/{.fcrepo_wrapper → .fcrepo_wrapper.yml} +0 -0
- data/lib/generators/active_fedora/config/solr/solr_generator.rb +2 -1
- data/lib/generators/active_fedora/config/solr/templates/{.solr_wrapper → .solr_wrapper.yml} +0 -0
- data/spec/integration/generators/fedora_generator_spec.rb +1 -1
- data/spec/integration/generators/solr_generator_spec.rb +1 -1
- data/spec/unit/finder_methods_spec.rb +47 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e4477e94db6cb4a9e1f22323c2dc319e8c32b029b66f973bc4b6b65bdfe289d9
|
4
|
+
data.tar.gz: 4a68c80e4e06bf4b820e5d64066894a16cc36b4e31121eef4fe890fb93b321a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da15216891813bfc736c43db883c5398a2e80a268c019935c64df29e77242235f64313776b5de454a18b8626d2b5dbed28c193793d4dd0048638cba377faf32f
|
7
|
+
data.tar.gz: 4b249fcc89efcb630f066ddf8b4705dfa7fab9326ca8d95225d75fc43eb710a14a00572d947bdfa1a5c2f51cfc90778e79aa10fee128e910bbaa91510e287ada
|
@@ -194,13 +194,17 @@ module ActiveFedora
|
|
194
194
|
ActiveFedora::Base
|
195
195
|
else
|
196
196
|
resource_class = ActiveFedora.model_mapper.classifier(resource).best_model
|
197
|
-
unless resource_class
|
197
|
+
unless equivalent_class?(resource_class)
|
198
198
|
raise ActiveFedora::ModelMismatch, "Expected #{@klass}. Got: #{resource_class}"
|
199
199
|
end
|
200
200
|
resource_class
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
+
def equivalent_class?(other_class)
|
205
|
+
other_class <= @klass
|
206
|
+
end
|
207
|
+
|
204
208
|
def find_with_ids(ids, cast)
|
205
209
|
expects_array = ids.first.is_a?(Array)
|
206
210
|
return ids.first if expects_array && ids.first.empty?
|
data/lib/generators/active_fedora/config/fedora/templates/{.fcrepo_wrapper → .fcrepo_wrapper.yml}
RENAMED
File without changes
|
@@ -11,7 +11,8 @@ module ActiveFedora
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def solr_wrapper_config
|
14
|
-
|
14
|
+
# Overwrite the configuration files that Blacklight has installed
|
15
|
+
copy_file '.solr_wrapper.yml', force: true
|
15
16
|
copy_file 'solr_wrapper_test.yml', 'config/solr_wrapper_test.yml'
|
16
17
|
end
|
17
18
|
end
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe ActiveFedora::FinderMethods do
|
3
|
+
RSpec.describe ActiveFedora::FinderMethods do
|
4
4
|
let(:object_class) do
|
5
5
|
Class.new do
|
6
6
|
def self.delegated_attributes
|
@@ -30,6 +30,52 @@ describe ActiveFedora::FinderMethods do
|
|
30
30
|
|
31
31
|
let(:finder) { finder_class.new }
|
32
32
|
|
33
|
+
describe '#equivalent_class?' do
|
34
|
+
let(:child_class) { Class.new(object_class) }
|
35
|
+
let(:object_class) { Class.new }
|
36
|
+
it 'is true for the exact class' do
|
37
|
+
expect(finder.send(:equivalent_class?, object_class)).to be true
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'is true for child classes' do
|
41
|
+
expect(finder.send(:equivalent_class?, child_class)).to be true
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'is falsey for non-decendants' do
|
45
|
+
expect(finder.send(:equivalent_class?, Class.new)).to be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#class_to_load' do
|
50
|
+
subject(:class_to_load) { finder.send(:class_to_load, resource, true) }
|
51
|
+
|
52
|
+
let(:best_model) { Class.new }
|
53
|
+
let(:mapper) { instance_double(ActiveFedora::DefaultModelMapper, classifier: classifier) }
|
54
|
+
let(:classifier) { instance_double(ActiveFedora::ModelClassifier, best_model: best_model) }
|
55
|
+
let(:resource) { instance_double(Hash) }
|
56
|
+
|
57
|
+
before do
|
58
|
+
allow(ActiveFedora).to receive(:model_mapper).and_return(mapper)
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when using the default implementation' do
|
62
|
+
it 'raises an error' do
|
63
|
+
expect { class_to_load }.to raise_error ActiveFedora::ModelMismatch
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when a custom finder overrides equivalent_class?' do
|
68
|
+
before do
|
69
|
+
allow(finder).to receive(:equivalent_class?).and_return(true)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'calls the overridden implementation' do
|
73
|
+
expect(class_to_load).to eq best_model
|
74
|
+
expect(finder).to have_received(:equivalent_class?).with(best_model)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
33
79
|
describe "#condition_to_clauses" do
|
34
80
|
subject { finder.send(:condition_to_clauses, key, value) }
|
35
81
|
let(:key) { 'library_id' }
|
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: 12.0.
|
4
|
+
version: 12.0.1
|
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:
|
13
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -559,11 +559,11 @@ files:
|
|
559
559
|
- lib/generators/active_fedora/config/USAGE
|
560
560
|
- lib/generators/active_fedora/config/config_generator.rb
|
561
561
|
- lib/generators/active_fedora/config/fedora/fedora_generator.rb
|
562
|
-
- lib/generators/active_fedora/config/fedora/templates/.fcrepo_wrapper
|
562
|
+
- lib/generators/active_fedora/config/fedora/templates/.fcrepo_wrapper.yml
|
563
563
|
- lib/generators/active_fedora/config/fedora/templates/fcrepo_wrapper_test.yml
|
564
564
|
- lib/generators/active_fedora/config/fedora/templates/fedora.yml
|
565
565
|
- lib/generators/active_fedora/config/solr/solr_generator.rb
|
566
|
-
- lib/generators/active_fedora/config/solr/templates/.solr_wrapper
|
566
|
+
- lib/generators/active_fedora/config/solr/templates/.solr_wrapper.yml
|
567
567
|
- lib/generators/active_fedora/config/solr/templates/solr.yml
|
568
568
|
- lib/generators/active_fedora/config/solr/templates/solr/config/_rest_managed.json
|
569
569
|
- lib/generators/active_fedora/config/solr/templates/solr/config/admin-extra.html
|
@@ -744,7 +744,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
744
744
|
version: '0'
|
745
745
|
requirements: []
|
746
746
|
rubyforge_project:
|
747
|
-
rubygems_version: 2.
|
747
|
+
rubygems_version: 2.7.1
|
748
748
|
signing_key:
|
749
749
|
specification_version: 4
|
750
750
|
summary: A convenience libary for manipulating documents in the Fedora Repository.
|