diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/column_alias_test.rb | 20 | ||||
-rw-r--r-- | activerecord/test/conditions_scoping_test.rb | 3 | ||||
-rw-r--r-- | activerecord/test/finder_test.rb | 2 | ||||
-rwxr-xr-x | activerecord/test/fixtures_test.rb | 44 |
4 files changed, 53 insertions, 16 deletions
diff --git a/activerecord/test/column_alias_test.rb b/activerecord/test/column_alias_test.rb index fbc93f1034..729a252eef 100644 --- a/activerecord/test/column_alias_test.rb +++ b/activerecord/test/column_alias_test.rb @@ -2,18 +2,16 @@ require 'abstract_unit' require 'fixtures/topic' class TestColumnAlias < Test::Unit::TestCase + fixtures :topics + + QUERY = if 'OCI' == ActiveRecord::Base.connection.adapter_name + 'SELECT id AS pk FROM topics WHERE ROWNUM < 2' + else + 'SELECT id AS pk FROM topics' + end def test_column_alias - topic = Topic.find(1) - if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter - if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter) - records = topic.connection.select_all("SELECT id AS pk FROM topics WHERE ROWNUM < 2") - assert_equal("pk", records[0].keys[0]) - end - else - records = topic.connection.select_all("SELECT id AS pk FROM topics") - assert_equal("pk", records[0].keys[0]) - end + records = Topic.connection.select_all(QUERY) + assert_equal 'pk', records[0].keys[0] end - end diff --git a/activerecord/test/conditions_scoping_test.rb b/activerecord/test/conditions_scoping_test.rb index bf6ddc52d1..4fc9aad64e 100644 --- a/activerecord/test/conditions_scoping_test.rb +++ b/activerecord/test/conditions_scoping_test.rb @@ -69,7 +69,7 @@ end class HasAndBelongsToManyScopingTest< Test::Unit::TestCase - fixtures :posts, :categories + fixtures :posts, :categories, :categories_posts def setup @welcome = Post.find(1) @@ -85,7 +85,6 @@ class HasAndBelongsToManyScopingTest< Test::Unit::TestCase assert_equal 0, @welcome.categories.find_all_by_type('SpecialCategory').size assert_equal 2, @welcome.categories.find_all_by_type('Category').size end - end diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index 5ac6f2348c..26a34162d3 100644 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -6,7 +6,7 @@ require 'fixtures/developer' require 'fixtures/post' class FinderTest < Test::Unit::TestCase - fixtures :companies, :topics, :entrants, :developers, :posts + fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts def test_find assert_equal(topics(:first).title, Topic.find(1).title) diff --git a/activerecord/test/fixtures_test.rb b/activerecord/test/fixtures_test.rb index 0e3176725b..ef931ea873 100755 --- a/activerecord/test/fixtures_test.rb +++ b/activerecord/test/fixtures_test.rb @@ -86,6 +86,7 @@ class FixturesTest < Test::Unit::TestCase secondRow = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'") assert_nil(secondRow["author_email_address"]) ensure + Fixtures.all_loaded_fixtures.delete(topics) ActiveRecord::Base.connection.drop_table :prefix_topics_suffix rescue nil end @@ -259,7 +260,7 @@ class MultipleFixturesTest < Test::Unit::TestCase fixtures :developers, :accounts def test_fixture_table_names - assert_equal([:topics, :developers, :accounts], fixture_table_names) + assert_equal %w(topics developers accounts), fixture_table_names end end @@ -269,7 +270,7 @@ class OverlappingFixturesTest < Test::Unit::TestCase fixtures :developers, :accounts def test_fixture_table_names - assert_equal([:topics, :developers, :accounts], fixture_table_names) + assert_equal %w(topics developers accounts), fixture_table_names end end @@ -289,3 +290,42 @@ class ForeignKeyFixturesTest < Test::Unit::TestCase assert true end end + + +class FixtureCleanup1Test < Test::Unit::TestCase + fixtures :topics + + def test_isolation + assert_equal 0, Developer.count + assert_equal 2, Topic.count + end +end + +class FixtureCleanup2Test < Test::Unit::TestCase + fixtures :developers + + def test_isolation + assert_equal 0, Topic.count + assert_equal 10, Developer.count + end +end + +class FixtureCleanup3Test < FixtureCleanup2Test + self.use_transactional_fixtures = false + + def test_dirty_fixture_table_names + assert_equal %w(developers), dirty_fixture_table_names + assert_equal %w(developers), loaded_fixture_table_names + assert_equal %w(developers), fixture_table_names + end +end + +class FixtureCleanup4Test < FixtureCleanup2Test + self.use_transactional_fixtures = true + + def test_dirty_fixture_table_names + assert_equal [], dirty_fixture_table_names + assert_equal %w(developers), loaded_fixture_table_names + assert_equal %w(developers), fixture_table_names + end +end |