aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorJeff Kreeftmeijer <jeff@kreeftmeijer.nl>2010-05-16 11:20:11 +0200
committerJosé Valim <jose.valim@gmail.com>2010-05-16 12:07:22 +0200
commit5ff6de0982c165bb9038258d867398c73c142084 (patch)
tree0ebdcbe4d67b660a199bdace641a86a5f3ad04cf /railties/test
parent99b38f371a17eb3965f794227279e89fb6c694a6 (diff)
downloadrails-5ff6de0982c165bb9038258d867398c73c142084.tar.gz
rails-5ff6de0982c165bb9038258d867398c73c142084.tar.bz2
rails-5ff6de0982c165bb9038258d867398c73c142084.zip
Added assert_attribute_type to clean up GeneratedAttributeTest [#2377 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/generated_attribute_test.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/railties/test/generators/generated_attribute_test.rb b/railties/test/generators/generated_attribute_test.rb
new file mode 100644
index 0000000000..ccd0c65905
--- /dev/null
+++ b/railties/test/generators/generated_attribute_test.rb
@@ -0,0 +1,40 @@
+require 'generators/generators_test_helper'
+require 'rails/generators/generated_attribute'
+
+class GeneratedAttributeTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
+
+ def test_field_type_returns_text_field
+ %w(integer float decimal string).each do |name|
+ assert_attribute_type name, :text_field
+ end
+ end
+
+ def test_field_type_returns_datetime_select
+ %w(datetime timestamp).each do |name|
+ assert_attribute_type name, :datetime_select
+ end
+ end
+
+ def test_field_type_returns_time_select
+ assert_attribute_type 'time', :time_select
+ end
+
+ def test_field_type_returns_date_select
+ assert_attribute_type 'date', :date_select
+ end
+
+ def test_field_type_returns_text_area
+ assert_attribute_type 'text', :text_area
+ end
+
+ def test_field_type_returns_check_box
+ assert_attribute_type 'boolean', :check_box
+ end
+
+ def test_field_type_with_unknown_type_returns_text_field
+ %w(foo bar baz).each do |name|
+ assert_attribute_type name, :text_field
+ end
+ end
+end