Skip to content

Commit

Permalink
update to couchrest.2.0.0.rc3 which returns nil for get('invalid') in…
Browse files Browse the repository at this point in the history
…stead of raising an exception
  • Loading branch information
thilo committed Jan 18, 2016
1 parent e92f3cd commit 0068f94
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion couch_potato.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY

s.add_dependency 'json', '~> 1.6'
s.add_dependency 'couchrest', '~>2.0.0.rc2'
s.add_dependency 'couchrest', '~>2.0.0.rc3'
s.add_dependency 'activemodel', '~> 4.0'

s.add_development_dependency 'rspec', '~>3.2.0'
Expand Down
10 changes: 3 additions & 7 deletions lib/couch_potato/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,9 @@ def load_document(id)
if id.is_a?(Array)
bulk_load id
else
begin
instance = couchrest_database.get(id)
instance.database = self
instance
rescue(CouchRest::NotFound)
nil
end
instance = couchrest_database.get(id)
instance.database = self if instance
instance
end
end
alias_method :load, :load_document
Expand Down
4 changes: 2 additions & 2 deletions spec/destroy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
end

it "should remove the document from the database" do
expect {
expect(CouchPotato.couchrest_database.get(@comment_id)).to
expect{
CouchPotato.couchrest_database.get!(@comment_id)
}.to raise_error(CouchRest::NotFound)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Child
let(:db) { CouchPotato::Database.new(double('couchrest db', :info => nil).as_null_object) }

it "should raise an error if no document found" do
allow(db.couchrest_database).to receive(:get).and_raise(CouchRest::NotFound)
allow(db.couchrest_database).to receive(:get).and_return(nil)
expect {
db.load! '1'
}.to raise_error(CouchPotato::NotFound)
Expand Down

0 comments on commit 0068f94

Please sign in to comment.