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-4.2.6 spec/cuisine_type_spec.rb
closure_tree-4.2.5 spec/cuisine_type_spec.rb
closure_tree-4.2.4 spec/cuisine_type_spec.rb
closure_tree-4.2.3 spec/cuisine_type_spec.rb
closure_tree-4.2.2 spec/cuisine_type_spec.rb
closure_tree-4.2.1 spec/cuisine_type_spec.rb
closure_tree-4.2.0 spec/cuisine_type_spec.rb
closure_tree-4.1.0 spec/cuisine_type_spec.rb
closure_tree-4.0.1 spec/cuisine_type_spec.rb
closure_tree-4.0.0 spec/cuisine_type_spec.rb
lalala-4.0.0.dev.136 vendor/deps/closure_tree/spec/cuisine_type_spec.rb
lalala-4.0.0.dev.135 vendor/deps/closure_tree/spec/cuisine_type_spec.rb
lalala-4.0.0.dev.134 vendor/deps/closure_tree/spec/cuisine_type_spec.rb
lalala-4.0.0.dev.133 vendor/deps/closure_tree/spec/cuisine_type_spec.rb
lalala-4.0.0.dev.132 vendor/deps/closure_tree/spec/cuisine_type_spec.rb
lalala-4.0.0.dev.131 vendor/deps/closure_tree/spec/cuisine_type_spec.rb
lalala-4.0.0.dev.129 vendor/deps/closure_tree/spec/cuisine_type_spec.rb
lalala-4.0.0.dev.128 vendor/deps/closure_tree/spec/cuisine_type_spec.rb
lalala-4.0.0.dev.126 vendor/deps/closure_tree/spec/cuisine_type_spec.rb
lalala-4.0.0.dev.125 vendor/deps/closure_tree/spec/cuisine_type_spec.rb