aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorCarlos Galdino <carloshsgaldino@gmail.com>2012-05-16 19:20:32 -0300
committerCarlos Galdino <carloshsgaldino@gmail.com>2012-05-21 17:23:48 -0300
commit1ce4b5b33d694eeebdb0495aef70d8d1b50cd02d (patch)
tree0676fe1ca8520a02cb3e97bc279a74c84ff155ef /actionpack/test/template
parent513a0525c24c2944630acfa465b22cd2f4601adf (diff)
downloadrails-1ce4b5b33d694eeebdb0495aef70d8d1b50cd02d.tar.gz
rails-1ce4b5b33d694eeebdb0495aef70d8d1b50cd02d.tar.bz2
rails-1ce4b5b33d694eeebdb0495aef70d8d1b50cd02d.zip
Add HTML5 input[type="color"] helper
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/form_helper_test.rb13
-rw-r--r--actionpack/test/template/form_tag_helper_test.rb5
2 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 27cc3ad48a..76a18fa76a 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -83,6 +83,8 @@ class FormHelperTest < ActionView::TestCase
@post.tags << Tag.new
@blog_post = Blog::Post.new("And his name will be forty and four.", 44)
+
+ @car = Car.new("#000FFF")
end
Routes = ActionDispatch::Routing::RouteSet.new
@@ -610,6 +612,17 @@ class FormHelperTest < ActionView::TestCase
)
end
+ def test_color_field_with_valid_hex_color_string
+ expected = %{<input id="car_color" name="car[color]" type="color" value="#000fff" />}
+ assert_dom_equal(expected, color_field("car", "color"))
+ end
+
+ def test_color_field_with_invalid_hex_color_string
+ expected = %{<input id="car_color" name="car[color]" type="color" value="#000000" />}
+ @car.color = "#1234TR"
+ assert_dom_equal(expected, color_field("car", "color"))
+ end
+
def test_search_field
expected = %{<input id="contact_notes_query" name="contact[notes_query]" type="search" />}
assert_dom_equal(expected, search_field("contact", "notes_query"))
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb
index 6574e13558..195adce180 100644
--- a/actionpack/test/template/form_tag_helper_test.rb
+++ b/actionpack/test/template/form_tag_helper_test.rb
@@ -444,6 +444,11 @@ class FormTagHelperTest < ActionView::TestCase
)
end
+ def test_color_field_tag
+ expected = %{<input id="car" name="car" type="color" />}
+ assert_dom_equal(expected, color_field_tag("car"))
+ end
+
def test_search_field_tag
expected = %{<input id="query" name="query" type="search" />}
assert_dom_equal(expected, search_field_tag("query"))