1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Generate valid default fixtures for models with a type column

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
Marc-Andre Lafortune 2011-03-05 16:25:20 -05:00 committed by Santiago Pastorino
parent 1939fa3f16
commit eeb58b0934
2 changed files with 6 additions and 1 deletions

View file

@ -32,7 +32,7 @@ module Rails
when :decimal then "9.99"
when :datetime, :timestamp, :time then Time.now.to_s(:db)
when :date then Date.today.to_s(:db)
when :string then "MyString"
when :string then name == "type" ? "" : "MyString"
when :text then "MyText"
when :boolean then false
when :references, :belongs_to then nil

View file

@ -68,6 +68,11 @@ class GeneratedAttributeTest < Rails::Generators::TestCase
assert_field_default_value :string, 'MyString'
end
def test_default_value_for_type
att = Rails::Generators::GeneratedAttribute.new("type", "string")
assert_equal("", att.default)
end
def test_default_value_is_text
assert_field_default_value :text, 'MyText'
end