Skip to content
Browse files

Fixtures support for ActiveRecord::Model

  • Loading branch information...
1 parent ba7ec73 commit 649869557a9592af5767b0ad3ae65d84fa0c0eb9 @jonleighton jonleighton committed Dec 23, 2011
View
2 activerecord/lib/active_record/fixtures.rb
@@ -559,7 +559,7 @@ def table_rows
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|
View
12 activerecord/test/cases/inclusion_test.rb
@@ -51,3 +51,15 @@ def test_mirrored_configuration
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
View
3 activerecord/test/fixtures/teapots.yml
@@ -0,0 +1,3 @@
+bob:
+ id: 1
+ name: Bob
View
1 activerecord/test/schema/schema.rb
@@ -598,6 +598,7 @@ def create_table(*args, &block)
create_table :teapots, :force => true do |t|
t.string :name
+ t.timestamps
end
create_table :topics, :force => true do |t|

0 comments on commit 6498695

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