aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-05-29 00:11:56 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-05-29 00:11:56 +0000
commit06744bb4c5777cae45dca3b0ed4826ab14cbc558 (patch)
treeb98960f3fee88a1ae10f39fdf14da4b527fafd03 /railties/test/generators
parent428d1f67dab05b84330c7fc66bff0202aee91bd8 (diff)
downloadrails-06744bb4c5777cae45dca3b0ed4826ab14cbc558.tar.gz
rails-06744bb4c5777cae45dca3b0ed4826ab14cbc558.tar.bz2
rails-06744bb4c5777cae45dca3b0ed4826ab14cbc558.zip
Generated migrations include timestamps by default. Closes #8501.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6883 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/generator_test_helper.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/railties/test/generators/generator_test_helper.rb b/railties/test/generators/generator_test_helper.rb
index 0bfb2a0964..ee971d9669 100644
--- a/railties/test/generators/generator_test_helper.rb
+++ b/railties/test/generators/generator_test_helper.rb
@@ -128,6 +128,7 @@ module GeneratorTestHelper
# the parsed yaml tree is passed to a block.
def assert_generated_fixtures_for(name)
assert_generated_yaml "test/fixtures/#{name.to_s.underscore}" do |yaml|
+ assert_generated_timestamps(yaml)
yield yaml if block_given?
end
end
@@ -147,7 +148,8 @@ module GeneratorTestHelper
# It takes the name of the migration as a parameter.
# the migration body is passed to a block.
def assert_generated_migration(name,parent="ActiveRecord::Migration")
- assert_generated_class "db/migrate/001_#{name.to_s.underscore}",parent do |body|
+ assert_generated_class "db/migrate/001_#{name.to_s.underscore}",parent do |body|
+ assert body=~/timestamps/, "should have timestamps defined"
yield body if block_given?
end
end
@@ -174,4 +176,13 @@ module GeneratorTestHelper
assert body=~/t\.#{type.to_s} :#{name.to_s}/, "should have column #{name.to_s} defined"
end
+ private
+ # asserts that the default timestamps are created in the fixture
+ def assert_generated_timestamps(yaml)
+ yaml.values.each do |v|
+ ["created_at", "updated_at"].each do |field|
+ assert v.keys.include?(field), "should have #{field} field by default"
+ end
+ end
+ end
end \ No newline at end of file