couch_potato 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.travis.yml CHANGED
@@ -12,4 +12,4 @@ before_script:
12
12
  - sudo /etc/init.d/couchdb restart
13
13
  matrix:
14
14
  allow_failures:
15
- - rvm: jruby
15
+ - rvm: jruby-19mode
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## Changes
2
2
 
3
+ ### 1.0.1
4
+
5
+ * fixes error when bulk loaded document does not respond to database= (Alexander Lang)
6
+
3
7
  ### 1.0.0
4
8
 
5
9
  * adds `reload` method (Alexander Lang)
data/README.md CHANGED
@@ -27,7 +27,7 @@ Lastly Couch Potato aims to provide a seamless integration with Ruby on Rails, e
27
27
 
28
28
  ### Supported Environments
29
29
 
30
- * Ruby 1.9.3
30
+ * Ruby 1.9.3, 2.0, Rubinius
31
31
  * CouchDB 1.2.0
32
32
  * ActiveSupport 3.2, 4.0
33
33
 
@@ -144,7 +144,9 @@ module CouchPotato
144
144
  def bulk_load(ids)
145
145
  response = couchrest_database.bulk_load ids
146
146
  docs = response['rows'].map{|row| row["doc"]}.compact
147
- docs.each{|doc| doc.database = self}
147
+ docs.each{|doc|
148
+ doc.database = self if doc.respond_to?(:database=)
149
+ }
148
150
  end
149
151
 
150
152
  def create_document(document, validate)
@@ -1,3 +1,3 @@
1
1
  module CouchPotato
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -46,7 +46,7 @@ end
46
46
 
47
47
  describe CouchPotato::Database, 'load' do
48
48
 
49
- let(:couchrest_db) { stub('couchrest db', :info => nil) }
49
+ let(:couchrest_db) { stub('couchrest db', :info => nil).as_null_object }
50
50
  let(:db) { CouchPotato::Database.new couchrest_db }
51
51
 
52
52
  it "should raise an exception if nil given" do
@@ -69,7 +69,6 @@ describe CouchPotato::Database, 'load' do
69
69
  end
70
70
 
71
71
  context "when several ids given" do
72
-
73
72
  let(:doc1) { DbTestUser.new }
74
73
  let(:doc2) { DbTestUser.new }
75
74
  let(:response) do
@@ -77,7 +76,7 @@ describe CouchPotato::Database, 'load' do
77
76
  end
78
77
 
79
78
  before(:each) do
80
- couchrest_db.stub(:bulk_load).and_return response
79
+ couchrest_db.stub(:bulk_load) { response }
81
80
  end
82
81
 
83
82
  it "requests the couchrest bulk method" do
@@ -94,6 +93,18 @@ describe CouchPotato::Database, 'load' do
94
93
  doc.database.should eql(db)
95
94
  end
96
95
  end
96
+
97
+ it 'does not write itself to a document that has no database= method' do
98
+ doc1 = stub(:doc1)
99
+ doc1.stub(:respond_to?).with(:database=) { false }
100
+ couchrest_db.stub(:bulk_load) do
101
+ {"rows" => [{'doc' => doc1}]}
102
+ end
103
+
104
+ doc1.should_not_receive(:database=)
105
+
106
+ db.load(['1'])
107
+ end
97
108
  end
98
109
  end
99
110
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couch_potato
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-26 00:00:00.000000000 Z
12
+ date: 2013-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json