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: 2a6aaa85c1cec8d9127e06e4db353d27bff2242f
4
- data.tar.gz: d00f7e80d79c688e814ea6f3db6f07acf011cf09
3
+ metadata.gz: deb5540242acdaf301f3c2d765614ec74b11b1e3
4
+ data.tar.gz: c75881e832484211ba01198b55819f93bb649bc2
5
5
  SHA512:
6
- metadata.gz: 7a9dbb8d4bc4b4e4ecba17969d8a1dea7f10fc23da40e9002f8abfb86cce07005f461f100ebf3fd9dc70ef1485f40124b028b2df39361ba60d1cb091d481880f
7
- data.tar.gz: 28eba8f8e3b45a2b19155e138a7886e97e6884b2296c4d344a9c11d1e1c2e1a01e07f9ab6bae1f2c1353b2073e6953a3fff270ff17505b842d52264a04a83af6
6
+ metadata.gz: 41301d93f26ac7b209c91ec04ca50d68f4e6ff48db91a30f544eb402806dbbf2626958eece949db32b3c5f19f0cfa512570d6664ae808b0de2f81b04dbe531df
7
+ data.tar.gz: 1bb10d598301165c54e25fabbc73f4a010bc4faf194a3c496a11819670b589a394df05e136b53ea84d3352d1c7fb7598b781ab1eba853def603042be85fa9e25
@@ -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
- self.save
61
+ save!
61
62
  end
62
63
 
63
64
  end
@@ -244,7 +244,7 @@ EZID Metadata:
244
244
  repo_object.reload
245
245
  repo_object.permanent_id = identifier.id
246
246
  repo_object.permanent_url = PERMANENT_URL_BASE + identifier.id
247
- repo_object.save(validate: false)
247
+ repo_object.save!
248
248
  set_metadata!
249
249
  end
250
250
 
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "2.6.0.rc2"
3
+ VERSION = "2.6.0.rc3"
4
4
  end
5
5
  end
@@ -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
- let(:object) { described_class.new }
2
+
3
3
  context "having an identifier" do
4
4
  before do
5
- object.identifier = ["id001"]
6
- object.save(validate: false)
5
+ subject.identifier = ["id001"]
6
+ subject.save!
7
7
  end
8
- it "should be findable by identifier" do
9
- expect(described_class.find_by_identifier('id001')).to include object
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 "should have a default value" do
14
- expect(object.desc_metadata_terms).to eq Ddr::Datastreams::DescriptiveMetadataDatastream.term_names
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(object.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(object.desc_metadata_terms(:dcterms)).to match_array Ddr::Vocab::Vocabulary.term_names(RDF::DC)
20
- expect(object.desc_metadata_terms(:duke)).to eq Ddr::Vocab::Vocabulary.term_names(Ddr::Vocab::DukeTerms)
21
- expect(object.desc_metadata_terms(:dcterms_elements11)).to eq Ddr::Vocab::Vocabulary.term_names(RDF::DC11)
22
- expect(object.desc_metadata_terms(:defined_attributes)).to match_array Ddr::Vocab::Vocabulary.term_names(RDF::DC11)
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
- object.descMetadata.title = ["Object Title"]
27
- object.descMetadata.creator = ["Duke University Libraries"]
28
- object.descMetadata.identifier = ["id001"]
29
- object.save
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 "should accept an :empty argument" do
32
- expect(object.desc_metadata_terms(:empty)).to eq(object.desc_metadata_terms - [:title, :creator, :identifier])
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 "should accept a :present argument" do
35
- expect(object.desc_metadata_terms(:present)).to match_array [:title, :creator, :identifier]
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) { object.desc_metadata_terms.each_with_object({}) {|t, memo| memo[t] = ["Value"]} }
42
- it "should set the descMetadata terms to the values of the matching keys in the hash" do
43
- object.desc_metadata_terms.each do |t|
44
- expect(object).to receive(:set_desc_metadata_values).with(t, ["Value"])
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
- object.set_desc_metadata(term_values_hash)
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 "should set the term to an empty value" do
52
- object.set_desc_metadata_values(:title, nil)
53
- expect(object.descMetadata.title).to be_empty
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 "should reject empty values from the array" do
58
- object.set_desc_metadata_values(:title, ["Object Title", nil, "Alternative Title", ""])
59
- expect(object.descMetadata.title).to eq ["Object Title", "Alternative Title"]
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.rc2
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-04 00:00:00.000000000 Z
12
+ date: 2017-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails