active-fedora 11.3.1 → 11.4.0

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: a51429cf9f08cc4aa710a9fc0d380d6111dda29a
4
- data.tar.gz: 87d9e18ee4cf39390b51ea9c38b4a1c61cf74e4d
3
+ metadata.gz: f1bd916c70022a35b187ef375993a59aea688ccd
4
+ data.tar.gz: 39a0d43d75c884e717d79197a2776156c391502d
5
5
  SHA512:
6
- metadata.gz: 244c96fe18c9e450eb87037c154f160c851ef4c294b1fcc4f929dffab591e811ffc885dd590b84e2e43d76014b7af02f07c01b42f50a321cf99c4bae69d0aed2
7
- data.tar.gz: 351d9b679c249a799a39e36b47dfb94a09d2a321ea0dd3b08e13eeaccfc5c966c89e257acd1bd471bfc13ebbd5faf55c1be93d36cead40cdbbab9de2e48a5ea0
6
+ metadata.gz: 22973752f005bcaa4bbe221dd6fc44de2c88c4ade86c5abe71b7ca38ad7493e8ec0c23185cdc55d202f0b47ae83942825ab5e4e7e644d6cb6bf436294d99a6d7
7
+ data.tar.gz: 3a3a96e70834bd59d41660a0bd5da16520b04dd258f841386455e611c360a6cddb9961b395ca4aeab228ff4a90e3ca84aebe947334a26688a1d18c7a0f07374d
@@ -17,6 +17,16 @@ module ActiveFedora
17
17
  end
18
18
  end
19
19
 
20
+ ##
21
+ # @return [String] the etag from the response headers
22
+ #
23
+ # @raise [RuntimeError] when the resource is new and has no etag
24
+ # @raise [Ldp::Gone] when the resource is deleted
25
+ def etag
26
+ raise 'Unable to produce an etag for a unsaved object' if ldp_source.new?
27
+ ldp_source.head.etag
28
+ end
29
+
20
30
  def ldp_source
21
31
  @ldp_source
22
32
  end
@@ -4,9 +4,13 @@ module ActiveFedora
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  def new_record?
7
- @ldp_source.new?
7
+ return true if @ldp_source.subject.nil?
8
+ @ldp_source.get
9
+ false
8
10
  rescue Ldp::Gone
9
11
  false
12
+ rescue Ldp::NotFound
13
+ true
10
14
  end
11
15
 
12
16
  def persisted?
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "11.3.1".freeze
2
+ VERSION = "11.4.0".freeze
3
3
  end
@@ -43,6 +43,28 @@ describe ActiveFedora::Base do
43
43
  end
44
44
  end
45
45
 
46
+ describe '#etag' do
47
+ let(:attributes) { { id: '1234' } }
48
+
49
+ it 'before save raises an error' do
50
+ expect { book.etag }
51
+ .to raise_error 'Unable to produce an etag for a unsaved object'
52
+ end
53
+
54
+ context 'after save' do
55
+ before { book.save! }
56
+
57
+ it 'has the etag from the ldp_source' do
58
+ expect(book.etag).to eq book.ldp_source.head.etag
59
+ end
60
+
61
+ it 'after delete raises Ldp::Gone' do
62
+ book.destroy!
63
+ expect { book.etag }.to raise_error Ldp::Gone
64
+ end
65
+ end
66
+ end
67
+
46
68
  describe "#freeze" do
47
69
  before { book.freeze }
48
70
 
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: 11.3.1
4
+ version: 11.4.0
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: 2017-06-15 00:00:00.000000000 Z
13
+ date: 2017-06-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr