diff --git a/lib/vagrant/action/builtin/box_add.rb b/lib/vagrant/action/builtin/box_add.rb index 7168347cd..4d591e7a9 100644 --- a/lib/vagrant/action/builtin/box_add.rb +++ b/lib/vagrant/action/builtin/box_add.rb @@ -161,22 +161,6 @@ module Vagrant expected: checksum end end - - # Persists URL used on download and the time it was added - write_extra_info(box_added, download_url) - - # Passes on the newly added box to the rest of the middleware chain - env[:box_added] = box_added - - # Carry on! - @app.call(env) - end - - def write_extra_info(box_added, url) - info = {'url' => url, 'downloaded_at' => Time.now.utc} - box_added.directory.join('info.json').open("w+") do |f| - f.write(JSON.dump(info)) - end end =end @@ -234,6 +218,9 @@ module Vagrant "vagrant.box_added", name: box.name, provider: box.provider)) + # Store the added box in the env for future middleware + env[:box_added] = box + box end diff --git a/test/unit/vagrant/action/builtin/box_add_test.rb b/test/unit/vagrant/action/builtin/box_add_test.rb index eead8ff83..cfe3ecedb 100644 --- a/test/unit/vagrant/action/builtin/box_add_test.rb +++ b/test/unit/vagrant/action/builtin/box_add_test.rb @@ -172,6 +172,8 @@ describe Vagrant::Action::Builtin::BoxAdd do app.should_receive(:call).with(env) subject.call(env) + + expect(env[:box_added]).to equal(box) end it "adds the latest version of a box with the specified provider, even if not latest" do @@ -218,6 +220,8 @@ describe Vagrant::Action::Builtin::BoxAdd do app.should_receive(:call).with(env) subject.call(env) + + expect(env[:box_added]).to equal(box) end it "adds the constrained version of a box with the only provider" do @@ -255,6 +259,8 @@ describe Vagrant::Action::Builtin::BoxAdd do app.should_receive(:call).with(env) subject.call(env) + + expect(env[:box_added]).to equal(box) end it "adds the constrained version of a box with the specified provider" do @@ -297,6 +303,8 @@ describe Vagrant::Action::Builtin::BoxAdd do app.should_receive(:call).with(env) subject.call(env) + + expect(env[:box_added]).to equal(box) end it "adds the latest version of a box with any specified provider" do @@ -342,6 +350,8 @@ describe Vagrant::Action::Builtin::BoxAdd do app.should_receive(:call).with(env) subject.call(env) + + expect(env[:box_added]).to equal(box) end it "raises an exception if no matching version" do @@ -483,6 +493,8 @@ describe Vagrant::Action::Builtin::BoxAdd do app.should_receive(:call).with(env) subject.call(env) + + expect(env[:box_added]).to equal(box) end end end