aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-08 13:33:18 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-08 13:34:07 -0700
commit86fc43fd584726ba81b1a3b3e0a6f6000c1f4cc8 (patch)
treeae5b6811931cb2903bf3a54a7211316f4e43589e /actionpack/test/template
parent00ee990443189649e481b2c30945e7a1029d8280 (diff)
downloadrails-86fc43fd584726ba81b1a3b3e0a6f6000c1f4cc8.tar.gz
rails-86fc43fd584726ba81b1a3b3e0a6f6000c1f4cc8.tar.bz2
rails-86fc43fd584726ba81b1a3b3e0a6f6000c1f4cc8.zip
ActionPack components should no longer have undeclared dependencies.
* Tests can be run in isolation * Dependencies added * A few tests modified to avoid depending on AS deps not depended on my files they were testing
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/erb_util_test.rb2
-rw-r--r--actionpack/test/template/number_helper_test.rb42
-rw-r--r--actionpack/test/template/render_test.rb2
3 files changed, 31 insertions, 15 deletions
diff --git a/actionpack/test/template/erb_util_test.rb b/actionpack/test/template/erb_util_test.rb
index c8c986f218..49f51c50c5 100644
--- a/actionpack/test/template/erb_util_test.rb
+++ b/actionpack/test/template/erb_util_test.rb
@@ -16,7 +16,7 @@ class ErbUtilTest < Test::Unit::TestCase
end
def test_rest_in_ascii
- (0..127).to_a.map(&:chr).each do |chr|
+ (0..127).to_a.map {|int| int.chr }.each do |chr|
next if %w(& " < >).include?(chr)
assert_equal chr, html_escape(chr)
end
diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb
index b6542ef29d..57b740032e 100644
--- a/actionpack/test/template/number_helper_test.rb
+++ b/actionpack/test/template/number_helper_test.rb
@@ -3,6 +3,22 @@ require 'abstract_unit'
class NumberHelperTest < ActionView::TestCase
tests ActionView::Helpers::NumberHelper
+ def kilobytes(number)
+ number * 1024
+ end
+
+ def megabytes(number)
+ kilobytes(number) * 1024
+ end
+
+ def gigabytes(number)
+ megabytes(number) * 1024
+ end
+
+ def terabytes(number)
+ gigabytes(number) * 1024
+ end
+
def test_number_to_phone
assert_equal("555-1234", number_to_phone(5551234))
assert_equal("800-555-1212", number_to_phone(8005551212))
@@ -96,16 +112,16 @@ class NumberHelperTest < ActionView::TestCase
assert_equal '1.2 MB', number_to_human_size(1234567)
assert_equal '1.1 GB', number_to_human_size(1234567890)
assert_equal '1.1 TB', number_to_human_size(1234567890123)
- assert_equal '1025 TB', number_to_human_size(1025.terabytes)
- assert_equal '444 KB', number_to_human_size(444.kilobytes)
- assert_equal '1023 MB', number_to_human_size(1023.megabytes)
- assert_equal '3 TB', number_to_human_size(3.terabytes)
+ assert_equal '1025 TB', number_to_human_size(terabytes(1025))
+ assert_equal '444 KB', number_to_human_size(kilobytes(444))
+ assert_equal '1023 MB', number_to_human_size(megabytes(1023))
+ assert_equal '3 TB', number_to_human_size(terabytes(3))
assert_equal '1.18 MB', number_to_human_size(1234567, :precision => 2)
assert_equal '3 Bytes', number_to_human_size(3.14159265, :precision => 4)
assert_equal("123 Bytes", number_to_human_size("123"))
- assert_equal '1.01 KB', number_to_human_size(1.0123.kilobytes, :precision => 2)
- assert_equal '1.01 KB', number_to_human_size(1.0100.kilobytes, :precision => 4)
- assert_equal '10 KB', number_to_human_size(10.000.kilobytes, :precision => 4)
+ assert_equal '1.01 KB', number_to_human_size(kilobytes(1.0123), :precision => 2)
+ assert_equal '1.01 KB', number_to_human_size(kilobytes(1.0100), :precision => 4)
+ assert_equal '10 KB', number_to_human_size(kilobytes(10.000), :precision => 4)
assert_equal '1 Byte', number_to_human_size(1.1)
assert_equal '10 Bytes', number_to_human_size(10)
#assert_nil number_to_human_size('x') # fails due to API consolidation
@@ -115,9 +131,9 @@ class NumberHelperTest < ActionView::TestCase
def test_number_to_human_size_with_options_hash
assert_equal '1.18 MB', number_to_human_size(1234567, :precision => 2)
assert_equal '3 Bytes', number_to_human_size(3.14159265, :precision => 4)
- assert_equal '1.01 KB', number_to_human_size(1.0123.kilobytes, :precision => 2)
- assert_equal '1.01 KB', number_to_human_size(1.0100.kilobytes, :precision => 4)
- assert_equal '10 KB', number_to_human_size(10.000.kilobytes, :precision => 4)
+ assert_equal '1.01 KB', number_to_human_size(kilobytes(1.0123), :precision => 2)
+ assert_equal '1.01 KB', number_to_human_size(kilobytes(1.0100), :precision => 4)
+ assert_equal '10 KB', number_to_human_size(kilobytes(10.000), :precision => 4)
assert_equal '1 TB', number_to_human_size(1234567890123, :precision => 0)
assert_equal '500 MB', number_to_human_size(524288000, :precision=>0)
assert_equal '40 KB', number_to_human_size(41010, :precision => 0)
@@ -125,8 +141,8 @@ class NumberHelperTest < ActionView::TestCase
end
def test_number_to_human_size_with_custom_delimiter_and_separator
- assert_equal '1,01 KB', number_to_human_size(1.0123.kilobytes, :precision => 2, :separator => ',')
- assert_equal '1,01 KB', number_to_human_size(1.0100.kilobytes, :precision => 4, :separator => ',')
- assert_equal '1.000,1 TB', number_to_human_size(1000.1.terabytes, :delimiter => '.', :separator => ',')
+ assert_equal '1,01 KB', number_to_human_size(kilobytes(1.0123), :precision => 2, :separator => ',')
+ assert_equal '1,01 KB', number_to_human_size(kilobytes(1.0100), :precision => 4, :separator => ',')
+ assert_equal '1.000,1 TB', number_to_human_size(terabytes(1000.1), :delimiter => '.', :separator => ',')
end
end
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 20cd4cc1d4..2ed11aa3c0 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -13,7 +13,7 @@ module RenderTestCases
I18n.backend.store_translations 'pt-BR', {}
# Ensure original are still the same since we are reindexing view paths
- assert_equal ORIGINAL_LOCALES, I18n.available_locales.map(&:to_s).sort
+ assert_equal ORIGINAL_LOCALES, I18n.available_locales.map {|l| l.to_s }.sort
end
def test_render_file