diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-11-26 22:45:43 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-11-26 22:45:43 +0000 |
commit | 8b3f83105ce719642a8f079f72c4f03c97cfc321 (patch) | |
tree | 86fd9a3b6e69a25cbddb904ce8d3bb5edb4eca34 /activerecord/test/fixtures_test.rb | |
parent | 1370d1578727bdbfee06ccdf2109e8ca5649a652 (diff) | |
download | rails-8b3f83105ce719642a8f079f72c4f03c97cfc321.tar.gz rails-8b3f83105ce719642a8f079f72c4f03c97cfc321.tar.bz2 rails-8b3f83105ce719642a8f079f72c4f03c97cfc321.zip |
Foxy fixtures: allow mixed usage to make migration easier and more attractive. Closes #10004.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8218 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/fixtures_test.rb')
-rwxr-xr-x | activerecord/test/fixtures_test.rb | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/activerecord/test/fixtures_test.rb b/activerecord/test/fixtures_test.rb index de0321fbf4..d51a4029bc 100755 --- a/activerecord/test/fixtures_test.rb +++ b/activerecord/test/fixtures_test.rb @@ -1,5 +1,8 @@ require 'abstract_unit' +require 'fixtures/post' +require 'fixtures/binary' require 'fixtures/topic' +require 'fixtures/computer' require 'fixtures/developer' require 'fixtures/company' require 'fixtures/task' @@ -11,6 +14,7 @@ require 'fixtures/parrot' require 'fixtures/pirate' require 'fixtures/treasure' require 'fixtures/matey' +require 'fixtures/ship' class FixturesTest < Test::Unit::TestCase self.use_instantiated_fixtures = true @@ -452,7 +456,7 @@ class FasterFixturesTest < Test::Unit::TestCase end class FoxyFixturesTest < Test::Unit::TestCase - fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys + fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers, :developers def test_identifies_strings assert_equal(Fixtures.identify("foo"), Fixtures.identify("foo")) @@ -471,6 +475,12 @@ class FoxyFixturesTest < Test::Unit::TestCase end end + def test_does_not_populate_timestamp_columns_if_model_has_set_record_timestamps_to_false + TIMESTAMP_COLUMNS.each do |property| + assert_nil(ships(:black_pearl).send(property), "should not set #{property}") + end + end + def test_populates_all_columns_with_the_same_time last = nil @@ -498,10 +508,22 @@ class FoxyFixturesTest < Test::Unit::TestCase assert_not_equal(parrots(:george).id, parrots(:louis).id) end + def test_automatically_sets_primary_key + assert_not_nil(ships(:black_pearl)) + end + + def test_preserves_existing_primary_key + assert_equal(2, ships(:interceptor).id) + end + def test_resolves_belongs_to_symbols assert_equal(parrots(:george), pirates(:blackbeard).parrot) end + def test_ignores_belongs_to_symbols_if_association_and_foreign_key_are_named_the_same + assert_equal(developers(:david), computers(:workstation).developer) + end + def test_supports_join_tables assert(pirates(:blackbeard).parrots.include?(parrots(:george))) assert(pirates(:blackbeard).parrots.include?(parrots(:louis))) @@ -514,6 +536,12 @@ class FoxyFixturesTest < Test::Unit::TestCase assert(!parrots(:george).treasures.include?(treasures(:ruby))) end + def test_supports_inline_habtm_with_specified_id + assert(parrots(:polly).treasures.include?(treasures(:ruby))) + assert(parrots(:polly).treasures.include?(treasures(:sapphire))) + assert(!parrots(:polly).treasures.include?(treasures(:diamond))) + end + def test_supports_yaml_arrays assert(parrots(:louis).treasures.include?(treasures(:diamond))) assert(parrots(:louis).treasures.include?(treasures(:sapphire))) @@ -550,4 +578,4 @@ class ActiveSupportSubclassWithFixturesTest < ActiveSupport::TestCase def test_foo assert_equal parrots(:louis), Parrot.find_by_name("King Louis") end -end
\ No newline at end of file +end |