aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/inclusion_test.rb
blob: d092e748e82a13c45f21cdc3e279f5b682ac6f24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'cases/helper'
require 'models/teapot'

class BasicInclusionModelTest < ActiveRecord::TestCase
  def test_basic_model
    Teapot.create!(:name => "Ronnie Kemper")
    assert_equal "Ronnie Kemper", Teapot.find(1).name
  end

  def test_inherited_model
    teapot = CoolTeapot.create!(:name => "Bob")
    teapot.reload

    assert_equal "Bob", teapot.name
    assert_equal "mmm", teapot.aaahhh
  end
end

class InclusionUnitTest < ActiveRecord::TestCase
  def setup
    @klass = Class.new { include ActiveRecord::Model }
  end

  def test_non_abstract_class
    assert !@klass.abstract_class?
  end

  def test_abstract_class
    @klass.abstract_class = true
    assert @klass.abstract_class?
  end

  def test_establish_connection
    assert @klass.respond_to?(:establish_connection)
  end

  def test_adapter_connection
    assert @klass.respond_to?("#{ActiveRecord::Base.connection_config[:adapter]}_connection")
  end

  def test_connection_handler
    assert_equal ActiveRecord::Base.connection_handler, @klass.connection_handler
  end
end