diff options
| author | hukl <contact@smyck.org> | 2009-02-27 16:53:11 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-02-27 16:53:11 +0100 |
| commit | 69a37065f9f523c25bc4edb9c70a9b21578d46f6 (patch) | |
| tree | 550e750f9c48dee36f472fa1c8bae54e5bd95f17 /test | |
| parent | 463da8c96569f4ef9450f0eb75c7209f6a25b84b (diff) | |
more tests and fixes. always write tests - they are so good!
Diffstat (limited to 'test')
| -rw-r--r-- | test/functional/content_controller_test.rb | 40 | ||||
| -rw-r--r-- | test/unit/page_test.rb | 4 |
2 files changed, 43 insertions, 1 deletions
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' | |||
| 2 | 2 | ||
| 3 | class ContentControllerTest < ActionController::TestCase | 3 | class ContentControllerTest < ActionController::TestCase |
| 4 | 4 | ||
| 5 | def setup | ||
| 6 | @root = Node.find(1) | ||
| 7 | @first_child = Node.find(2) | ||
| 8 | @second_child = Node.find(3) | ||
| 9 | |||
| 10 | @user1 = User.create :login => 'demo', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar' | ||
| 11 | @user2 = User.create :login => 'show', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar' | ||
| 12 | end | ||
| 13 | |||
| 5 | def test_custom_page_route | 14 | def test_custom_page_route |
| 6 | assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'de', :page_path => ['foo', 'bar'] }, '/de/foo/bar') | 15 | assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'de', :page_path => ['foo', 'bar'] }, '/de/foo/bar') |
| 7 | assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'en', :page_path => ['home'] }, '/en/home') | 16 | assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'en', :page_path => ['home'] }, '/en/home') |
| @@ -23,4 +32,35 @@ class ContentControllerTest < ActionController::TestCase | |||
| 23 | assert_response :success | 32 | assert_response :success |
| 24 | assert_equal "layouts/application", @response.layout | 33 | assert_equal "layouts/application", @response.layout |
| 25 | end | 34 | end |
| 35 | |||
| 36 | def test_page_containing_aggregator | ||
| 37 | assert_not_nil Node.root | ||
| 38 | |||
| 39 | d1 = @first_child.find_or_create_draft @user1 | ||
| 40 | d1.title = "one" | ||
| 41 | d1.tag_list = "update" | ||
| 42 | d1.body = '<aggregate tags="update" limit="20" />' | ||
| 43 | d1.save | ||
| 44 | @first_child.publish_draft! | ||
| 45 | |||
| 46 | d2 = @second_child.find_or_create_draft @user1 | ||
| 47 | d2.title = "two" | ||
| 48 | d2.tag_list = "update" | ||
| 49 | d2.save | ||
| 50 | @second_child.publish_draft! | ||
| 51 | |||
| 52 | get :render_page, :locale => 'de', :page_path => ["first_child"] | ||
| 53 | assert_response :success | ||
| 54 | |||
| 55 | assert_select("h2", "one") | ||
| 56 | assert_select("h2", "two") | ||
| 57 | end | ||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | protected | ||
| 62 | |||
| 63 | def create_update | ||
| 64 | |||
| 65 | end | ||
| 26 | end | 66 | 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 | |||
| 14 | n1.move_to_child_of Node.root | 14 | n1.move_to_child_of Node.root |
| 15 | n2.move_to_child_of Node.root | 15 | n2.move_to_child_of Node.root |
| 16 | 16 | ||
| 17 | # get the drafts created_with | 17 | # get the drafts and assign a user to it |
| 18 | assert_not_nil d1 = n1.find_or_create_draft( @user1 ) | 18 | assert_not_nil d1 = n1.find_or_create_draft( @user1 ) |
| 19 | assert_not_nil d3 = n2.find_or_create_draft( @user1 ) | 19 | assert_not_nil d3 = n2.find_or_create_draft( @user1 ) |
| 20 | 20 | ||
| 21 | # tag and double publish so we have 4 pages tagged with "update" | ||
| 21 | d1.tag_list = "update" | 22 | d1.tag_list = "update" |
| 22 | d1.save | 23 | d1.save |
| 23 | n1.publish_draft! | 24 | n1.publish_draft! |
| @@ -33,6 +34,7 @@ class PageTest < ActiveSupport::TestCase | |||
| 33 | d4 = n2.find_or_create_draft @user1 | 34 | d4 = n2.find_or_create_draft @user1 |
| 34 | n2.publish_draft! | 35 | n2.publish_draft! |
| 35 | 36 | ||
| 37 | # Set up two options hashes for the assertions | ||
| 36 | options1 = { | 38 | options1 = { |
| 37 | :tags => "update" | 39 | :tags => "update" |
| 38 | } | 40 | } |
