public
Fork of chuyeow/activecouch
Description: ActiveCouch is a simple, convenient, Ruby-idiomatic wrapper for CouchDB
Homepage: http://github.com/arunthampi/activecouch
Clone URL: git://github.com/arunthampi/activecouch.git
Search Repo:
- Fixed bug in ticket 27 
(http://code.google.com/p/activecouch/issues/list)
- Added specs for ActiveCouch::Base#new
arunthampi (author)
Tue Jan 22 07:38:32 -0800 2008
commit  af92343cdf64ca1419862a5d9b806a280dcc28d5
tree    e477c99b5cc00c1d372e96eda784fc51d2abc8fa
parent  e5c097b1bb95646d63fcd06b41389bc878a9ac47
...
450
451
452
453
 
454
455
456
...
450
451
452
 
453
454
455
456
0
@@ -450,7 +450,7 @@ module ActiveCouch
0
           elsif v.is_a?(Hash) # This means this is a has_one association (which we might add later)
0
             # Do nothing for now. More later
0
           else # This means this is a normal attribute
0
- self.send("#{k}=", v) if @attributes.has_key?(k)
0
+ self.send("#{k}=", v) if respond_to?("#{k}=") # @attributes.has_key?(k) || @attributes.has_key?("_#{k}")
0
           end
0
         end
0
       end
...
29
30
31
32
33
 
34
35
36
...
29
30
31
 
 
32
33
34
35
0
@@ -29,8 +29,7 @@ describe "ActiveCouch::Base #before_delete method with a Symbol as argument" do
0
   
0
   it "should call the method specified as an argument to before_delete, *before* deleting the object from CouchDB" do
0
     # First save the object
0
- p = Person.create(:name => 'McLovin')
0
- p.age = 10
0
+ p = Person.create(:name => 'McLovin', :age => 10)
0
     # Before deleting, age must be 10
0
     p.age.should == 10
0
     # Delete the object, and...
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
0
@@ -0,0 +1,43 @@
0
+require File.dirname(__FILE__) + '/../spec_helper.rb'
0
+
0
+describe "ActiveCouch::Base #new method with a hash containing one key-value pair" do
0
+ before(:each) do
0
+ class Person < ActiveCouch::Base
0
+ has :name
0
+ end
0
+ end
0
+
0
+ it "should be able to initialize attributes correctly from a hash" do
0
+ p = Person.new(:name => 'McLovin')
0
+ p.name.should == 'McLovin'
0
+ end
0
+end
0
+
0
+describe "ActiveCouch::Base #new method with a hash containing more than one key-value pair" do
0
+ before(:each) do
0
+ class Person < ActiveCouch::Base
0
+ has :name
0
+ has :age, :which_is => :number, :with_default_value => 25
0
+ end
0
+ end
0
+
0
+ it "should be able to initialize attributes correctly from the hash" do
0
+ p = Person.new(:name => 'McLovin', :age => 12)
0
+ p.name.should == 'McLovin'
0
+ p.age.should == 12
0
+ end
0
+end
0
+
0
+describe "ActiveCouch::Base #new method with a hash containing a CouchDB reserved attribute" do
0
+ before(:each) do
0
+ class Person < ActiveCouch::Base
0
+ has :name
0
+ end
0
+ end
0
+
0
+ it "should be able to initialize attributes correclty from the has, including CouchDB reserved attributes" do
0
+ p = Person.new(:name => 'McLovin', :id => '123')
0
+ p.name.should == 'McLovin'
0
+ p.id.should == '123'
0
+ end
0
+end
0
\ No newline at end of file

Comments

    No one has commented yet.