active-fedora 6.6.0 → 6.6.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: ef5496bb9123668b10de796159b394a50a1ec1da
4
- data.tar.gz: 70b9bf4b2d64f1f0a6ffd3b5eb81dca852f47cd6
3
+ metadata.gz: 95bf10c81395906f26c70a425466ec9e544f2e15
4
+ data.tar.gz: b18abff4428238811124584add40c90b6b58a1dd
5
5
  SHA512:
6
- metadata.gz: c87b4be4a4d26c6424cdfa4d7ca73981760fa36d9f91b3e62ecf8396153ee581914f594cdb9a4edaaca1c73f52332ffba2b78af3f0dd57bee176add2e0381d1c
7
- data.tar.gz: 15f245fddca1d9fb480cca04e41708e4e2fc1ec8cecd23409346101295bedecd286517e55b19d1420ba4511d076842f141d1171f9d16198b5ff6b3d9d3a11bc6
6
+ metadata.gz: 5a2087217930bad433c30938c82bcc7416c66cc7552796466bf24c29e6e67cd099419b7e76914a09e66ae147b7c2b8bafa5178c1927e8f74311d283c21031a7d
7
+ data.tar.gz: 50d38ecf44e8959f978dab853f39d784a2f9d2168d0f6015e7a17e63b8c34a3f17a482064fdc1314a9af8b8b1eb4b0aa084555a3b4ba23a9ed053c9007a1daee
@@ -1,3 +1,6 @@
1
+ v6.6.1
2
+ Don't try to track changes on delegates that are not attributes
3
+
1
4
  v6.6.0
2
5
  Add _destroy method for building nested forms [Justin Coyne]
3
6
  Removed the pid placeholder `__DO_NOT_USE__` [Justin Coyne]
@@ -41,6 +41,21 @@ module ActiveFedora
41
41
  instance_exec(args, &self.class.delegates[field][:setter])
42
42
  end
43
43
 
44
+ # @return [Boolean] true if there is an reader method and it returns a
45
+ # value different from the new_value.
46
+ def value_has_changed?(field, new_value)
47
+ begin
48
+ new_value != array_reader(field)
49
+ rescue NoMethodError
50
+ false
51
+ end
52
+ end
53
+
54
+ def mark_as_changed(field)
55
+ self.send("#{field}_will_change!")
56
+ end
57
+
58
+
44
59
  module ClassMethods
45
60
  def delegates
46
61
  @local_delegates ||= {}.with_indifferent_access
@@ -181,7 +196,7 @@ module ActiveFedora
181
196
  self.delegates[field] ||= {}
182
197
  self.delegates[field][:setter] = lambda do |v|
183
198
  ds = self.send(args[:to])
184
- self.send("#{field}_will_change!") unless v == array_reader(field)
199
+ mark_as_changed(field) if value_has_changed?(field, v)
185
200
  if ds.kind_of?(ActiveFedora::RDFDatastream)
186
201
  ds.send("#{field}=", v)
187
202
  else
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "6.6.0"
2
+ VERSION = "6.6.1"
3
3
  end
@@ -1,32 +1,59 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "delegating objects" do
4
- before :all do
5
- class TitledObject < ActiveFedora::Base
6
- has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"foo" do |m|
7
- m.field "title", :string
3
+ describe "delegating properties" do
4
+ describe "that have a reader and writer" do
5
+ before :all do
6
+ class TitledObject < ActiveFedora::Base
7
+ has_metadata 'foo', type: ActiveFedora::SimpleDatastream do |m|
8
+ m.field "title", :string
9
+ end
10
+ delegate :title, to: 'foo', multiple: false
11
+ end
12
+ end
13
+ after :all do
14
+ Object.send(:remove_const, :TitledObject)
15
+ end
16
+
17
+ describe "save" do
18
+ subject do
19
+ obj = TitledObject.create
20
+ obj.title = "Hydra for Dummies"
21
+ obj.save
22
+ obj
23
+ end
24
+ it "should keep a list of changes after a successful save" do
25
+ subject.previous_changes.should_not be_empty
26
+ subject.previous_changes.keys.should include("title")
27
+ end
28
+ it "should clean out changes" do
29
+ subject.title_changed?.should be_false
30
+ subject.changes.should be_empty
8
31
  end
