diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-01-18 07:30:42 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-01-18 07:30:42 +0000 |
commit | 42b39ae3f2991692672364d7e09b1e4002e66261 (patch) | |
tree | cddaf1eb2dbf7be27430bde882432db3b1cc0407 /activerecord/test/cases/multiple_db_test.rb | |
parent | 105a27f39ee9dbfd7fdb2b25e5ba38b00708b66c (diff) | |
download | rails-42b39ae3f2991692672364d7e09b1e4002e66261.tar.gz rails-42b39ae3f2991692672364d7e09b1e4002e66261.tar.bz2 rails-42b39ae3f2991692672364d7e09b1e4002e66261.zip |
Move tests to cases
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8660 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/cases/multiple_db_test.rb')
-rw-r--r-- | activerecord/test/cases/multiple_db_test.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/activerecord/test/cases/multiple_db_test.rb b/activerecord/test/cases/multiple_db_test.rb new file mode 100644 index 0000000000..5d64a3efaa --- /dev/null +++ b/activerecord/test/cases/multiple_db_test.rb @@ -0,0 +1,60 @@ +require 'abstract_unit' +require 'fixtures/entrant' + +# So we can test whether Course.connection survives a reload. +require_dependency 'fixtures/course' + +class MultipleDbTest < ActiveSupport::TestCase + self.use_transactional_fixtures = false + + def setup + @courses = create_fixtures("courses") { Course.retrieve_connection } + @entrants = create_fixtures("entrants") + end + + def test_connected + assert_not_nil Entrant.connection + assert_not_nil Course.connection + end + + def test_proper_connection + assert_not_equal(Entrant.connection, Course.connection) + assert_equal(Entrant.connection, Entrant.retrieve_connection) + assert_equal(Course.connection, Course.retrieve_connection) + assert_equal(ActiveRecord::Base.connection, Entrant.connection) + end + + def test_find + c1 = Course.find(1) + assert_equal "Ruby Development", c1.name + c2 = Course.find(2) + assert_equal "Java Development", c2.name + e1 = Entrant.find(1) + assert_equal "Ruby Developer", e1.name + e2 = Entrant.find(2) + assert_equal "Ruby Guru", e2.name + e3 = Entrant.find(3) + assert_equal "Java Lover", e3.name + end + + def test_associations + c1 = Course.find(1) + assert_equal 2, c1.entrants.count + e1 = Entrant.find(1) + assert_equal e1.course.id, c1.id + c2 = Course.find(2) + assert_equal 1, c2.entrants.count + e3 = Entrant.find(3) + assert_equal e3.course.id, c2.id + end + + def test_course_connection_should_survive_dependency_reload + assert Course.connection + + Dependencies.clear + Object.send(:remove_const, :Course) + require_dependency 'fixtures/course' + + assert Course.connection + end +end |