seiten 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,6 +51,23 @@ class Seiten::PageCollectionTest < ActiveSupport::TestCase
51
51
  assert_equal [{ id: 1 }], page_collection.instance_variable_get(:@find_by).keys
52
52
  end
53
53
 
54
+ test 'top-level pages and pages without children look nothing up again' do
55
+ navigation.pages = [Seiten::Page.new(id: 1), Seiten::Page.new(id: 2, parent_id: 1), Seiten::Page.new(id: 3)]
56
+ top, leaf = navigation.pages.find(1), navigation.pages.find(3)
57
+ top.parent
58
+ leaf.children?
59
+
60
+ scans = 0
61
+ pages = navigation.pages.pages
62
+ pages.define_singleton_method(:find) { |*args, &block| scans += 1; super(*args, &block) }
63
+ pages.define_singleton_method(:select) { |*args, &block| scans += 1; super(*args, &block) }
64
+ 3.times { top.parent; leaf.children? }
65
+
66
+ assert_nil top.parent
67
+ assert_not leaf.children?
68
+ assert_equal 0, scans
69
+ end
70
+
54
71
  test '#where' do
55
72
  assert_equal [1], page_collection.where(id: 1).map(&:id)
56
73
  assert_equal [2,3], page_collection.where(parent_id: 1).map(&:id)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seiten
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Puglisi