From f277e1d8fddfa417104c6fe095c15559f0c8713d Mon Sep 17 00:00:00 2001 From: Ken Collins Date: Sat, 14 Jun 2008 14:06:27 -0400 Subject: Added TextHelper#current_cycle to return the current cycle for better design options. [#417 state:resolved] Signed-off-by: Jeremy Kemper --- actionpack/test/template/text_helper_test.rb | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index a31d532567..5f9f715819 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -369,6 +369,40 @@ class TextHelperTest < ActionView::TestCase assert_equal("red", cycle("red", "blue", :name => "colors")) end + def test_current_cycle_with_default_name + cycle("even","odd") + assert_equal "even", current_cycle + cycle("even","odd") + assert_equal "odd", current_cycle + cycle("even","odd") + assert_equal "even", current_cycle + end + + def test_current_cycle_with_named_cycles + cycle("red", "blue", :name => "colors") + assert_equal "red", current_cycle("colors") + cycle("red", "blue", :name => "colors") + assert_equal "blue", current_cycle("colors") + cycle("red", "blue", :name => "colors") + assert_equal "red", current_cycle("colors") + end + + def test_current_cycle_safe_call + assert_nothing_raised { current_cycle } + assert_nothing_raised { current_cycle("colors") } + end + + def test_current_cycle_with_more_than_two_names + cycle(1,2,3) + assert_equal "1", current_cycle + cycle(1,2,3) + assert_equal "2", current_cycle + cycle(1,2,3) + assert_equal "3", current_cycle + cycle(1,2,3) + assert_equal "1", current_cycle + end + def test_default_named_cycle assert_equal("1", cycle(1, 2, 3)) assert_equal("2", cycle(1, 2, 3, :name => "default")) -- cgit v1.2.3