Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Generate valid default fixtures for models with a type column

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
commit eeb58b0934f646847b3220e3db270bc6b9148919 1 parent 1939fa3
@marcandre marcandre authored spastorino committed
View
2  railties/lib/rails/generators/generated_attribute.rb
@@ -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
View
5 railties/test/generators/generated_attribute_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.