seiten 1.3.0 → 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.
@@ -44,6 +44,30 @@ class Seiten::PageCollectionTest < ActiveSupport::TestCase
44
44
  assert_nil page_collection.find_by(id: 2, parent_id: 2)
45
45
  end
46
46
 
47
+ test '#find_by does not keep what it did not find' do
48
+ page_collection.find_by(id: 1)
49
+ page_collection.find_by(slug: 'wp-admin')
50
+
51
+ assert_equal [{ id: 1 }], page_collection.instance_variable_get(:@find_by).keys
52
+ end
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
+
47
71
  test '#where' do
48
72
  assert_equal [1], page_collection.where(id: 1).map(&:id)
49
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.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Puglisi