Merge branch 'master' of https://github.com/kanterov/couchrest_model into kanterov
This commit is contained in:
commit
363461fc9d
|
@ -53,6 +53,13 @@ module CouchRest::Model
|
||||||
end
|
end
|
||||||
alias :to_key :id
|
alias :to_key :id
|
||||||
alias :to_param :id
|
alias :to_param :id
|
||||||
|
|
||||||
|
# Fixes belongs_to assocations.
|
||||||
|
# See it "should allow to reference association by id in casted model" in
|
||||||
|
# assocations_spec.rb
|
||||||
|
def model_proxy
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
# Sets the attributes from a hash
|
# Sets the attributes from a hash
|
||||||
def update_attributes_without_saving(hash)
|
def update_attributes_without_saving(hash)
|
||||||
|
|
|
@ -64,6 +64,22 @@ describe "Assocations" do
|
||||||
@invoice.alternate_client.id.should eql(@client.id)
|
@invoice.alternate_client.id.should eql(@client.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should allow to reference association by id in casted model" do
|
||||||
|
class Money < Hash
|
||||||
|
include CouchRest::Model::CastedModel
|
||||||
|
|
||||||
|
property :value, Integer
|
||||||
|
belongs_to :client
|
||||||
|
end
|
||||||
|
|
||||||
|
money = Money.new :value => 1000
|
||||||
|
|
||||||
|
money.client_id = @client.id
|
||||||
|
|
||||||
|
money.client.should eql(@client)
|
||||||
|
money.valid?.should be_true
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "of type collection_of" do
|
describe "of type collection_of" do
|
||||||
|
|
Loading…
Reference in a new issue