Skip to content
This repository
Browse code

Merge [6023] from trunk. References #7330.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@6024 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit c9ed2f64ae7d9c4e5d8f389cfb773310c942272e 1 parent 70f4a92
Jeremy Kemper jeremy authored
2  activerecord/CHANGELOG
... ... @@ -1,5 +1,7 @@
1 1 *SVN*
2 2
  3 +* Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden]
  4 +
3 5 * SQLServer: quote table name in indexes query. #2928 [keithm@infused.org]
4 6
5 7
2  activerecord/lib/active_record/fixtures.rb
@@ -276,6 +276,8 @@ def initialize(connection, table_name, class_name, fixture_path, file_filter = D
276 276 @class_name = class_name ||
277 277 (ActiveRecord::Base.pluralize_table_names ? @table_name.singularize.camelize : @table_name.camelize)
278 278 @table_name = ActiveRecord::Base.table_name_prefix + @table_name + ActiveRecord::Base.table_name_suffix
  279 + @table_name = class_name.table_name if class_name.respond_to?(:table_name)
  280 + @connection = class_name.connection if class_name.respond_to?(:connection)
279 281 read_fixture_files
280 282 end
281 283
11 activerecord/test/fixtures_test.rb
@@ -5,6 +5,7 @@
5 5 require 'fixtures/task'
6 6 require 'fixtures/reply'
7 7 require 'fixtures/joke'
  8 +require 'fixtures/course'
8 9 require 'fixtures/category'
9 10
10 11 class FixturesTest < Test::Unit::TestCase
@@ -334,6 +335,16 @@ def test_table_method
334 335 end
335 336 end
336 337
  338 +class CustomConnectionFixturesTest < Test::Unit::TestCase
  339 + set_fixture_class :courses => Course
  340 + fixtures :courses
  341 +
  342 + def test_connection
  343 + assert_kind_of Course, courses(:ruby)
  344 + assert_equal Course.connection, courses(:ruby).connection
  345 + end
  346 +end
  347 +
337 348 class InvalidTableNameFixturesTest < Test::Unit::TestCase
338 349 fixtures :funny_jokes
339 350

0 comments on commit c9ed2f6

Please sign in to comment.
Something went wrong with that request. Please try again.