aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-12-09 17:01:03 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-12-10 00:01:41 -0300
commit95ccbd847da149b194cbf423e04e3d19a812dce4 (patch)
treef6dbbb9015c8125b853aaa7743b727b685dbc0b8 /railties/test/generators
parent80735ff4c059d634e5eb3a83ce6a0bb8bda5cd8e (diff)
downloadrails-95ccbd847da149b194cbf423e04e3d19a812dce4.tar.gz
rails-95ccbd847da149b194cbf423e04e3d19a812dce4.tar.bz2
rails-95ccbd847da149b194cbf423e04e3d19a812dce4.zip
Add GeneratedAttribute#column_name to get the name of the column in the
database
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/generated_attribute_test.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/railties/test/generators/generated_attribute_test.rb b/railties/test/generators/generated_attribute_test.rb
index 6ab1cd58c7..d08e650b62 100644
--- a/railties/test/generators/generated_attribute_test.rb
+++ b/railties/test/generators/generated_attribute_test.rb
@@ -117,13 +117,13 @@ class GeneratedAttributeTest < Rails::Generators::TestCase
assert create_generated_attribute("#{attribute_type}{polymorphic}").polymorphic?
end
end
-
+
def test_polymorphic_reference_is_false
%w(foo bar baz).each do |attribute_type|
assert !create_generated_attribute("#{attribute_type}{polymorphic}").polymorphic?
end
end
-
+
def test_blank_type_defaults_to_string_raises_exception
assert_equal :string, create_generated_attribute(nil, 'title').type
assert_equal :string, create_generated_attribute("", 'title').type
@@ -132,6 +132,13 @@ class GeneratedAttributeTest < Rails::Generators::TestCase
def test_handles_index_names_for_references
assert_equal "post", create_generated_attribute('string', 'post').index_name
assert_equal "post_id", create_generated_attribute('references', 'post').index_name
+ assert_equal "post_id", create_generated_attribute('belongs_to', 'post').index_name
assert_equal ["post_id", "post_type"], create_generated_attribute('references{polymorphic}', 'post').index_name
end
+
+ def test_handles_index_names_for_references
+ assert_equal "post", create_generated_attribute('string', 'post').column_name
+ assert_equal "post_id", create_generated_attribute('references', 'post').column_name
+ assert_equal "post_id", create_generated_attribute('belongs_to', 'post').column_name
+ end
end