diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/base_test.rb | 23 | ||||
-rw-r--r-- | actionpack/test/template/number_helper_i18n_test.rb | 8 | ||||
-rw-r--r-- | actionpack/test/template/number_helper_test.rb | 16 |
3 files changed, 29 insertions, 18 deletions
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index f047e7da30..8b935097da 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -124,11 +124,11 @@ class ControllerInstanceTests < Test::Unit::TestCase def test_action_methods @empty_controllers.each do |c| - assert_equal Set.new, c.class.__send__(:action_methods), "#{c.controller_path} should be empty!" + assert_equal Set.new, c.class.action_methods, "#{c.controller_path} should be empty!" end @non_empty_controllers.each do |c| - assert_equal Set.new(%w(public_action)), c.class.__send__(:action_methods), "#{c.controller_path} should not be empty!" + assert_equal Set.new(%w(public_action)), c.class.action_methods, "#{c.controller_path} should not be empty!" end end @@ -191,7 +191,7 @@ class UrlOptionsTest < ActionController::TestCase def test_url_options_override with_routing do |set| - set.draw do |map| + set.draw do match 'from_view', :to => 'url_options#from_view', :as => :from_view match ':controller/:action' end @@ -202,7 +202,18 @@ class UrlOptionsTest < ActionController::TestCase assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url) assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options') end - end + end + + def test_url_helpers_does_not_become_actions + with_routing do |set| + set.draw do + match "account/overview" + end + + @controller.class.send(:include, set.url_helpers) + assert !@controller.class.action_methods.include?("account_overview_path") + end + end end class DefaultUrlOptionsTest < ActionController::TestCase @@ -216,7 +227,7 @@ class DefaultUrlOptionsTest < ActionController::TestCase def test_default_url_options_override with_routing do |set| - set.draw do |map| + set.draw do match 'from_view', :to => 'default_url_options#from_view', :as => :from_view match ':controller/:action' end @@ -231,7 +242,7 @@ class DefaultUrlOptionsTest < ActionController::TestCase def test_default_url_options_are_used_in_non_positional_parameters with_routing do |set| - set.draw do |map| + set.draw do scope("/:locale") do resources :descriptions end diff --git a/actionpack/test/template/number_helper_i18n_test.rb b/actionpack/test/template/number_helper_i18n_test.rb index 07a0e2792c..f730a0d7f5 100644 --- a/actionpack/test/template/number_helper_i18n_test.rb +++ b/actionpack/test/template/number_helper_i18n_test.rb @@ -6,13 +6,13 @@ class NumberHelperTest < ActionView::TestCase def setup I18n.backend.store_translations 'ts', :number => { - :format => { :precision => 3, :delimiter => ',', :separator => '.', :significant => false, :strip_unsignificant_zeros => false }, + :format => { :precision => 3, :delimiter => ',', :separator => '.', :significant => false, :strip_insignificant_zeros => false }, :currency => { :format => { :unit => '&$', :format => '%u - %n', :precision => 2 } }, :human => { :format => { :precision => 2, :significant => true, - :strip_unsignificant_zeros => true + :strip_insignificant_zeros => true }, :storage_units => { :format => "%n %u", @@ -35,7 +35,7 @@ class NumberHelperTest < ActionView::TestCase } } }, - :percentage => { :format => {:delimiter => '', :precision => 2, :strip_unsignificant_zeros => true} }, + :percentage => { :format => {:delimiter => '', :precision => 2, :strip_insignificant_zeros => true} }, :precision => { :format => {:delimiter => '', :significant => true} } }, :custom_units_for_number_to_human => {:mili => "mm", :centi => "cm", :deci => "dm", :unit => "m", :ten => "dam", :hundred => "hm", :thousand => "km"} @@ -60,7 +60,7 @@ class NumberHelperTest < ActionView::TestCase end def test_number_to_percentage - # to see if strip_unsignificant_zeros is true + # to see if strip_insignificant_zeros is true assert_equal("1%", number_to_percentage(1, :locale => 'ts')) # precision is 2, significant should be inherited assert_equal("1.24%", number_to_percentage(1.2434, :locale => 'ts')) diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb index 6adbe9c098..50c57a5588 100644 --- a/actionpack/test/template/number_helper_test.rb +++ b/actionpack/test/template/number_helper_test.rb @@ -58,7 +58,7 @@ class NumberHelperTest < ActionView::TestCase assert_equal("302.06%", number_to_percentage(302.0574, {:precision => 2})) assert_equal("100.000%", number_to_percentage("100")) assert_equal("1000.000%", number_to_percentage("1000")) - assert_equal("123.4%", number_to_percentage(123.400, :precision => 3, :strip_unsignificant_zeros => true)) + assert_equal("123.4%", number_to_percentage(123.400, :precision => 3, :strip_insignificant_zeros => true)) assert_equal("1.000,000%", number_to_percentage(1000, :delimiter => '.', :separator => ',')) end @@ -124,9 +124,9 @@ class NumberHelperTest < ActionView::TestCase assert_equal "5.392900", number_with_precision(5.3929, :precision => 7, :significant => true ) end - def test_number_with_precision_with_strip_unsignificant_zeros - assert_equal "9775.43", number_with_precision(9775.43, :precision => 4, :strip_unsignificant_zeros => true ) - assert_equal "9775.2", number_with_precision(9775.2, :precision => 6, :significant => true, :strip_unsignificant_zeros => true ) + def test_number_with_precision_with_strip_insignificant_zeros + assert_equal "9775.43", number_with_precision(9775.43, :precision => 4, :strip_insignificant_zeros => true ) + assert_equal "9775.2", number_with_precision(9775.2, :precision => 6, :significant => true, :strip_insignificant_zeros => true ) end def test_number_with_precision_with_significant_true_and_zero_precision @@ -181,7 +181,7 @@ class NumberHelperTest < ActionView::TestCase assert_equal '500 MB', number_to_human_size(524288000, :precision=>3) assert_equal '40 KB', number_to_human_size(41010, :precision => 1) assert_equal '40 KB', number_to_human_size(41100, :precision => 2) - assert_equal '1.0 KB', number_to_human_size(kilobytes(1.0123), :precision => 2, :strip_unsignificant_zeros => false) + assert_equal '1.0 KB', number_to_human_size(kilobytes(1.0123), :precision => 2, :strip_insignificant_zeros => false) assert_equal '1.012 KB', number_to_human_size(kilobytes(1.0123), :precision => 3, :significant => false) assert_equal '1 KB', number_to_human_size(kilobytes(1.0123), :precision => 0, :significant => true) #ignores significant it precision is 0 end @@ -212,7 +212,7 @@ class NumberHelperTest < ActionView::TestCase assert_equal '490 Thousand', number_to_human(489939, :precision => 2) assert_equal '489.9 Thousand', number_to_human(489939, :precision => 4) assert_equal '489 Thousand', number_to_human(489000, :precision => 4) - assert_equal '489.0 Thousand', number_to_human(489000, :precision => 4, :strip_unsignificant_zeros => false) + assert_equal '489.0 Thousand', number_to_human(489000, :precision => 4, :strip_insignificant_zeros => false) assert_equal '1.2346 Million', number_to_human(1234567, :precision => 4, :significant => false) assert_equal '1,2 Million', number_to_human(1234567, :precision => 1, :significant => false, :separator => ',') assert_equal '1 Million', number_to_human(1234567, :precision => 0, :significant => true, :separator => ',') #significant forced to false @@ -289,8 +289,8 @@ class NumberHelperTest < ActionView::TestCase assert !number_to_human_size("<script></script>").html_safe? assert number_to_human_size("asdf".html_safe).html_safe? - assert number_with_precision(1, :strip_unsignificant_zeros => false).html_safe? - assert number_with_precision(1, :strip_unsignificant_zeros => true).html_safe? + assert number_with_precision(1, :strip_insignificant_zeros => false).html_safe? + assert number_with_precision(1, :strip_insignificant_zeros => true).html_safe? assert !number_with_precision("<script></script>").html_safe? assert number_with_precision("asdf".html_safe).html_safe? |