blob: 99a5d395038488809f0f3c45f97b84c0964cdef1 (
plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' )
require 'rubygems'
require 'test/unit'
require 'active_record'
require 'active_support'
require 'active_support/test_case'
require 'mocha'
require 'globalize'
# require 'validation_reflection'
config = { :adapter => 'sqlite3', :database => ':memory:' }
ActiveRecord::Base.establish_connection(config)
class ActiveSupport::TestCase
def reset_db!(schema_path = nil)
schema_path ||= File.expand_path(File.dirname(__FILE__) + '/data/schema.rb')
ActiveRecord::Migration.verbose = false
ActiveRecord::Base.silence { load(schema_path) }
end
def assert_member(item, array)
assert_block "Item #{item} is not in array #{array}" do
array.member?(item)
end
end
def assert_belongs_to(model, associated)
assert model.reflect_on_all_associations(:belongs_to).detect { |association|
association.name.to_s == associated.to_s
}
end
def assert_has_many(model, associated)
assert model.reflect_on_all_associations(:has_many).detect { |association|
association.name.to_s == associated.to_s
}
end
end
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
def index_exists?(table_name, column_name)
indexes(table_name).any? { |index| index.name == index_name(table_name, column_name) }
end
end
end
end
# module ActiveRecord
# class BaseWithoutTable < Base
# self.abstract_class = true
#
# def create_or_update
# errors.empty?
# end
#
# class << self
# def columns()
# @columns ||= []
# end
#
# def column(name, sql_type = nil, default = nil, null = true)
# columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
# reset_column_information
# end
#
# # Do not reset @columns
# def reset_column_information
# read_methods.each { |name| undef_method(name) }
# @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil
# end
# end
# end
# end
|