Sha256: 1e73771e3eff9ce8d1b3eb30c944eda71e377bb6477ca301dafdea60add6fc16
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'spec_helper' describe DataMapper::NestedAttributes::Resource do before(:all) do class ::Project include DataMapper::Resource extend ConstraintSupport property :id, Integer, :key => true, :min => 0 property :name, String, :required => true has n, :memberships, constraint(:destroy) has n, :people, :through => :memberships end class ::Person include DataMapper::Resource extend ConstraintSupport property :id, Integer, :key => true, :min => 0 property :name, String, :required => true has n, :memberships, constraint(:destroy) has n, :projects, :through => :memberships accepts_nested_attributes_for :memberships, :allow_destroy => true end class ::Membership include DataMapper::Resource property :person_id, Integer, :key => true, :min => 0 property :project_id, Integer, :key => true, :min => 0 property :role, String, :required => true belongs_to :person belongs_to :project accepts_nested_attributes_for :person accepts_nested_attributes_for :project end DataMapper.auto_migrate! end before(:each) do Membership.all.destroy! Person.all.destroy! Project.all.destroy! end describe "#uncreatable_keys" do it "includes delete marker" do Person.new.send(:uncreatable_keys).should == [:_delete] Membership.new.send(:uncreatable_keys).should == [:_delete] end end describe "#unupdateable_keys" do it "includes primary keys and delete marker" do Person.new.send(:unupdatable_keys).should == [:id, :_delete] Membership.new.send(:unupdatable_keys).should == [:person_id, :project_id, :_delete] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dm-accepts_nested_attributes_for-1.2.0 | spec/resource_spec.rb |