Sha256: 7c414d3a18958ce16015680b20202ae6e26bb6f75ee9b713e894e8b3c3b14d98

Contents?: true

Size: 872 Bytes

Versions: 75

Compression:

Stored size: 872 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 == ActiveRecord::Base.table_name_prefix + "cuisine_type_hierarchies" + ActiveRecord::Base.table_name_suffix
  end
end

Version data entries

75 entries across 75 versions & 2 rubygems

Version Path
closure_tree-3.8.0 spec/cuisine_type_spec.rb
closure_tree-3.7.3 spec/cuisine_type_spec.rb
closure_tree-3.7.2 spec/cuisine_type_spec.rb
closure_tree-3.7.1 spec/cuisine_type_spec.rb
closure_tree-3.7.0 spec/cuisine_type_spec.rb
closure_tree-3.6.9 spec/cuisine_type_spec.rb
closure_tree-3.6.8 spec/cuisine_type_spec.rb
closure_tree-3.6.7 spec/cuisine_type_spec.rb
closure_tree-3.6.6 spec/cuisine_type_spec.rb
closure_tree-3.6.5 spec/cuisine_type_spec.rb
closure_tree-3.6.4 spec/cuisine_type_spec.rb
closure_tree-3.6.3 spec/cuisine_type_spec.rb
closure_tree-3.6.2 spec/cuisine_type_spec.rb
closure_tree-3.6.1 spec/cuisine_type_spec.rb
closure_tree-3.6.0 spec/cuisine_type_spec.rb