Skip to content

Commit

Permalink
Merge pull request #1069 from projecthydra/no_exception
Browse files Browse the repository at this point in the history
Don't raise an error if you check if a deleted object is new
  • Loading branch information
cbeer committed May 6, 2016
2 parents df77504 + acc771d commit 971e609
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/active_fedora/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Persistence

def new_record?
@ldp_source.new?
rescue Ldp::Gone
false
end

def persisted?
Expand Down
13 changes: 13 additions & 0 deletions spec/unit/persistence_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
require 'spec_helper'

describe ActiveFedora::Persistence do
describe '#new_record?' do
context 'with an new object' do
subject { ActiveFedora::Base.new }
it { is_expected.to be_new_record }
end

context 'with an destroyed object' do
subject { ActiveFedora::Base.create }
before { subject.delete }
it { is_expected.not_to be_new_record }
end
end

describe '.delete' do
context 'with an unsaved object' do
subject { ActiveFedora::Base.new }
Expand Down

0 comments on commit 971e609

Please sign in to comment.