From 0068f946dcc641c6a706eddd6ae4685793c62a4c Mon Sep 17 00:00:00 2001 From: Thilo Utke Date: Mon, 18 Jan 2016 14:06:49 +0100 Subject: [PATCH 1/2] update to couchrest.2.0.0.rc3 which returns nil for get('invalid') instead of raising an exception --- couch_potato.gemspec | 2 +- lib/couch_potato/database.rb | 10 +++------- spec/destroy_spec.rb | 4 ++-- spec/unit/database_spec.rb | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/couch_potato.gemspec b/couch_potato.gemspec index 5ab28f5a..9077e537 100644 --- a/couch_potato.gemspec +++ b/couch_potato.gemspec @@ -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' diff --git a/lib/couch_potato/database.rb b/lib/couch_potato/database.rb index 69d4c9eb..c6b83be6 100644 --- a/lib/couch_potato/database.rb +++ b/lib/couch_potato/database.rb @@ -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 diff --git a/spec/destroy_spec.rb b/spec/destroy_spec.rb index 9b0aa02f..948c7e4f 100644 --- a/spec/destroy_spec.rb +++ b/spec/destroy_spec.rb @@ -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 diff --git a/spec/unit/database_spec.rb b/spec/unit/database_spec.rb index 1ca5a9a3..c603630e 100644 --- a/spec/unit/database_spec.rb +++ b/spec/unit/database_spec.rb @@ -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) From 9416bfed68b4b97aa1011a9263c85fa4e0a1c26b Mon Sep 17 00:00:00 2001 From: Thilo Utke Date: Thu, 21 Jan 2016 21:24:25 +0100 Subject: [PATCH 2/2] install bundler version 1.11.2 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 14203b1d..4eef3cab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ gemfile: - gemfiles/active_support_4_0 - gemfiles/active_support_4_1 - gemfiles/active_support_4_2 +before_install: + gem install bundler --version 1.11.2 before_script: - sudo sh -c 'echo "[native_query_servers]" >> /etc/couchdb/local.ini' - sudo sh -c 'echo "erlang = {couch_native_process, start_link, []}" >> /etc/couchdb/local.ini'