blob: 79e842f5e149a7e7535310baf7a3333ff7382eae (
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
45
46
47
48
49
50
51
52
53
54
55
|
require "cases/helper"
module ActiveRecord
module ConnectionAdapters
class SchemaCacheTest < ActiveRecord::TestCase
def setup
connection = ActiveRecord::Base.connection
@cache = SchemaCache.new connection
if in_memory_db?
connection.create_table :posts do |t|
t.integer :cololumn
end
end
end
def test_primary_key
assert_equal 'id', @cache.primary_keys['posts']
end
def test_primary_key_for_non_existent_table
assert_equal 'id', @cache.primary_keys['omgponies']
end
def test_primary_key_is_set_on_columns
posts_columns = @cache.columns_hash['posts']
assert posts_columns['id'].primary
(posts_columns.keys - ['id']).each do |key|
assert !posts_columns[key].primary
end
end
def test_caches_columns
columns = @cache.columns['posts']
assert_equal columns, @cache.columns['posts']
end
def test_caches_columns_hash
columns_hash = @cache.columns_hash['posts']
assert_equal columns_hash, @cache.columns_hash['posts']
end
def test_clearing_column_cache
@cache.columns['posts']
@cache.columns_hash['posts']
@cache.clear!
assert_equal 0, @cache.columns.size
assert_equal 0, @cache.columns_hash.size
end
end
end
end
|