couch_potato 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/CHANGES.md +4 -0
- data/README.md +1 -1
- data/lib/couch_potato/database.rb +3 -1
- data/lib/couch_potato/version.rb +1 -1
- data/spec/unit/database_spec.rb +14 -3
- metadata +2 -2
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -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|
|
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)
|
data/lib/couch_potato/version.rb
CHANGED
data/spec/unit/database_spec.rb
CHANGED
@@ -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)
|
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.
|
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-
|
12
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|