Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
class ArticleIndexTest < ActiveSupport::TestCase
def setup
# create a parent page, which will display our index list
page_index = Cms::Page.new(
:slug => "top_page",
:label => "Page Top")
page_index.save!
# create Children, so we have something to list
(3.times).each { |i|
children << Cms::Page.new(
:parent => page_index,
:slug => "child_page_#{i}",
:label => "Page #{i}")
}
children.save!
end
def test_list_items
# Does the method return something containing our expected data?
assert_select ArticleIndex.list_articles, "child_page_1"
assert_select ArticleIndex.list_articles, 'label', "Page 1"
end
end
class ArticleIndex
def list_articles
articles = Articles.find(:parent => page_index)
articles.each { |article|
"<a href='#{article.path}' id='#{article.slug}'>#{article.label}</p>"
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.