core: ability to hide success UI

This commit is contained in:
Mitchell Hashimoto 2014-01-24 14:56:41 -08:00
parent e537e02d9d
commit d78194654d
3 changed files with 44 additions and 13 deletions

View File

@ -41,10 +41,12 @@ module Vagrant
newer = md.version( newer = md.version(
"> #{machine.box.version}", provider: machine.box.provider) "> #{machine.box.version}", provider: machine.box.provider)
if !newer if !newer
env[:ui].success(I18n.t( if env[:box_outdated_success_ui]
"vagrant.box_up_to_date_single", env[:ui].success(I18n.t(
name: machine.box.name, "vagrant.box_up_to_date_single",
version: machine.box.version)) name: machine.box.name,
version: machine.box.version))
end
env[:box_outdated] = false env[:box_outdated] = false
return @app.call(env) return @app.call(env)

View File

@ -27,6 +27,7 @@ module VagrantPlugins
with_target_vms(argv) do |machine| with_target_vms(argv) do |machine|
@env.action_runner.run(Vagrant::Action.action_box_outdated, { @env.action_runner.run(Vagrant::Action.action_box_outdated, {
box_outdated_refresh: true, box_outdated_refresh: true,
box_outdated_success_ui: true,
machine: machine, machine: machine,
}) })
end end

View File

@ -6,6 +6,7 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
let(:app) { lambda { |env| } } let(:app) { lambda { |env| } }
let(:env) { { let(:env) { {
machine: machine, machine: machine,
ui: Vagrant::UI::Silent.new,
} } } }
subject { described_class.new(app, env) } subject { described_class.new(app, env) }
@ -63,9 +64,10 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
let(:box_dir) { iso_env.box3("foo", "1.0", :virtualbox) } let(:box_dir) { iso_env.box3("foo", "1.0", :virtualbox) }
it "isn't outdated if it isn't" do context "isn't outdated" do
File.open(metadata_url.path, "w") do |f| before do
f.write(<<-RAW) File.open(metadata_url.path, "w") do |f|
f.write(<<-RAW)
{ {
"name": "foo/bar", "name": "foo/bar",
"versions": [ "versions": [
@ -80,16 +82,42 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
} }
] ]
} }
RAW RAW
end
box = Vagrant::Box.new(
"foo", :virtualbox, "1.0", box_dir,
metadata_url: metadata_url.path)
machine.stub(box: box)
end end
box = Vagrant::Box.new( it "marks it isn't outdated" do
"foo", :virtualbox, "1.0", box_dir, metadata_url: metadata_url.path) app.should_receive(:call).with(env)
machine.stub(box: box)
subject.call(env) subject.call(env)
expect(env[:box_outdated]).to be_false expect(env[:box_outdated]).to be_false
end
it "talks to the UI" do
env[:box_outdated_success_ui] = true
app.should_receive(:call).with(env)
env[:ui].should_receive(:success)
subject.call(env)
expect(env[:box_outdated]).to be_false
end
it "doesn't talk to UI if it is told" do
app.should_receive(:call).with(env)
env[:ui].should_receive(:success).never
subject.call(env)
expect(env[:box_outdated]).to be_false
end
end end
it "is outdated if it is" do it "is outdated if it is" do