Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 jeremy authored
View
2  activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden]
+
* SQLServer: quote table name in indexes query. #2928 [keithm@infused.org]
View
2  activerecord/lib/active_record/fixtures.rb
@@ -276,6 +276,8 @@ def initialize(connection, table_name, class_name, fixture_path, file_filter = D
@class_name = class_name ||
(ActiveRecord::Base.pluralize_table_names ? @table_name.singularize.camelize : @table_name.camelize)
@table_name = ActiveRecord::Base.table_name_prefix + @table_name + ActiveRecord::Base.table_name_suffix
+ @table_name = class_name.table_name if class_name.respond_to?(:table_name)
+ @connection = class_name.connection if class_name.respond_to?(:connection)
read_fixture_files
end
View
11 activerecord/test/fixtures_test.rb
@@ -5,6 +5,7 @@
require 'fixtures/task'
require 'fixtures/reply'
require 'fixtures/joke'
+require 'fixtures/course'
require 'fixtures/category'
class FixturesTest < Test::Unit::TestCase
@@ -334,6 +335,16 @@ def test_table_method
end
end
+class CustomConnectionFixturesTest < Test::Unit::TestCase
+ set_fixture_class :courses => Course
+ fixtures :courses
+
+ def test_connection
+ assert_kind_of Course, courses(:ruby)
+ assert_equal Course.connection, courses(:ruby).connection
+ end
+end
+
class InvalidTableNameFixturesTest < Test::Unit::TestCase
fixtures :funny_jokes
Please sign in to comment.
Something went wrong with that request. Please try again.