2012-09-16 16:45:08 -04:00
|
|
|
require 'abstract_unit'
|
2014-07-16 13:13:42 -04:00
|
|
|
require 'action_view/renderer/partial_renderer'
|
2012-09-16 16:45:08 -04:00
|
|
|
|
2014-07-16 13:13:42 -04:00
|
|
|
class PartialIterationTest < ActiveSupport::TestCase
|
2012-09-16 16:45:08 -04:00
|
|
|
def test_has_size_and_index
|
2014-07-16 13:28:39 -04:00
|
|
|
iteration = ActionView::PartialIteration.new 3
|
2012-09-16 16:45:08 -04:00
|
|
|
assert_equal 0, iteration.index, "should be at the first index"
|
|
|
|
assert_equal 3, iteration.size, "should have the size"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_first_is_true_when_current_is_at_the_first_index
|
2014-07-16 13:28:39 -04:00
|
|
|
iteration = ActionView::PartialIteration.new 3
|
2012-09-16 16:45:08 -04:00
|
|
|
assert iteration.first?, "first when current is 0"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_first_is_false_unless_current_is_at_the_first_index
|
2014-07-16 13:28:39 -04:00
|
|
|
iteration = ActionView::PartialIteration.new 3
|
|
|
|
iteration.iterate!
|
2012-09-16 16:45:08 -04:00
|
|
|
assert !iteration.first?, "not first when current is 1"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_last_is_true_when_current_is_at_the_last_index
|
2014-07-16 13:28:39 -04:00
|
|
|
iteration = ActionView::PartialIteration.new 3
|
|
|
|
iteration.iterate!
|
|
|
|
iteration.iterate!
|
2012-09-16 16:45:08 -04:00
|
|
|
assert iteration.last?, "last when current is 2"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_last_is_false_unless_current_is_at_the_last_index
|
2014-07-16 13:28:39 -04:00
|
|
|
iteration = ActionView::PartialIteration.new 3
|
2012-09-16 16:45:08 -04:00
|
|
|
assert !iteration.last?, "not last when current is 0"
|
|
|
|
end
|
|
|
|
end
|