core: add the box_added to the middleware

This commit is contained in:
Mitchell Hashimoto 2014-01-23 15:48:24 -08:00
parent 1ca7f86f76
commit 03b22ab9a1
2 changed files with 15 additions and 16 deletions

View File

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

View File

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