diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-12-23 21:47:58 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-12-24 11:08:15 +0000 |
commit | 649869557a9592af5767b0ad3ae65d84fa0c0eb9 (patch) | |
tree | 280afd21f54530c0a180b02958085eddb6f81fa8 /activerecord | |
parent | ba7ec73f6a5c98c008e8e48eb06e9b9a17a91991 (diff) | |
download | rails-649869557a9592af5767b0ad3ae65d84fa0c0eb9.tar.gz rails-649869557a9592af5767b0ad3ae65d84fa0c0eb9.tar.bz2 rails-649869557a9592af5767b0ad3ae65d84fa0c0eb9.zip |
Fixtures support for ActiveRecord::Model
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/fixtures.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/inclusion_test.rb | 12 | ||||
-rw-r--r-- | activerecord/test/fixtures/teapots.yml | 3 | ||||
-rw-r--r-- | activerecord/test/schema/schema.rb | 1 |
4 files changed, 17 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index da72d1718e..65c7f3afbb 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -559,7 +559,7 @@ module ActiveRecord rows[table_name] = fixtures.map do |label, fixture| row = fixture.to_hash - if model_class && model_class < ActiveRecord::Base + if model_class && model_class < ActiveRecord::Model # fill in timestamp columns if they aren't specified and the model is set to record_timestamps if model_class.record_timestamps timestamp_column_names.each do |name| diff --git a/activerecord/test/cases/inclusion_test.rb b/activerecord/test/cases/inclusion_test.rb index ee32a71ca9..2302761205 100644 --- a/activerecord/test/cases/inclusion_test.rb +++ b/activerecord/test/cases/inclusion_test.rb @@ -51,3 +51,15 @@ class InclusionUnitTest < ActiveRecord::TestCase ActiveRecord::Base.time_zone_aware_attributes = false end end + +class InclusionFixturesTest < ActiveRecord::TestCase + fixtures :teapots + + def test_fixtured_record + assert_equal "Bob", teapots(:bob).name + end + + def test_timestamped_fixture + assert_not_nil teapots(:bob).created_at + end +end diff --git a/activerecord/test/fixtures/teapots.yml b/activerecord/test/fixtures/teapots.yml new file mode 100644 index 0000000000..ff515beb45 --- /dev/null +++ b/activerecord/test/fixtures/teapots.yml @@ -0,0 +1,3 @@ +bob: + id: 1 + name: Bob diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index 09c8c25d74..8706732230 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -598,6 +598,7 @@ ActiveRecord::Schema.define do create_table :teapots, :force => true do |t| t.string :name + t.timestamps end create_table :topics, :force => true do |t| |