Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added assert_attribute_type to clean up GeneratedAttributeTest [#2377 …
…state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |