diff options
| author | hukl <contact@smyck.org> | 2009-02-27 16:10:00 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-02-27 16:10:00 +0100 |
| commit | b52c19b2bd5af7e479ba297e3382f056a324046b (patch) | |
| tree | 71c17d9c701d2438e635f954d1c4dc8d68b20372 /test/unit | |
| parent | 297676fafb7df8ce06134a41a5545eb7250a6f62 (diff) | |
unit test for the Page.aggregate method to verify only published pages are aggregated
Diffstat (limited to 'test/unit')
| -rw-r--r-- | test/unit/page_test.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/unit/page_test.rb b/test/unit/page_test.rb index af62e93..bf4bca1 100644 --- a/test/unit/page_test.rb +++ b/test/unit/page_test.rb | |||
| @@ -2,4 +2,48 @@ require 'test_helper' | |||
| 2 | 2 | ||
| 3 | class PageTest < ActiveSupport::TestCase | 3 | class PageTest < ActiveSupport::TestCase |
| 4 | 4 | ||
| 5 | def setup | ||
| 6 | @user1 = User.create :login => 'demo', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar' | ||
| 7 | @user2 = User.create :login => 'show', :email => "f@b.com", :password => 'foobar', :password_confirmation => 'foobar' | ||
| 8 | end | ||
| 9 | |||
| 10 | def test_aggregation | ||
| 11 | # Create two nodes and move them beneath the root node | ||
| 12 | n1 = Node.create! :slug => "one" | ||
| 13 | n2 = Node.create! :slug => "two" | ||
| 14 | n1.move_to_child_of Node.root | ||
| 15 | n2.move_to_child_of Node.root | ||
| 16 | |||
| 17 | # get the drafts created_with | ||
| 18 | assert_not_nil d1 = n1.find_or_create_draft( @user1 ) | ||
| 19 | assert_not_nil d3 = n2.find_or_create_draft( @user1 ) | ||
| 20 | |||
| 21 | d1.tag_list = "update" | ||
| 22 | d1.save | ||
| 23 | n1.publish_draft! | ||
| 24 | |||
| 25 | d2 = n1.find_or_create_draft @user1 | ||
| 26 | n1.publish_draft! | ||
| 27 | |||
| 28 | |||
| 29 | d3.tag_list = "update, pressemitteilung" | ||
| 30 | d3.save | ||
| 31 | n2.publish_draft! | ||
| 32 | |||
| 33 | d4 = n2.find_or_create_draft @user1 | ||
| 34 | n2.publish_draft! | ||
| 35 | |||
| 36 | options1 = { | ||
| 37 | :tags => "update" | ||
| 38 | } | ||
| 39 | |||
| 40 | options2 = { | ||
| 41 | :tags => "update, pressemitteilung" | ||
| 42 | } | ||
| 43 | |||
| 44 | assert_equal 2, Page.aggregate( options1 ).length | ||
| 45 | assert_equal 1, Page.aggregate( options2 ).length | ||
| 46 | assert_equal 4, Page.find_tagged_with( "update" ).count | ||
| 47 | assert_equal [d2.id, d4.id], Page.aggregate( options1 ).map {|x| x.id} | ||
| 48 | end | ||
| 5 | end | 49 | end |
