Created
May 20, 2011 17:36
-
-
Save jhenry/983383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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