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 f4858e4639fb68a1a86ae167c12a4bda277790d4 1 parent a9980d1
@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

0 comments on commit f4858e4

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