diff options
| -rw-r--r-- | app/models/node.rb | 2 | ||||
| -rw-r--r-- | test/unit/node_test.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/node.rb b/app/models/node.rb index cac4495..6e54004 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | class Node < ActiveRecord::Base | 1 | class Node < ActiveRecord::Base |
| 2 | acts_as_nested_set | 2 | acts_as_nested_set |
| 3 | 3 | ||
| 4 | has_many :pages | 4 | has_many :pages, :order => "revision ASC" |
| 5 | 5 | ||
| 6 | # returns array with pages up to root excluding root | 6 | # returns array with pages up to root excluding root |
| 7 | def path_to_root | 7 | def path_to_root |
diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index 14fdad0..2b35403 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb | |||
| @@ -27,6 +27,16 @@ class NodeTest < ActiveSupport::TestCase | |||
| 27 | 27 | ||
| 28 | end | 28 | end |
| 29 | 29 | ||
| 30 | def test_order_of_pages_by_revision | ||
| 31 | one = @first_child.pages.create :title => "one" | ||
| 32 | two = @first_child.pages.create :title => "two" | ||
| 33 | three = @first_child.pages.create :title => "three" | ||
| 34 | |||
| 35 | @first_child.pages.reload | ||
| 36 | |||
| 37 | assert_equal [1,2,3], @first_child.pages.map { |x| x.revision } | ||
| 38 | end | ||
| 39 | |||
| 30 | def test_behavior_of_acts_as_list | 40 | def test_behavior_of_acts_as_list |
| 31 | one = @first_child.pages.create :title => "one" | 41 | one = @first_child.pages.create :title => "one" |
| 32 | two = @first_child.pages.create :title => "two" | 42 | two = @first_child.pages.create :title => "two" |
