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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93a4738c22acccd452b340bd9bde7d2dbb4eac11
4
- data.tar.gz: 5f3b011aa5c923fa17660db8b48bf5cb528caea2
3
+ metadata.gz: f6d273e1b012bea164a89a6ce3029bae9568c2b1
4
+ data.tar.gz: 942b1b7201d4426c1df684417d657df550604490
5
5
  SHA512:
6
- metadata.gz: 6dafeee44f551b18eb0b26c674df5cfa6e776104cf3d9c0bb05375717fc68ae488f45200214d142efaeeaa33120beab0d5f2116af1d428aedd60222161a4dfb6
7
- data.tar.gz: e90b570e88827930395c2ab3be39d64a1e8c2cf2bddfa20f65016c3175cdbcd77b889b65bf377a4486b14b545b6ae62863a85a63aeb7e414f4078afe29a464e7
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
- admin_policy_uri.present?
101
+ admin_policy_id.present?
102
102
  end
103
103
 
104
- def admin_policy_uri
104
+ def admin_policy_id
105
105
  is_governed_by
106
106
  end
107
-
108
- def admin_policy_pid
109
- uri = admin_policy_uri
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 parent_uri
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
- parent_uri.present?
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')
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "3.0.0"
3
+ VERSION = "3.0.1"
4
4
  end
5
5
  end
@@ -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
- describe "when the object has a license" do
15
- before do
16
- allow(License).to receive(:call).with(obj) { license }
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
- describe "when the object does not have a license" do
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(obj).to receive(:parent) { parent }
21
+ allow(License).to receive(:call).with(obj) { nil }
28
22
  end
29
- describe "and the parent has a license" do
23
+ describe "and the object has a parent" do
30
24
  before do
31
- allow(License).to receive(:call).with(parent) { license }
25
+ allow(obj).to receive(:parent) { parent }
32
26
  end
33
- it { is_expected.to eq(license) }
34
- end
35
- describe "and the parent does not have a license" do
36
- before do
37
- allow(License).to receive(:call).with(parent) { nil }
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
- it { is_expected.to be_nil }
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(obj).to receive(:admin_policy_id) { "test-3" }
35
+ allow(License).to receive(:call).with(parent) { nil }
48
36
  end
49
- describe "and the admin policy has a license" do
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(License).to receive(:call).with(admin_policy) { license }
45
+ allow(obj).to receive(:admin_policy_id) { "test-3" }
52
46
  end
53
- it { is_expected.to eq(license) }
54
- end
55
- describe "and the admin policy does not have a license" do
56
- before do
57
- allow(License).to receive(:call).with(admin_policy) { nil }
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 admin policy has the same id as the object" do
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 "#admin_policy_uri" do
28
+ describe "#admin_policy_id" do
29
29
  describe "when is_governed_by is not set" do
30
- its(:admin_policy_uri) { is_expected.to be_nil }
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] = "info:fedora/test:1" }
34
- its(:admin_policy_uri) { should eq("info:fedora/test:1") }
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(:admin_policy_pid) { nil } }
41
- its(:admin_policy) { should be_nil }
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 "#parent_uri" do
54
+ describe "#parent_id" do
55
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") }
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] = "info:fedora/test:1" }
62
- its(:parent_uri) { is_expected.to eq("info:fedora/test:1") }
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(:parent_uri) { is_expected.to be_nil }
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 URI" do
72
- let(:doc) { described_class.new({"id"=>"test:1"}) }
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(:parent_uri) { "info:fedora/test:1" }
75
- allow(described_class).to receive(:find).with("info:fedora/test:1") { doc }
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
@@ -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
- # 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
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.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 00:00:00.000000000 Z
12
+ date: 2016-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails