|
Revision 8688, 1.2 kB
(checked in by nzkoz, 9 months ago)
|
Add options missing from earlier changeset
|
| Line | |
|---|
| 1 |
require "active_support/test_case" |
|---|
| 2 |
|
|---|
| 3 |
module ActiveRecord |
|---|
| 4 |
class TestCase < ActiveSupport::TestCase |
|---|
| 5 |
self.fixture_path = FIXTURES_ROOT |
|---|
| 6 |
self.use_instantiated_fixtures = false |
|---|
| 7 |
self.use_transactional_fixtures = true |
|---|
| 8 |
|
|---|
| 9 |
def create_fixtures(*table_names, &block) |
|---|
| 10 |
Fixtures.create_fixtures(FIXTURES_ROOT, table_names, {}, &block) |
|---|
| 11 |
end |
|---|
| 12 |
|
|---|
| 13 |
def assert_date_from_db(expected, actual, message = nil) |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
if current_adapter?(:SQLServerAdapter) |
|---|
| 17 |
assert_equal expected.strftime("%Y/%m/%d 00:00:00"), actual.strftime("%Y/%m/%d 00:00:00") |
|---|
| 18 |
elsif current_adapter?(:SybaseAdapter) |
|---|
| 19 |
assert_equal expected.to_s, actual.to_date.to_s, message |
|---|
| 20 |
else |
|---|
| 21 |
assert_equal expected.to_s, actual.to_s, message |
|---|
| 22 |
end |
|---|
| 23 |
end |
|---|
| 24 |
|
|---|
| 25 |
def assert_queries(num = 1) |
|---|
| 26 |
$query_count = 0 |
|---|
| 27 |
yield |
|---|
| 28 |
ensure |
|---|
| 29 |
assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed." |
|---|
| 30 |
end |
|---|
| 31 |
|
|---|
| 32 |
def assert_no_queries(&block) |
|---|
| 33 |
assert_queries(0, &block) |
|---|
| 34 |
end |
|---|
| 35 |
end |
|---|
| 36 |
end |
|---|