Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Generate valid default fixtures for models with a type column
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information
marcandre authored and spastorino committed Jul 11, 2011
1 parent 1939fa3 commit eeb58b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion railties/lib/rails/generators/generated_attribute.rb
Expand Up @@ -32,7 +32,7 @@ def default
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
Expand Down
5 changes: 5 additions & 0 deletions railties/test/generators/generated_attribute_test.rb
Expand Up @@ -68,6 +68,11 @@ def test_default_value_is_string
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
Expand Down

0 comments on commit eeb58b0

Please sign in to comment.