From 69a37065f9f523c25bc4edb9c70a9b21578d46f6 Mon Sep 17 00:00:00 2001 From: hukl Date: Fri, 27 Feb 2009 16:53:11 +0100 Subject: more tests and fixes. always write tests - they are so good! --- test/functional/content_controller_test.rb | 40 ++++++++++++++++++++++++++++++ test/unit/page_test.rb | 4 ++- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/content_controller_test.rb b/test/functional/content_controller_test.rb index d64de60..2e0ee0e 100644 --- a/test/functional/content_controller_test.rb +++ b/test/functional/content_controller_test.rb @@ -2,6 +2,15 @@ require 'test_helper' class ContentControllerTest < ActionController::TestCase + def setup + @root = Node.find(1) + @first_child = Node.find(2) + @second_child = Node.find(3) + + @user1 = User.create :login => 'demo', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar' + @user2 = User.create :login => 'show', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar' + end + def test_custom_page_route assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'de', :page_path => ['foo', 'bar'] }, '/de/foo/bar') assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'en', :page_path => ['home'] }, '/en/home') @@ -23,4 +32,35 @@ class ContentControllerTest < ActionController::TestCase assert_response :success assert_equal "layouts/application", @response.layout end + + def test_page_containing_aggregator + assert_not_nil Node.root + + d1 = @first_child.find_or_create_draft @user1 + d1.title = "one" + d1.tag_list = "update" + d1.body = '' + d1.save + @first_child.publish_draft! + + d2 = @second_child.find_or_create_draft @user1 + d2.title = "two" + d2.tag_list = "update" + d2.save + @second_child.publish_draft! + + get :render_page, :locale => 'de', :page_path => ["first_child"] + assert_response :success + + assert_select("h2", "one") + assert_select("h2", "two") + end + + + + protected + + def create_update + + end end diff --git a/test/unit/page_test.rb b/test/unit/page_test.rb index bf4bca1..21b8910 100644 --- a/test/unit/page_test.rb +++ b/test/unit/page_test.rb @@ -14,10 +14,11 @@ class PageTest < ActiveSupport::TestCase n1.move_to_child_of Node.root n2.move_to_child_of Node.root - # get the drafts created_with + # get the drafts and assign a user to it assert_not_nil d1 = n1.find_or_create_draft( @user1 ) assert_not_nil d3 = n2.find_or_create_draft( @user1 ) + # tag and double publish so we have 4 pages tagged with "update" d1.tag_list = "update" d1.save n1.publish_draft! @@ -33,6 +34,7 @@ class PageTest < ActiveSupport::TestCase d4 = n2.find_or_create_draft @user1 n2.publish_draft! + # Set up two options hashes for the assertions options1 = { :tags => "update" } -- cgit v1.3