Sha256: abefcd572691788bb63a6ca079c485fed4b81a8c6640b0b2427fa461dc85942d

Contents?: true

Size: 794 Bytes

Versions: 7

Compression:

Stored size: 794 Bytes

Contents

require 'spec_helper'

def assert_lineage(e, m)
  m.parent.should == e
  m.self_and_ancestors.should == [m, e]

  # make sure reloading doesn't affect the self_and_ancestors:
  m.reload
  m.self_and_ancestors.should == [m, e]
end

describe CuisineType do
  it "finds self and parents when children << is used" do
    e = CuisineType.new(:name => "e")
    m = CuisineType.new(:name => "m")
    e.children << m
    e.save
    assert_lineage(e, m)
  end

  it "finds self and parents properly if the constructor is used" do
    e = CuisineType.create(:name => "e")
    m = CuisineType.create(:name => "m", :parent => e)
    assert_lineage(e, m)
  end

  it "sets the table_name of the hierarchy class properly" do
    CuisineTypeHierarchy.table_name.should == "cuisine_type_hierarchies"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
closure_tree-3.5.2 spec/cuisine_type_spec.rb
closure_tree-3.5.1 spec/cuisine_type_spec.rb
closure_tree-3.5.0 spec/cuisine_type_spec.rb
closure_tree-3.4.3 spec/cuisine_type_spec.rb
closure_tree-3.4.2 spec/cuisine_type_spec.rb
closure_tree-3.4.1 spec/cuisine_type_spec.rb
closure_tree-3.4.0 spec/cuisine_type_spec.rb