Merge pull request #11867 from marxarelli/fix/storage-controller-array-sort
Avoid sorting of controllers with nil boot_priority
This commit is contained in:
commit
7103be62b9
@ -27,10 +27,8 @@ module VagrantPlugins
|
||||
#
|
||||
# @return [VagrantPlugins::ProviderVirtualBox::Model::StorageController]
|
||||
def get_primary_controller
|
||||
ordered = sort { |a, b| a.boot_priority <=> b.boot_priority }
|
||||
controller = ordered.detect do |c|
|
||||
c.supported? && c.attachments.any? { |a| hdd?(a) }
|
||||
end
|
||||
ordered = find_all(&:supported?).sort_by(&:boot_priority)
|
||||
controller = ordered.detect { |c| c.attachments.any? { |a| hdd?(a) } }
|
||||
|
||||
if !controller
|
||||
raise Vagrant::Errors::VirtualBoxDisksNoSupportedControllers,
|
||||
@ -62,8 +60,8 @@ module VagrantPlugins
|
||||
#
|
||||
# @return [VagrantPlugins::ProviderVirtualBox::Model::StorageController]
|
||||
def get_dvd_controller
|
||||
ordered = sort { |a, b| a.boot_priority <=> b.boot_priority }
|
||||
controller = ordered.detect { |c| c.supported? }
|
||||
ordered = find_all(&:supported?).sort_by(&:boot_priority)
|
||||
controller = ordered.first
|
||||
if !controller
|
||||
raise Vagrant::Errors::VirtualBoxDisksNoSupportedControllers,
|
||||
supported_types: supported_types.join(" ,")
|
||||
|
||||
@ -91,7 +91,7 @@ describe VagrantPlugins::ProviderVirtualBox::Model::StorageControllerArray do
|
||||
|
||||
describe "#get_dvd_controller" do
|
||||
context "with one controller" do
|
||||
let(:controller) { double("controller", supported?: true) }
|
||||
let(:controller) { double("controller", supported?: true, boot_priority: 1) }
|
||||
|
||||
before do
|
||||
subject.replace([controller])
|
||||
@ -111,9 +111,10 @@ describe VagrantPlugins::ProviderVirtualBox::Model::StorageControllerArray do
|
||||
context "with multiple controllers" do
|
||||
let(:controller1) { double("controller", supported?: true, boot_priority: 2) }
|
||||
let(:controller2) { double("controller", supported?: true, boot_priority: 1) }
|
||||
let(:controller3) { double("controller", supported?: false, boot_priority: nil) }
|
||||
|
||||
before do
|
||||
subject.replace([controller1, controller2])
|
||||
subject.replace([controller1, controller2, controller3])
|
||||
end
|
||||
|
||||
it "returns the first supported controller" do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user