aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/active_record_helper_test.rb2
-rw-r--r--actionpack/test/template/benchmark_helper_test.rb12
-rw-r--r--actionpack/test/template/date_helper_i18n_test.rb19
-rw-r--r--actionpack/test/template/date_helper_test.rb42
-rw-r--r--actionpack/test/template/form_options_helper_test.rb2
-rw-r--r--actionpack/test/template/url_helper_test.rb14
6 files changed, 50 insertions, 41 deletions
diff --git a/actionpack/test/template/active_record_helper_test.rb b/actionpack/test/template/active_record_helper_test.rb
index ec3384f15d..c149070f2a 100644
--- a/actionpack/test/template/active_record_helper_test.rb
+++ b/actionpack/test/template/active_record_helper_test.rb
@@ -185,7 +185,7 @@ class ActiveRecordHelperTest < ActionView::TestCase
end
def test_form_with_action_option
- @response.body = form("post", :action => "sign")
+ output_buffer << form("post", :action => "sign")
assert_select "form[action=sign]" do |form|
assert_select "input[type=submit][value=Sign]"
end
diff --git a/actionpack/test/template/benchmark_helper_test.rb b/actionpack/test/template/benchmark_helper_test.rb
index 5d2af7cdd9..ac31fc6503 100644
--- a/actionpack/test/template/benchmark_helper_test.rb
+++ b/actionpack/test/template/benchmark_helper_test.rb
@@ -4,14 +4,14 @@ require 'action_view/helpers/benchmark_helper'
class BenchmarkHelperTest < ActionView::TestCase
tests ActionView::Helpers::BenchmarkHelper
- def teardown
- controller.logger.send(:clear_buffer)
+ def setup
+ super
+ controller.logger = ActiveSupport::BufferedLogger.new(StringIO.new)
+ controller.logger.auto_flushing = false
end
- def controller
- logger = ActiveSupport::BufferedLogger.new(StringIO.new)
- logger.auto_flushing = false
- @controller ||= Struct.new(:logger).new(logger)
+ def teardown
+ controller.logger.send(:clear_buffer)
end
def test_without_block
diff --git a/actionpack/test/template/date_helper_i18n_test.rb b/actionpack/test/template/date_helper_i18n_test.rb
index bc011f59b8..b69a449617 100644
--- a/actionpack/test/template/date_helper_i18n_test.rb
+++ b/actionpack/test/template/date_helper_i18n_test.rb
@@ -20,15 +20,16 @@ class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase
[60.seconds, true] => [:'x_minutes', 1],
# without include_seconds
- [29.seconds, false] => [:'less_than_x_minutes', 1],
- [60.seconds, false] => [:'x_minutes', 1],
- [44.minutes, false] => [:'x_minutes', 44],
- [61.minutes, false] => [:'about_x_hours', 1],
- [24.hours, false] => [:'x_days', 1],
- [30.days, false] => [:'about_x_months', 1],
- [60.days, false] => [:'x_months', 2],
- [1.year, false] => [:'about_x_years', 1],
- [3.years, false] => [:'over_x_years', 3]
+ [29.seconds, false] => [:'less_than_x_minutes', 1],
+ [60.seconds, false] => [:'x_minutes', 1],
+ [44.minutes, false] => [:'x_minutes', 44],
+ [61.minutes, false] => [:'about_x_hours', 1],
+ [24.hours, false] => [:'x_days', 1],
+ [30.days, false] => [:'about_x_months', 1],
+ [60.days, false] => [:'x_months', 2],
+ [1.year, false] => [:'about_x_years', 1],
+ [3.years + 6.months, false] => [:'over_x_years', 3],
+ [3.years + 10.months, false] => [:'almost_x_years', 4]
}.each do |passed, expected|
assert_distance_of_time_in_words_translates_key passed, expected
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index 2e4763f446..9fb2080f77 100644
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -53,13 +53,14 @@ class DateHelperTest < ActionView::TestCase
assert_equal "about 2 hours", distance_of_time_in_words(from, to + 89.minutes + 30.seconds)
assert_equal "about 24 hours", distance_of_time_in_words(from, to + 23.hours + 59.minutes + 29.seconds)
- # 1440..2879
+ # 1440..2529
assert_equal "1 day", distance_of_time_in_words(from, to + 23.hours + 59.minutes + 30.seconds)
- assert_equal "1 day", distance_of_time_in_words(from, to + 47.hours + 59.minutes + 29.seconds)
+ assert_equal "1 day", distance_of_time_in_words(from, to + 41.hours + 59.minutes + 29.seconds)
- # 2880..43199
- assert_equal "2 days", distance_of_time_in_words(from, to + 47.hours + 59.minutes + 30.seconds)
- assert_equal "29 days", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 29.seconds)
+ # 2530..43199
+ assert_equal "2 days", distance_of_time_in_words(from, to + 42.hours + 59.minutes + 30.seconds)
+ assert_equal "3 days", distance_of_time_in_words(from, to + 2.days + 12.hours)
+ assert_equal "30 days", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 29.seconds)
# 43200..86399
assert_equal "about 1 month", distance_of_time_in_words(from, to + 29.days + 23.hours + 59.minutes + 30.seconds)
@@ -69,13 +70,28 @@ class DateHelperTest < ActionView::TestCase
assert_equal "2 months", distance_of_time_in_words(from, to + 59.days + 23.hours + 59.minutes + 30.seconds)
assert_equal "12 months", distance_of_time_in_words(from, to + 1.years - 31.seconds)
- # 525600..1051199
- assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years - 30.seconds)
- assert_equal "about 1 year", distance_of_time_in_words(from, to + 2.years - 31.seconds)
-
- # > 1051199
- assert_equal "over 2 years", distance_of_time_in_words(from, to + 2.years + 30.seconds)
- assert_equal "over 10 years", distance_of_time_in_words(from, to + 10.years)
+ # > 525599
+ assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years - 30.seconds)
+ assert_equal "about 1 year", distance_of_time_in_words(from, to + 1.years + 3.months - 1.day)
+ assert_equal "over 1 year", distance_of_time_in_words(from, to + 1.years + 6.months)
+
+ assert_equal "almost 2 years", distance_of_time_in_words(from, to + 2.years - 3.months + 1.day)
+ assert_equal "about 2 years", distance_of_time_in_words(from, to + 2.years + 3.months - 1.day)
+ assert_equal "over 2 years", distance_of_time_in_words(from, to + 2.years + 3.months + 1.day)
+ assert_equal "over 2 years", distance_of_time_in_words(from, to + 2.years + 9.months - 1.day)
+ assert_equal "almost 3 years", distance_of_time_in_words(from, to + 2.years + 9.months + 1.day)
+
+ assert_equal "almost 5 years", distance_of_time_in_words(from, to + 5.years - 3.months + 1.day)
+ assert_equal "about 5 years", distance_of_time_in_words(from, to + 5.years + 3.months - 1.day)
+ assert_equal "over 5 years", distance_of_time_in_words(from, to + 5.years + 3.months + 1.day)
+ assert_equal "over 5 years", distance_of_time_in_words(from, to + 5.years + 9.months - 1.day)
+ assert_equal "almost 6 years", distance_of_time_in_words(from, to + 5.years + 9.months + 1.day)
+
+ assert_equal "almost 10 years", distance_of_time_in_words(from, to + 10.years - 3.months + 1.day)
+ assert_equal "about 10 years", distance_of_time_in_words(from, to + 10.years + 3.months - 1.day)
+ assert_equal "over 10 years", distance_of_time_in_words(from, to + 10.years + 3.months + 1.day)
+ assert_equal "over 10 years", distance_of_time_in_words(from, to + 10.years + 9.months - 1.day)
+ assert_equal "almost 11 years", distance_of_time_in_words(from, to + 10.years + 9.months + 1.day)
# test to < from
assert_equal "about 4 hours", distance_of_time_in_words(from + 4.hours, to)
@@ -104,7 +120,7 @@ class DateHelperTest < ActionView::TestCase
def test_distance_in_words_with_dates
start_date = Date.new 1975, 1, 31
end_date = Date.new 1977, 1, 31
- assert_equal("over 2 years", distance_of_time_in_words(start_date, end_date))
+ assert_equal("about 2 years", distance_of_time_in_words(start_date, end_date))
end
def test_distance_in_words_with_integers
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index f3cdab05bf..aa40e46aa8 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -1,5 +1,5 @@
require 'abstract_unit'
-require 'active_support/vendor/tzinfo'
+require 'tzinfo'
TZInfo::Timezone.cattr_reader :loaded_zones
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index 447d520ef1..ce99482078 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -5,8 +5,6 @@ require 'controller/fake_controllers'
RequestMock = Struct.new("Request", :request_uri, :protocol, :host_with_port, :env)
class UrlHelperTest < ActionView::TestCase
- tests ActionView::Helpers::UrlHelper
-
def setup
super
@controller = Class.new do
@@ -386,9 +384,7 @@ class UrlHelperController < ActionController::Base
def rescue_action(e) raise e end
end
-class UrlHelperWithControllerTest < ActionView::TestCase
- tests ActionView::Helpers::UrlHelper
-
+class UrlHelperWithControllerTest < ActionController::TestCase
def setup
super
@request = ActionController::TestRequest.new
@@ -463,9 +459,7 @@ class TasksController < ActionController::Base
end
end
-class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase
- tests ActionView::Helpers::UrlHelper
-
+class LinkToUnlessCurrentWithControllerTest < ActionController::TestCase
def setup
super
@request = ActionController::TestRequest.new
@@ -566,9 +560,7 @@ class SessionsController < ActionController::Base
def rescue_action(e) raise e end
end
-class PolymorphicControllerTest < ActionView::TestCase
- tests ActionView::Helpers::UrlHelper
-
+class PolymorphicControllerTest < ActionController::TestCase
def setup
super
@request = ActionController::TestRequest.new