keg: fix dependents with unavailable formulae

Because of an accidental use of `=` instead of `==`, the source formula
check would be skipped when determining if a keg depended on another one
(so only the versions would be compared).

Fixed that comparison, and updated the corresponding test.

Glad I caught that!
This commit is contained in:
Alyssa Ross 2016-12-27 22:58:44 +00:00
parent e5d7e13c63
commit 3a27d81219
2 changed files with 7 additions and 5 deletions

View File

@ -357,7 +357,7 @@ class Keg
end
def installed_dependents
my_tab = Tab.for_keg(self)
tap = Tab.for_keg(self).source["tap"]
Keg.all.select do |keg|
tab = Tab.for_keg(keg)
next if tab.runtime_dependencies.nil? # no dependency information saved.
@ -368,7 +368,7 @@ class Keg
dep_formula = Formulary.factory(dep["full_name"])
next false unless dep_formula == to_formula
rescue FormulaUnavailableError
next false unless my_tab["full_name"] = dep["full_name"]
next false unless "#{tap}/#{name}" == dep["full_name"]
end
dep["version"] == version.to_s

View File

@ -360,9 +360,11 @@ class InstalledDependantsTests < LinkTestCase
# from a file path or URL.
def test_unknown_formula
Formulary.unstub(:loader_for)
alter_tab { |t| t.source["tap"] = "some/tap" }
dependencies [{ "full_name" => "some/tap/bar", "version" => "1.0" }]
alter_tab { |t| t.source["path"] = nil }
alter_tab(@keg) do |t|
t.source["tap"] = "some/tap"
t.source["path"] = nil
end
dependencies [{ "full_name" => "some/tap/foo", "version" => "1.0" }]
assert_equal [@dependent], @keg.installed_dependents
assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg])
end