Skip to content

Commit

Permalink
Fix test to illustrate way to partial include
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Willson authored and Scott Willson committed Mar 9, 2009
1 parent 1e1c86d commit d34727b
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions test/unit/comatose_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ class ComatosePageTest < Test::Unit::TestCase
assert !page.new_record?, "#{page.errors.full_messages.to_sentence}"
end
end

should "create a new version of an updated page" do
page = create_page
assert_difference page, :version do
page.update_attribute :body, "I'm the new content!"
assert_equal "<p>I&#8217;m the new content!</p>", page.to_html
end
end

should "render content through textile and liquid processors" do
page = create_page :title=>'Title Here', :body=>'h1. {{page.title}}'
assert_equal "<h1>Title Here</h1>", page.to_html
Expand All @@ -30,15 +30,15 @@ class ComatosePageTest < Test::Unit::TestCase
assert p.errors.on(:title)
end
end

should "have good fixtures for this to work out" do
assert_equal 'Home Page', root_page.title
assert_equal 'home-page', root_page.slug
assert_equal 'Comatose', root_page.author
assert_equal "", root_page.full_path
assert_equal 'faq', faq_page.full_path
end

should "generate slugs correctly" do
assert_equal 'hello-how-are-you', new_page_slug( "Hello, How Are You?" )
assert_equal 'i-have-too-much-space', new_page_slug( "I have too much space" )
Expand All @@ -47,17 +47,17 @@ class ComatosePageTest < Test::Unit::TestCase
assert_equal 'a-bizarre-title', new_page_slug( 'A !@!@#$%^<>&*()_+{} Bizarre TiTle!' )
assert_equal '001-numbers-too', new_page_slug( "001 Numbers too" )
end

should "generate page paths correctly" do
products = root_page.children.create( :title=>'Products' )
assert_equal 'products', products.full_path

books = products.children.create( :title=>'Books' )
assert_equal 'products/books', books.full_path

novels = books.children.create( :title=>'Novels' )
assert_equal 'products/books/novels', novels.full_path

comics = books.children.create( :title=>'Comics' )
assert_equal 'products/books/comics', comics.full_path
end
Expand All @@ -72,26 +72,26 @@ class ComatosePageTest < Test::Unit::TestCase

page.reload
assert_equal 'faq/question-one/params', page.full_path

q1pg.reload
q1pg.slug = "q-1"
assert q1pg.save, "Page.save"
assert_equal "faq/q-1", q1pg.full_path

page.reload
assert_equal 'faq/q-1/params', page.full_path
end

should "set an AR error with processor syntax error info" do
page = create_page :title=>'Title Here', :body=>'h1. {% crap %}'
assert !page.save, page.errors.full_messages.to_sentence
end

should "render body text accurately" do
assert_equal "<h1>Home Page</h1>\n<p>This is your <strong>home page</strong>.</p>", root_page.to_html
assert_equal "<h1>Frequently Asked Questions</h1>\n<h2><a href=\"/faq/question-one\">Question One?</a></h2>\n<p>Content for <strong>question one</strong>.</p>\n<h2><a href=\"/faq/question-two\">Question Two?</a></h2>\n<p>Content for <strong>question two</strong>.</p>", faq_page.to_html
end

should "render data from parameterized calls too" do
assert_equal "<p>I&#8217;m</p>", param_driven_page.to_html
assert_equal "<p>I&#8217;m From the Params Hash</p>", param_driven_page.to_html(:extra=>'From the Params Hash')
Expand All @@ -107,10 +107,12 @@ def test
assert_equal "<p>From Drop</p>", p.to_html
end

# Test illustrates broken partial, sort of
# <%= render :comatose => 'faq/question-one' %> should work, but does not
should "render inline partial" do
# FIX test illustrates broken partial, sort of
page = create_page :body => "<%= render :comatose=>'question_one' %>"
assert_equal "Content for <em>question one</em>", page.to_html
Comatose.config.default_processor = :erb
page = create_page :body => "Included: <%= ComatosePage.find_by_path('faq/question-one').to_html %>", :filter_type => :none
assert_equal "Included: <p>Content for <strong>question one</strong>.</p>", page.to_html
end

protected
Expand Down

0 comments on commit d34727b

Please sign in to comment.