Sha256: e55b3e948b0c105c536f1edf8890a1dd6cc8bc9774aa958d70269b2b1dd66a10
Contents?: true
Size: 978 Bytes
Versions: 3
Compression:
Stored size: 978 Bytes
Contents
require File.dirname(__FILE__) + "/spec_helper" describe('A tree') do before(:all) do class Node < DataMapper::Base property :name, :string belongs_to :parent, :class => 'Node' has_many :children, :class => 'Node', :foreign_key => 'parent_id' end database.schema[Node].drop! database.save(Node) end it 'should work' do root = Node.new(:name => 'root') one = Node.new(:name => 'one') two = Node.new(:name => 'two') root.children << one << two one_one = Node.new(:name => 'one_one') one_two = Node.new(:name => 'one_two') one.children << one_one << one_two two_one = Node.new(:name => 'two_one') two_two = Node.new(:name => 'two_two') two.children << two_one << two_two root.save grand = Node[:name => 'root'] root.should_not == grand # false since +root+ and +grand+ are in different sessions. grand.children[0].children[0].name.should == 'one_one' end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
datamapper-0.2.1 | spec/acts_as_tree_spec.rb |
datamapper-0.2.2 | spec/acts_as_tree_spec.rb |
datamapper-0.2.3 | spec/acts_as_tree_spec.rb |