Merge pull request #10810 from alex-goncharov-usa/fix-box-update-version-sort

Fix box version sort in Update.update_specific
This commit is contained in:
Brian Cain 2019-04-25 08:41:41 -07:00 committed by GitHub
commit 15c7fc23ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -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|

View File

@ -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