diff --git a/lib/license_finder/decision_applier.rb b/lib/license_finder/decision_applier.rb index 4a401cd69..e0e3d2e27 100644 --- a/lib/license_finder/decision_applier.rb +++ b/lib/license_finder/decision_applier.rb @@ -4,7 +4,7 @@ module LicenseFinder class DecisionApplier def initialize(options) @decisions = options.fetch(:decisions) - @all_packages = decisions.packages + options.fetch(:packages) + @all_packages = options.fetch(:packages).to_set + @decisions.packages.to_set @acknowledged = apply_decisions end @@ -28,10 +28,14 @@ def any_packages? def apply_decisions all_packages - .map { |package| with_decided_licenses(package) } - .map { |package| with_approval(package) } - .map { |package| with_homepage(package) } .reject { |package| ignored?(package) } + .map do |package| + with_homepage( + with_approval( + with_decided_licenses(package) + ) + ) + end end def ignored?(package) diff --git a/spec/lib/license_finder/decision_applier_spec.rb b/spec/lib/license_finder/decision_applier_spec.rb index b6c08912f..00aa793fa 100644 --- a/spec/lib/license_finder/decision_applier_spec.rb +++ b/spec/lib/license_finder/decision_applier_spec.rb @@ -14,6 +14,15 @@ module LicenseFinder describe '#acknowledged' do it 'combines manual and system packages' do + decision_applier = described_class.new( + decisions: Decisions.new.add_package('system', nil).license('system', 'MIT'), + packages: [Package.new('system', '1.0.0')] + ) + package = decision_applier.acknowledged.first + expect([package.name, package.version, package.licenses.first.name]).to match_array %w[system 1.0.0 MIT] + end + + it 'merges manual packages with system packages' do decision_applier = described_class.new( decisions: Decisions.new.add_package('manual', nil), packages: [Package.new('system')]