rufus-doric 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +6 -0
- data/lib/rufus/doric/model.rb +21 -1
- data/lib/rufus/doric/version.rb +1 -1
- data/rufus-doric.gemspec +2 -2
- data/test/ut_1_model.rb +19 -1
- data/test/ut_6_model_associations.rb +7 -0
- metadata +3 -3
data/CHANGELOG.txt
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
= rufus-doric CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
+
== rufus-doric - 0.1.12 released 2010/05/20
|
6
|
+
|
7
|
+
- implemented Model#save. Thanks Claudio !
|
8
|
+
- raising ArgumentError when find(x) and x is not a String
|
9
|
+
|
10
|
+
|
5
11
|
== rufus-doric - 0.1.11 released 2010/05/17
|
6
12
|
|
7
13
|
- model : issue with nil attachments, fixed
|
data/lib/rufus/doric/model.rb
CHANGED
@@ -239,6 +239,10 @@ module Doric
|
|
239
239
|
self.class.new(h)
|
240
240
|
end
|
241
241
|
|
242
|
+
# Saves this record.
|
243
|
+
#
|
244
|
+
# An exception will get raised if it fails.
|
245
|
+
#
|
242
246
|
def save!
|
243
247
|
|
244
248
|
raise ActiveRecord::RecordInvalid.new(self) unless valid?
|
@@ -270,6 +274,18 @@ module Doric
|
|
270
274
|
raise(SaveFailed.new(self.class.doric_type, _id)) unless r.nil?
|
271
275
|
end
|
272
276
|
|
277
|
+
# Returns true in case of success, false else.
|
278
|
+
#
|
279
|
+
def save
|
280
|
+
|
281
|
+
begin
|
282
|
+
save!
|
283
|
+
true
|
284
|
+
rescue Exception => e
|
285
|
+
false
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
273
289
|
def attach (attname, data, opts={})
|
274
290
|
|
275
291
|
extname = File.extname(attname)
|
@@ -514,9 +530,13 @@ module Doric
|
|
514
530
|
|
515
531
|
def self.find (_id)
|
516
532
|
|
533
|
+
raise ArgumentError.new(
|
534
|
+
"id #{_id.inspect} is not a String") unless _id.is_a?(String)
|
535
|
+
|
517
536
|
doc = db.get(_id)
|
518
537
|
|
519
|
-
raise Rufus::Doric::NotFound.new(
|
538
|
+
raise Rufus::Doric::NotFound.new(
|
539
|
+
@doric_type, _id) unless doc
|
520
540
|
|
521
541
|
self.new(doc)
|
522
542
|
end
|
data/lib/rufus/doric/version.rb
CHANGED
data/rufus-doric.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rufus-doric}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["John Mettraux"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-20}
|
13
13
|
s.description = %q{
|
14
14
|
something at the intersection of Rails3, CouchDB and rufus-jig
|
15
15
|
}
|
data/test/ut_1_model.rb
CHANGED
@@ -67,7 +67,7 @@ class UtModelTest < Test::Unit::TestCase
|
|
67
67
|
assert_equal({}, Concept.defaults)
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
70
|
+
def test_save_bang
|
71
71
|
|
72
72
|
Thing.new(
|
73
73
|
'name' => 'toto'
|
@@ -77,6 +77,14 @@ class UtModelTest < Test::Unit::TestCase
|
|
77
77
|
assert_equal 'toto', Thing.all.first._id
|
78
78
|
end
|
79
79
|
|
80
|
+
def test_save
|
81
|
+
|
82
|
+
assert_equal true, Thing.new('name' => 'dvorka').save
|
83
|
+
|
84
|
+
assert_equal 1, Thing.all.size
|
85
|
+
assert_equal 'dvorka', Thing.all.first._id
|
86
|
+
end
|
87
|
+
|
80
88
|
def test_failing_save
|
81
89
|
|
82
90
|
Thing.new(
|
@@ -88,6 +96,8 @@ class UtModelTest < Test::Unit::TestCase
|
|
88
96
|
'name' => 'toto'
|
89
97
|
).save!
|
90
98
|
end
|
99
|
+
|
100
|
+
assert_equal false, Thing.new('name' => 'toto').save
|
91
101
|
end
|
92
102
|
|
93
103
|
def test_missing_id_when_saving
|
@@ -187,5 +197,13 @@ class UtModelTest < Test::Unit::TestCase
|
|
187
197
|
|
188
198
|
assert_equal 'art', c.name
|
189
199
|
end
|
200
|
+
|
201
|
+
def test_find_nil
|
202
|
+
|
203
|
+
assert_raise ArgumentError do
|
204
|
+
|
205
|
+
Thing.find(nil)
|
206
|
+
end
|
207
|
+
end
|
190
208
|
end
|
191
209
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 12
|
9
|
+
version: 0.1.12
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- John Mettraux
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-20 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|