Skip to content

Commit d1faaeb

Browse files
committed
no more tests from hash_tree_scope
1 parent 820131b commit d1faaeb

File tree

2 files changed

+21
-47
lines changed

2 files changed

+21
-47
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
### 6.0.0.alpha
44
* Drop support for unsupported versions of Rails, 3.2 and 4.0.
55
* Drop support for Ruby 1.9 and JRuby 1.9
6+
* Added support for `.hash_tree` from `.parent` and `.children`.
7+
Addresses [PR146](https://github.com/mceachen/closure_tree/pull/146).
8+
Thanks for reporting this and the breaking test, [Mike](https://github.com/mkralla11)!
69

710
### 5.2.0
811

spec/tag_examples.rb

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -579,56 +579,9 @@ def assert_parent_and_children
579579
it 'no limit' do
580580
expect(tag_class.hash_tree).to eq(@full_tree)
581581
end
582-
# AR Association Tests
583-
it 'limit_depth 2 from chained activerecord association subroots' do
584-
expect(@a.children.hash_tree(limit_depth: 2)).to eq(@three_tree[@a])
585-
end
586-
it 'no limit from chained activerecord association subroots' do
587-
expect(@a.children.hash_tree).to eq(@full_tree[@a])
588-
end
589-
it 'limit_depth 3 from b.parent' do
590-
expect(@b.parent.hash_tree(limit_depth: 3)).to eq(@three_tree.slice(@a))
591-
end
592-
it 'no limit_depth from b.parent' do
593-
expect(@b.parent.hash_tree).to eq(@full_tree.slice(@a))
594-
end
595-
it 'no limit_depth from c.parent' do
596-
expect(@c1.parent.hash_tree).to eq(@full_tree[@a].slice(@b))
597-
end
598-
end
599-
600-
def assert_no_dupes(scope)
601-
# the named scope is complicated enough that an incorrect join could result in unnecessarily
602-
# duplicated rows:
603-
a = scope.collect { |ea| ea.id }
604-
expect(a).to eq(a.uniq)
605-
end
606-
607-
context '#hash_tree_scope' do
608-
it 'no dupes for any depth' do
609-
(0..5).each do |ea|
610-
assert_no_dupes(tag_class.hash_tree_scope(ea))
611-
end
612-
end
613-
it 'no limit' do
614-
assert_no_dupes(tag_class.hash_tree_scope)
615-
end
616-
end
617-
618-
context '.hash_tree_scope' do
619-
it 'no dupes for any depth' do
620-
(0..5).each do |ea|
621-
assert_no_dupes(@a.hash_tree_scope(ea))
622-
end
623-
end
624-
it 'no limit holdum' do
625-
assert_no_dupes(@a.hash_tree_scope)
626-
end
627582
end
628583

629584
context '.hash_tree' do
630-
before :each do
631-
end
632585
it 'returns {} for depth 0' do
633586
expect(@b.hash_tree(limit_depth: 0)).to eq({})
634587
end
@@ -651,6 +604,24 @@ def assert_no_dupes(scope)
651604
expect(@a.hash_tree.merge(@a2.hash_tree)).to eq(@full_tree)
652605
end
653606
end
607+
608+
context '.hash_tree from relations' do
609+
it 'limit_depth 2 from chained activerecord association subroots' do
610+
expect(@a.children.hash_tree(limit_depth: 2)).to eq(@three_tree[@a])
611+
end
612+
it 'no limit from chained activerecord association subroots' do
613+
expect(@a.children.hash_tree).to eq(@full_tree[@a])
614+
end
615+
it 'limit_depth 3 from b.parent' do
616+
expect(@b.parent.hash_tree(limit_depth: 3)).to eq(@three_tree.slice(@a))
617+
end
618+
it 'no limit_depth from b.parent' do
619+
expect(@b.parent.hash_tree).to eq(@full_tree.slice(@a))
620+
end
621+
it 'no limit_depth from c.parent' do
622+
expect(@c1.parent.hash_tree).to eq(@full_tree[@a].slice(@b))
623+
end
624+
end
654625
end
655626

656627
it 'finds_by_path for very deep trees' do

0 commit comments

Comments
 (0)