ddr-models 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ddr/models/solr_document.rb +11 -16
- data/lib/ddr/models/version.rb +1 -1
- data/spec/models/effective_license_spec.rb +48 -41
- data/spec/models/solr_document_spec.rb +16 -16
- data/spec/spec_helper.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6d273e1b012bea164a89a6ce3029bae9568c2b1
|
4
|
+
data.tar.gz: 942b1b7201d4426c1df684417d657df550604490
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c5fdc47393e01d2e3746747f85565c1d17accb24f371e737bb5143abb73364d607315a7f7974bb0c1d95893a2133a9abf78426488209451ad4f1e912e16dff
|
7
|
+
data.tar.gz: 177b2529645a27c5a4c216817b3ab727b6cce26941199f42207668ef0761ab87f9f756e6bd2d98879f7bac4cceb55c57c53d7bea32b713b5bae12547b7415d8c
|
@@ -98,23 +98,18 @@ module Ddr::Models
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def has_admin_policy?
|
101
|
-
|
101
|
+
admin_policy_id.present?
|
102
102
|
end
|
103
103
|
|
104
|
-
def
|
104
|
+
def admin_policy_id
|
105
105
|
is_governed_by
|
106
106
|
end
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
uri &&= ActiveFedora::Base.pid_from_uri(uri)
|
111
|
-
end
|
112
|
-
alias_method :admin_policy_id, :admin_policy_pid
|
107
|
+
alias_method :admin_policy_pid, :admin_policy_id
|
108
|
+
alias_method :admin_policy_uri, :admin_policy_id
|
109
|
+
deprecation_deprecate :admin_policy_pid, :admin_policy_uri
|
113
110
|
|
114
111
|
def admin_policy
|
115
|
-
if has_admin_policy?
|
116
|
-
self.class.find(admin_policy_uri)
|
117
|
-
end
|
112
|
+
self.class.find(admin_policy_id) if has_admin_policy?
|
118
113
|
end
|
119
114
|
|
120
115
|
def has_children?
|
@@ -211,18 +206,18 @@ module Ddr::Models
|
|
211
206
|
Ddr::Models::Contact.call(research_help_contact) if research_help_contact
|
212
207
|
end
|
213
208
|
|
214
|
-
def
|
209
|
+
def parent_id
|
215
210
|
is_part_of || is_member_of_collection
|
216
211
|
end
|
212
|
+
alias_method :parent_uri, :parent_id
|
213
|
+
deprecation_deprecate :parent_uri
|
217
214
|
|
218
215
|
def has_parent?
|
219
|
-
|
216
|
+
parent_id.present?
|
220
217
|
end
|
221
218
|
|
222
219
|
def parent
|
223
|
-
if has_parent?
|
224
|
-
self.class.find(parent_uri)
|
225
|
-
end
|
220
|
+
self.class.find(parent_id) if has_parent?
|
226
221
|
end
|
227
222
|
|
228
223
|
def multires_image_file_paths(type='default')
|
data/lib/ddr/models/version.rb
CHANGED
@@ -4,71 +4,78 @@ module Ddr::Models
|
|
4
4
|
subject { described_class.call(obj) }
|
5
5
|
|
6
6
|
let(:url) { "https://creativecommons.org/licenses/by-nc-nd/4.0/" }
|
7
|
-
|
8
7
|
let(:license) { License.new(url: url) }
|
9
|
-
|
10
|
-
let(:obj) { Component.new(id: "test-1") }
|
11
8
|
let(:parent) { Item.new(id: "test-2") }
|
12
9
|
let(:admin_policy) { Collection.new(id: "test-3") }
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
shared_examples "an effective license" do
|
12
|
+
describe "when the object has a license" do
|
13
|
+
before do
|
14
|
+
allow(License).to receive(:call).with(obj) { license }
|
15
|
+
end
|
16
|
+
it { is_expected.to eq(license) }
|
17
17
|
end
|
18
|
-
it { is_expected.to eq(license) }
|
19
|
-
end
|
20
18
|
|
21
|
-
|
22
|
-
before do
|
23
|
-
allow(License).to receive(:call).with(obj) { nil }
|
24
|
-
end
|
25
|
-
describe "and the object has a parent" do
|
19
|
+
describe "when the object does not have a license" do
|
26
20
|
before do
|
27
|
-
allow(
|
21
|
+
allow(License).to receive(:call).with(obj) { nil }
|
28
22
|
end
|
29
|
-
describe "and the
|
23
|
+
describe "and the object has a parent" do
|
30
24
|
before do
|
31
|
-
allow(
|
25
|
+
allow(obj).to receive(:parent) { parent }
|
32
26
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
describe "and the parent has a license" do
|
28
|
+
before do
|
29
|
+
allow(License).to receive(:call).with(parent) { license }
|
30
|
+
end
|
31
|
+
it { is_expected.to eq(license) }
|
38
32
|
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
describe "and the object does not have a parent" do
|
43
|
-
describe "and the object has an admin policy" do
|
44
|
-
before { allow(obj).to receive(:admin_policy) { admin_policy } }
|
45
|
-
describe "and the admin policy has a different id from the object" do
|
33
|
+
describe "and the parent does not have a license" do
|
46
34
|
before do
|
47
|
-
allow(
|
35
|
+
allow(License).to receive(:call).with(parent) { nil }
|
48
36
|
end
|
49
|
-
|
37
|
+
it { is_expected.to be_nil }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
describe "and the object does not have a parent" do
|
41
|
+
describe "and the object has an admin policy" do
|
42
|
+
before { allow(obj).to receive(:admin_policy) { admin_policy } }
|
43
|
+
describe "and the admin policy has a different id from the object" do
|
50
44
|
before do
|
51
|
-
allow(
|
45
|
+
allow(obj).to receive(:admin_policy_id) { "test-3" }
|
52
46
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
47
|
+
describe "and the admin policy has a license" do
|
48
|
+
before do
|
49
|
+
allow(License).to receive(:call).with(admin_policy) { license }
|
50
|
+
end
|
51
|
+
it { is_expected.to eq(license) }
|
52
|
+
end
|
53
|
+
describe "and the admin policy does not have a license" do
|
54
|
+
before do
|
55
|
+
allow(License).to receive(:call).with(admin_policy) { nil }
|
56
|
+
end
|
57
|
+
it { is_expected.to be_nil }
|
58
58
|
end
|
59
|
+
end
|
60
|
+
describe "and the admin policy has the same id as the object" do
|
61
|
+
before { allow(obj).to receive(:admin_policy_id) { obj.id } }
|
59
62
|
it { is_expected.to be_nil }
|
60
63
|
end
|
61
64
|
end
|
62
|
-
describe "and the
|
63
|
-
before { allow(obj).to receive(:admin_policy_id) { obj.id } }
|
65
|
+
describe "and the object does not have an admin policy" do
|
64
66
|
it { is_expected.to be_nil }
|
65
67
|
end
|
66
68
|
end
|
67
|
-
describe "and the object does not have an admin policy" do
|
68
|
-
it { is_expected.to be_nil }
|
69
|
-
end
|
70
69
|
end
|
71
70
|
end
|
72
71
|
|
72
|
+
it_behaves_like "an effective license" do
|
73
|
+
let(:obj) { Component.new(id: "test-1") }
|
74
|
+
end
|
75
|
+
|
76
|
+
it_behaves_like "an effective license" do
|
77
|
+
let(:obj) { ::SolrDocument.new(id: "test-1") }
|
78
|
+
end
|
79
|
+
|
73
80
|
end
|
74
81
|
end
|
@@ -25,20 +25,20 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe "#
|
28
|
+
describe "#admin_policy_id" do
|
29
29
|
describe "when is_governed_by is not set" do
|
30
|
-
its(:
|
30
|
+
its(:admin_policy_id) { is_expected.to be_nil }
|
31
31
|
end
|
32
32
|
describe "when is_governed_by is set" do
|
33
|
-
before { subject[Ddr::Index::Fields::IS_GOVERNED_BY] = "
|
34
|
-
its(:
|
33
|
+
before { subject[Ddr::Index::Fields::IS_GOVERNED_BY] = "test-1" }
|
34
|
+
its(:admin_policy_id) { is_expected.to eq("test-1") }
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "#admin_policy" do
|
39
39
|
describe "when there is not an admin policy relationship" do
|
40
|
-
before { allow(subject).to receive(:
|
41
|
-
its(:admin_policy) {
|
40
|
+
before { allow(subject).to receive(:admin_policy_id) { nil } }
|
41
|
+
its(:admin_policy) { is_expected.to be_nil }
|
42
42
|
end
|
43
43
|
describe "where there is an admin policy relationship" do
|
44
44
|
let(:admin_policy) { FactoryGirl.create(:collection) }
|
@@ -51,28 +51,28 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe "#
|
54
|
+
describe "#parent_id" do
|
55
55
|
describe "when is_part_of is present" do
|
56
|
-
before { subject[Ddr::Index::Fields::IS_PART_OF] = "
|
57
|
-
its(:
|
56
|
+
before { subject[Ddr::Index::Fields::IS_PART_OF] = "test-1" }
|
57
|
+
its(:parent_id) { is_expected.to eq("test-1") }
|
58
58
|
end
|
59
59
|
describe "when is_part_of is not present" do
|
60
60
|
describe "when is_member_of_collection is present" do
|
61
|
-
before { subject[Ddr::Index::Fields::IS_MEMBER_OF_COLLECTION] = "
|
62
|
-
its(:
|
61
|
+
before { subject[Ddr::Index::Fields::IS_MEMBER_OF_COLLECTION] = "test-1" }
|
62
|
+
its(:parent_id) { is_expected.to eq("test-1") }
|
63
63
|
end
|
64
64
|
describe "when is_member_of_collection is not present" do
|
65
|
-
its(:
|
65
|
+
its(:parent_id) { is_expected.to be_nil }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "#parent" do
|
71
|
-
describe "when there is a parent
|
72
|
-
let(:doc) { described_class.new({"id"=>"test
|
71
|
+
describe "when there is a parent ID" do
|
72
|
+
let(:doc) { described_class.new({"id"=>"test-1"}) }
|
73
73
|
before do
|
74
|
-
allow(subject).to receive(:
|
75
|
-
allow(described_class).to receive(:find).with("
|
74
|
+
allow(subject).to receive(:parent_id) { "test-1" }
|
75
|
+
allow(described_class).to receive(:find).with("test-1") { doc }
|
76
76
|
end
|
77
77
|
its(:parent) { is_expected.to eq(doc) }
|
78
78
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -76,12 +76,12 @@ RSpec.configure do |config|
|
|
76
76
|
# Many RSpec users commonly either run the entire suite or an individual
|
77
77
|
# file, and it's useful to allow more verbose output when running an
|
78
78
|
# individual spec file.
|
79
|
-
if config.files_to_run.one?
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
79
|
+
# if config.files_to_run.one?
|
80
|
+
# # Use the documentation formatter for detailed output,
|
81
|
+
# # unless a formatter has already been configured
|
82
|
+
# # (e.g. via a command-line flag).
|
83
|
+
# config.default_formatter = 'doc'
|
84
|
+
# end
|
85
85
|
|
86
86
|
# Print the 10 slowest examples and example groups at the
|
87
87
|
# end of the spec run, to help surface which specs are running
|
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: 3.0.
|
4
|
+
version: 3.0.1
|
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: 2016-05-
|
12
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|