From b75768fc564ca422aff4e8313e53e4f4373b9bc5 Mon Sep 17 00:00:00 2001 From: Alex Goncharov Date: Wed, 24 Apr 2019 18:57:34 -0400 Subject: [PATCH 1/2] Fix box version sort in Update.update_specific --- plugins/commands/box/command/update.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/box/command/update.rb b/plugins/commands/box/command/update.rb index ea913be90..5b2cc9acb 100644 --- a/plugins/commands/box/command/update.rb +++ b/plugins/commands/box/command/update.rb @@ -80,7 +80,7 @@ module VagrantPlugins end to_update = [ - [name, provider, boxes[name][provider].sort.last], + [name, provider, boxes[name][provider].sort_by{|n| Gem::Version.new(n)}.last], ] to_update.each do |n, p, v| From 9266899b34af15b80be0af4fa2c0b398675a70d9 Mon Sep 17 00:00:00 2001 From: Alex Goncharov Date: Wed, 24 Apr 2019 19:59:37 -0400 Subject: [PATCH 2/2] Add a test for version selection for a box update --- .../commands/box/command/update_test.rb | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test/unit/plugins/commands/box/command/update_test.rb b/test/unit/plugins/commands/box/command/update_test.rb index f3bf60113..0c930b40e 100644 --- a/test/unit/plugins/commands/box/command/update_test.rb +++ b/test/unit/plugins/commands/box/command/update_test.rb @@ -67,7 +67,7 @@ describe VagrantPlugins::CommandBox::Command::Update do expect(called).to be(false) end - it "does update if there is an update" do + it "does the correct update if there is an update" do metadata_url.open("w") do |f| f.write(<<-RAW) { @@ -77,7 +77,25 @@ describe VagrantPlugins::CommandBox::Command::Update do "version": "1.0" }, { - "version": "1.1", + "version": "1.8", + "providers": [ + { + "name": "virtualbox", + "url": "bar" + } + ] + }, + { + "version": "1.10", + "providers": [ + { + "name": "virtualbox", + "url": "bar" + } + ] + }, + { + "version": "1.11", "providers": [ { "name": "virtualbox", @@ -97,7 +115,7 @@ describe VagrantPlugins::CommandBox::Command::Update do expect(opts[:box_force]).to eq(nil) expect(opts[:box_url]).to eq(metadata_url.to_s) expect(opts[:box_provider]).to eq("virtualbox") - expect(opts[:box_version]).to eq("1.1") + expect(opts[:box_version]).to eq("1.11") expect(opts[:box_download_ca_path]).to be_nil expect(opts[:box_download_ca_cert]).to be_nil expect(opts[:box_download_client_cert]).to be_nil