diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-24 01:29:49 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-24 01:29:49 +0000 |
commit | 0eb8398cfa6d4abf20c85fa59fa1a284dd992172 (patch) | |
tree | d87f26f88f28146450a7e2286bb5ce8adf993535 /activerecord | |
parent | be7f86e37ac21585ad2621e2e0938c68a7a71360 (diff) | |
download | rails-0eb8398cfa6d4abf20c85fa59fa1a284dd992172.tar.gz rails-0eb8398cfa6d4abf20c85fa59fa1a284dd992172.tar.bz2 rails-0eb8398cfa6d4abf20c85fa59fa1a284dd992172.zip |
Fixtures use the table name and connection from set_fixture_class. Closes #7330.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6023 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/fixtures.rb | 2 | ||||
-rwxr-xr-x | activerecord/test/fixtures_test.rb | 11 |
3 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 717cd8364d..004941566c 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixtures use the table name and connection from set_fixture_class. #7330 [Anthony Eden] + * Remove useless code in #attribute_present? since 0 != blank?. Closes #7249 [Josh Susser] * Fix minor doc typos. Closes #7157 [Josh Susser] diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 06e39e0829..cf05b63779 100755 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -276,6 +276,8 @@ class Fixtures < YAML::Omap @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 diff --git a/activerecord/test/fixtures_test.rb b/activerecord/test/fixtures_test.rb index 96788a09bd..35882526a1 100755 --- a/activerecord/test/fixtures_test.rb +++ b/activerecord/test/fixtures_test.rb @@ -5,6 +5,7 @@ require 'fixtures/company' require 'fixtures/task' require 'fixtures/reply' require 'fixtures/joke' +require 'fixtures/course' require 'fixtures/category' class FixturesTest < Test::Unit::TestCase @@ -334,6 +335,16 @@ class SetTableNameFixturesTest < Test::Unit::TestCase 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 |