9
- delegate :title, :to=>'foo', :unique=>true
10
32
  end
11
- end
12
- after :all do
13
- Object.send(:remove_const, :TitledObject)
14
33
  end
15
34
 
16
- describe "save" do
17
- subject do
18
- obj = TitledObject.create
19
- obj.title = "Hydra for Dummies"
20
- obj.save
21
- obj
35
+ describe "that only have a writer" do
36
+ before :all do
37
+ class TestDatastream < ActiveFedora::NtriplesRDFDatastream
38
+ # accepts_nested_attributes_for :title, would generate a method like this:
39
+ def title_attributes=(attributes)
40
+ end
41
+ end
42
+ class TitledObject < ActiveFedora::Base
43
+ has_metadata 'foo', type: TestDatastream
44
+ delegate :title_attributes, to: 'foo', multiple: false
45
+ end
22
46
  end
23
- it "should keep a list of changes after a successful save" do
24
- subject.previous_changes.should_not be_empty
25
- subject.previous_changes.keys.should include("title")
47
+ after :all do
48
+ Object.send(:remove_const, :TitledObject)
49
+ Object.send(:remove_const, :TestDatastream)
26
50
  end
27
- it "should clean out changes" do
28
- subject.title_changed?.should be_false
29
- subject.changes.should be_empty
51
+
52
+ subject { TitledObject.new }
53
+
54
+ it "Should delegate the method" do
55
+ subject.title_attributes = {'0' => {'title' => 'Hello'}}
30
56
  end
57
+
31
58
  end
32
59
  end
@@ -161,7 +161,7 @@ describe ActiveFedora::OmDatastream do
161
161
  @obj.reload
162
162
  end
163
163
  it "should solrize terms with :type=>'date' to *_dt solr terms" do
164
- @obj.to_solr[ActiveFedora::SolrService.solr_name('mods_journal_issue_publication_date', type: :date)].should == ['2012-11-02T00:00:00Z']
164
+ @obj.to_solr[ActiveFedora::SolrService.solr_name('journal_issue_publication_date', type: :date)].should == ['2012-11-02T00:00:00Z']
165
165
  end
166
166
  end
167
167
  end
@@ -20,7 +20,7 @@ describe ActiveFedora::Base do
20
20
  it 'should notify of deprecation if no cast parameter is passed' do
21
21
  Deprecation.should_receive(:warn).at_least(1).times
22
22
  expect {
23
- ActiveFedora::Base.find_one('_PID_')
23
+ ActiveFedora::Base.find_one('mypid:99999')
24
24
  }.to raise_error(ActiveFedora::ObjectNotFoundError)
25
25
  end
26
26
  end
@@ -28,7 +28,7 @@ describe ActiveFedora::Base do
28
28
  it 'should not have a deprecation warning when no cast parameter is passed' do
29
29
  Deprecation.should_not_receive(:warn)
30
30
  expect {
31
- SpecModel::Basic.find_one('_PID_')
31
+ SpecModel::Basic.find_one('mypid:99999')
32
32
  }.to raise_error(ActiveFedora::ObjectNotFoundError)
33
33
  end
34
34
  end
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: 6.6.0
4
+ version: 6.6.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: 2013-10-09 00:00:00.000000000 Z
13
+ date: 2013-10-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr
@@ -555,7 +555,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
555
555
  version: '0'
556
556
  requirements: []
557
557
  rubyforge_project:
558
- rubygems_version: 2.0.5
558
+ rubygems_version: 2.0.3
559
559
  signing_key:
560
560
  specification_version: 4
561
561
  summary: A convenience libary for manipulating documents in the Fedora Repository.