summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rdoc/ri/driver.rb8
-rw-r--r--test/rdoc/test_rdoc_ri_driver.rb24
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb
index 0408cbb0aa..7549a39203 100644
--- a/lib/rdoc/ri/driver.rb
+++ b/lib/rdoc/ri/driver.rb
@@ -616,11 +616,11 @@ or the PAGER environment variable.
stores = classes[current]
- break unless stores and not stores.empty?
+ next unless stores and not stores.empty?
- klasses = stores.map do |store|
- store.ancestors[current]
- end.flatten.uniq
+ klasses = stores.flat_map do |store|
+ store.ancestors[current] || []
+ end.uniq
klasses = klasses - seen
diff --git a/test/rdoc/test_rdoc_ri_driver.rb b/test/rdoc/test_rdoc_ri_driver.rb
index f79d17b1cd..87e4ebd2b1 100644
--- a/test/rdoc/test_rdoc_ri_driver.rb
+++ b/test/rdoc/test_rdoc_ri_driver.rb
@@ -421,6 +421,30 @@ class TestRDocRIDriver < RDoc::TestCase
assert_equal %w[X Mixin Object Foo], @driver.ancestors_of('Foo::Bar')
end
+ def test_ancestors_of_chained_inclusion
+ # Store represents something like:
+ #
+ # module X
+ # end
+ #
+ # module Y
+ # include X
+ # end
+ #
+ # class Z
+ # include Y
+ # end
+ #
+ # Y is not chosen randomly, it has to be after Object in the alphabet
+ # to reproduce https://github.com/ruby/rdoc/issues/814.
+ store = RDoc::RI::Store.new @home_ri
+ store.cache[:ancestors] = { "Z" => ["Object", "Y"], "Y" => ["X"] }
+ store.cache[:modules] = %W[X Y Z]
+ @driver.stores = [store]
+
+ assert_equal %w[X Y Object], @driver.ancestors_of('Z')
+ end
+
def test_classes
util_multi_store