aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorKen Collins <ken@metaskills.net>2008-06-14 14:06:27 -0400
committerJeremy Kemper <jeremy@bitsweat.net>2008-08-27 23:06:20 -0700
commitf277e1d8fddfa417104c6fe095c15559f0c8713d (patch)
tree39865611a3e8b3b8d3df441c1c646dad30c03edb /actionpack/test
parente42a235dd18a39ccc83382365088de96f24fa236 (diff)
downloadrails-f277e1d8fddfa417104c6fe095c15559f0c8713d.tar.gz
rails-f277e1d8fddfa417104c6fe095c15559f0c8713d.tar.bz2
rails-f277e1d8fddfa417104c6fe095c15559f0c8713d.zip
Added TextHelper#current_cycle to return the current cycle for better design options.
[#417 state:resolved] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/text_helper_test.rb34
1 files changed, 34 insertions, 0 deletions
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"))