ddr-models 2.6.0.rc2 → 2.6.0.rc3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deb5540242acdaf301f3c2d765614ec74b11b1e3
|
4
|
+
data.tar.gz: c75881e832484211ba01198b55819f93bb649bc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41301d93f26ac7b209c91ec04ca50d68f4e6ff48db91a30f544eb402806dbbf2626958eece949db32b3c5f19f0cfa512570d6664ae808b0de2f81b04dbe531df
|
7
|
+
data.tar.gz: 1bb10d598301165c54e25fabbc73f4a010bc4faf194a3c496a11819670b589a394df05e136b53ea84d3352d1c7fb7598b781ab1eba853def603042be85fa9e25
|
data/app/models/collection.rb
CHANGED
@@ -14,7 +14,7 @@ class Collection < Ddr::Models::Base
|
|
14
14
|
alias_method :items, :children
|
15
15
|
alias_method :item_ids, :child_ids
|
16
16
|
|
17
|
-
after_create :set_admin_policy
|
17
|
+
after_create :set_admin_policy, unless: :admin_policy
|
18
18
|
|
19
19
|
validates_presence_of :title
|
20
20
|
|
@@ -56,8 +56,9 @@ class Collection < Ddr::Models::Base
|
|
56
56
|
private
|
57
57
|
|
58
58
|
def set_admin_policy
|
59
|
+
reload
|
59
60
|
self.admin_policy = self
|
60
|
-
|
61
|
+
save!
|
61
62
|
end
|
62
63
|
|
63
64
|
end
|
data/lib/ddr/models/version.rb
CHANGED
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Collection, type: :model do
|
4
4
|
|
5
|
+
subject { described_class.new(title: ["Test Collection"]) }
|
6
|
+
|
5
7
|
it_behaves_like "a DDR model"
|
6
8
|
it_behaves_like "it has an association", :has_many, :children, :is_member_of_collection, "Item"
|
7
9
|
it_behaves_like "it has an association", :has_many, :targets, :is_external_target_for, "Target"
|
@@ -54,6 +56,9 @@ RSpec.describe Collection, type: :model do
|
|
54
56
|
end
|
55
57
|
|
56
58
|
describe "validation" do
|
59
|
+
before do
|
60
|
+
subject.title = nil
|
61
|
+
end
|
57
62
|
it "requires a title" do
|
58
63
|
expect(subject).to_not be_valid
|
59
64
|
expect(subject.errors.messages).to have_key(:title)
|
@@ -1,62 +1,62 @@
|
|
1
1
|
RSpec.shared_examples "a describable object" do
|
2
|
-
|
2
|
+
|
3
3
|
context "having an identifier" do
|
4
4
|
before do
|
5
|
-
|
6
|
-
|
5
|
+
subject.identifier = ["id001"]
|
6
|
+
subject.save!
|
7
7
|
end
|
8
|
-
it "
|
9
|
-
expect(described_class.find_by_identifier('id001')).to include
|
8
|
+
it "is findable by identifier" do
|
9
|
+
expect(described_class.find_by_identifier('id001')).to include subject
|
10
10
|
end
|
11
11
|
end
|
12
12
|
describe "#desc_metadata_terms" do
|
13
|
-
it "
|
14
|
-
expect(
|
13
|
+
it "has a default value" do
|
14
|
+
expect(subject.desc_metadata_terms).to eq Ddr::Datastreams::DescriptiveMetadataDatastream.term_names
|
15
15
|
end
|
16
16
|
describe "arguments" do
|
17
17
|
it "with fixed results" do
|
18
|
-
expect(
|
19
|
-
expect(
|
20
|
-
expect(
|
21
|
-
expect(
|
22
|
-
expect(
|
18
|
+
expect(subject.desc_metadata_terms(:dcterms)).to eq(Ddr::Vocab::Vocabulary.term_names(RDF::DC11) + (Ddr::Vocab::Vocabulary.term_names(RDF::DC) - Ddr::Vocab::Vocabulary.term_names(RDF::DC11)))
|
19
|
+
expect(subject.desc_metadata_terms(:dcterms)).to match_array Ddr::Vocab::Vocabulary.term_names(RDF::DC)
|
20
|
+
expect(subject.desc_metadata_terms(:duke)).to eq Ddr::Vocab::Vocabulary.term_names(Ddr::Vocab::DukeTerms)
|
21
|
+
expect(subject.desc_metadata_terms(:dcterms_elements11)).to eq Ddr::Vocab::Vocabulary.term_names(RDF::DC11)
|
22
|
+
expect(subject.desc_metadata_terms(:defined_attributes)).to match_array Ddr::Vocab::Vocabulary.term_names(RDF::DC11)
|
23
23
|
end
|
24
24
|
context "with variable results" do
|
25
25
|
before do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
subject.descMetadata.title = ["Object Title"]
|
27
|
+
subject.descMetadata.creator = ["Duke University Libraries"]
|
28
|
+
subject.descMetadata.identifier = ["id001"]
|
29
|
+
subject.save!
|
30
30
|
end
|
31
|
-
it "
|
32
|
-
expect(
|
31
|
+
it "accepts an :empty argument" do
|
32
|
+
expect(subject.desc_metadata_terms(:empty)).to eq(subject.desc_metadata_terms - [:title, :creator, :identifier])
|
33
33
|
end
|
34
|
-
it "
|
35
|
-
expect(
|
34
|
+
it "accepts a :present argument" do
|
35
|
+
expect(subject.desc_metadata_terms(:present)).to match_array [:title, :creator, :identifier]
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
40
|
describe "#set_desc_metadata" do
|
41
|
-
let(:term_values_hash) {
|
42
|
-
it "
|
43
|
-
|
44
|
-
expect(
|
41
|
+
let(:term_values_hash) { subject.desc_metadata_terms.each_with_object({}) {|t, memo| memo[t] = ["Value"]} }
|
42
|
+
it "sets the descMetadata terms to the values of the matching keys in the hash" do
|
43
|
+
subject.desc_metadata_terms.each do |t|
|
44
|
+
expect(subject).to receive(:set_desc_metadata_values).with(t, ["Value"])
|
45
45
|
end
|
46
|
-
|
46
|
+
subject.set_desc_metadata(term_values_hash)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
describe "#set_desc_metadata_values" do
|
50
50
|
context "when values == nil" do
|
51
|
-
it "
|
52
|
-
|
53
|
-
expect(
|
51
|
+
it "sets the term to an empty value" do
|
52
|
+
subject.set_desc_metadata_values(:title, nil)
|
53
|
+
expect(subject.descMetadata.title).to be_empty
|
54
54
|
end
|
55
55
|
end
|
56
56
|
context "when values is an array" do
|
57
|
-
it "
|
58
|
-
|
59
|
-
expect(
|
57
|
+
it "rejects empty values from the array" do
|
58
|
+
subject.set_desc_metadata_values(:title, ["Object Title", nil, "Alternative Title", ""])
|
59
|
+
expect(subject.descMetadata.title).to eq ["Object Title", "Alternative Title"]
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
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: 2.6.0.
|
4
|
+
version: 2.6.0.rc3
|
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: 2017-01-
|
12
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|