merge rafaelss :as patch

This commit is contained in:
Chris Anderson 2008-12-31 15:40:17 -08:00
commit c180a317e8
2 changed files with 21 additions and 6 deletions

View file

@ -89,6 +89,12 @@ class Player < CouchRest::Model
timestamps!
end
class Event < CouchRest::Model
key_accessor :subject, :occurs_at
cast :occurs_at, :as => 'Time', :send => 'parse'
end
describe "save bug" do
before(:each) do
CouchRest::Model.default_database = reset_test_db!
@ -322,6 +328,18 @@ describe CouchRest::Model do
end
end
describe "cast keys to any type" do
before(:all) do
event_doc = { :subject => "Some event", :occurs_at => Time.now }
e = Event.database.save event_doc
@event = Event.get e['id']
end
it "should cast created_at to Time" do
@event['occurs_at'].should be_an_instance_of(Time)
end
end
describe "saving a model" do
before(:all) do
@obj = Basic.new