aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG4
-rw-r--r--actionpack/test/template/text_helper_test.rb18
2 files changed, 21 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index ccc8e63a9d..0209cdf065 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Improve Text Helper test coverage. #7274 [Rob Sanheim, Josh Peek]
+
* Improve Action View test coverage. #7241, #7243, #7244 [Rich Collins]
* Resources: url_for([parent, child]) generates /parents/1/children/2 for the nested resource. Likewise with the other simply helpful methods like form_for and link_to. #6432 [mhw, Jonathan Vaught, lotswholetime]
@@ -562,7 +564,7 @@ superclass' view_paths. [Rick]
* Update Routing to complain when :controller is not specified by a route. Closes #6669. [Nicholas Seckar]
-* Ensure render_to_string cleans up after itself when an exception is raised. #6658 [rsanheim]
+* Ensure render_to_string cleans up after itself when an exception is raised. #6658 [Rob Sanheim]
* Extract template_changed_since? from compile_template? so plugins may override its behavior for non-file-based templates. #6651 [Jeff Barczewski]
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb
index 61afbb5136..1f5b90e811 100644
--- a/actionpack/test/template/text_helper_test.rb
+++ b/actionpack/test/template/text_helper_test.rb
@@ -31,6 +31,11 @@ class TextHelperTest < Test::Unit::TestCase
assert_equal "Hello Wor...", truncate("Hello World!!", 12)
end
+ def test_truncate_should_use_default_length_of_30
+ str = "This is a string that will go longer then the default truncate length of 30"
+ assert_equal str[0...27] + "...", truncate(str)
+ end
+
def test_truncate_multibyte
with_kcode 'none' do
assert_equal "\354\225\210\353\205\225\355...", truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", 10)
@@ -124,6 +129,19 @@ class TextHelperTest < Test::Unit::TestCase
assert_equal("1.25 counts", pluralize('1.25', "count"))
assert_equal("2 counters", pluralize(2, "count", "counters"))
assert_equal("0 counters", pluralize(nil, "count", "counters"))
+ assert_equal("2 people", pluralize(2, "person"))
+ assert_equal("10 buffaloes", pluralize(10, "buffalo"))
+ end
+
+ uses_mocha("should_just_add_s_for_pluralize_without_inflector_loaded") do
+ def test_should_just_add_s_for_pluralize_without_inflector_loaded
+ Object.expects(:const_defined?).with("Inflector").times(4).returns(false)
+ assert_equal("1 count", pluralize(1, "count"))
+ assert_equal("2 persons", pluralize(2, "person"))
+ assert_equal("2 personss", pluralize("2", "persons"))
+ assert_equal("2 counts", pluralize(2, "count"))
+ assert_equal("10 buffalos", pluralize(10, "buffalo"))
+ end
end
def test_auto_link_parsing