aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/form_helper_test.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-14 16:46:04 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-14 16:46:04 -0700
commitb67990cf342fb1d8f9ecab532db7e5b884981d7d (patch)
treed64486fb5d72094d797bf51342dc4d0da9dc71cc /actionview/test/template/form_helper_test.rb
parent99b6cf538145fb34c08f81a6fc495e7fbb0510ae (diff)
downloadrails-b67990cf342fb1d8f9ecab532db7e5b884981d7d.tar.gz
rails-b67990cf342fb1d8f9ecab532db7e5b884981d7d.tar.bz2
rails-b67990cf342fb1d8f9ecab532db7e5b884981d7d.zip
Add tests with an explanation of why we're using `_before_type_cast`
If you entered incorrect input into a form (particularly with a numericality validation), we should not replace what you typed in with `0`, since clicking submit a second time would essentially be the same as erroneously accepting the junk input as 0.
Diffstat (limited to 'actionview/test/template/form_helper_test.rb')
-rw-r--r--actionview/test/template/form_helper_test.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb
index fff1e1e572..fa8d11d08b 100644
--- a/actionview/test/template/form_helper_test.rb
+++ b/actionview/test/template/form_helper_test.rb
@@ -99,7 +99,8 @@ class FormHelperTest < ActionView::TestCase
}.new
end
def @post.to_key; [123]; end
- def @post.id_before_type_cast; 123; end
+ def @post.id; 0; end
+ def @post.id_before_type_cast; "omg"; end
def @post.to_param; '123'; end
@post.persisted = true
@@ -900,9 +901,9 @@ class FormHelperTest < ActionView::TestCase
)
end
- def test_text_area_with_value_before_type_cast
+ def test_inputs_use_before_type_cast_to_retain_information_from_validations_like_numericality
assert_dom_equal(
- %{<textarea id="post_id" name="post[id]">\n123</textarea>},
+ %{<textarea id="post_id" name="post[id]">\nomg</textarea>},
text_area("post", "id")
)
end