Remove the ErrorHalt middleware, since Warden takes care of this on a larger scale
This commit is contained in:
parent
21e4477c39
commit
efbfd335ad
|
@ -110,13 +110,9 @@ module Vagrant
|
|||
# @param [Vagrant::Action::Environment] env The action environment
|
||||
# @return [Object] A callable object
|
||||
def to_app(env)
|
||||
# Prepend the error halt task so errneous environments are halted
|
||||
# before the chain even begins.
|
||||
middleware = stack.dup.push([Env::ErrorHalt, [], nil])
|
||||
|
||||
# Convert each middleware into a lambda which takes the next
|
||||
# middleware.
|
||||
Vagrant::Action::Warden.new(middleware, env)
|
||||
# Wrap the middleware stack with the Warden to provide a consistent
|
||||
# and predictable behavior upon exceptions.
|
||||
Warden.new(stack.dup, env)
|
||||
end
|
||||
|
||||
# Runs the builder stack with the given environment.
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
module Vagrant
|
||||
class Action
|
||||
module Env
|
||||
# A middleware which simply halts if the environment is erroneous.
|
||||
class ErrorHalt
|
||||
def initialize(app,env)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@app.call(env) if !env.error?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -159,17 +159,6 @@ class ActionBuilderTest < Test::Unit::TestCase
|
|||
Vagrant::Action.actions.clear
|
||||
end
|
||||
|
||||
should "preprend error halt to the chain" do
|
||||
result = mock("result")
|
||||
env = {:a => :b}
|
||||
middleware = mock("middleware")
|
||||
middleware.stubs(:is_a?).with(Class).returns(true)
|
||||
middleware.expects(:new).with(anything, env).returns(result)
|
||||
@instance.use middleware
|
||||
result = @instance.to_app(env).actions.first
|
||||
assert result.kind_of?(Vagrant::Action::Env::ErrorHalt)
|
||||
end
|
||||
|
||||
should "make non-classes lambdas" do
|
||||
env = Vagrant::Action::Environment.new(nil)
|
||||
env.expects(:foo).once
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
require "test_helper"
|
||||
|
||||
class ErrorHaltEnvActionTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Action::Env::ErrorHalt
|
||||
@app, @env = mock_action_data
|
||||
@instance = @klass.new(@app, @env)
|
||||
end
|
||||
|
||||
should "continue the chain if no error" do
|
||||
assert !@env.error?
|
||||
@app.expects(:call).with(@env).once
|
||||
@instance.call(@env)
|
||||
end
|
||||
|
||||
should "halt the chain if an error occured" do
|
||||
@env.error!(:foo)
|
||||
@app.expects(:call).never
|
||||
@instance.call(@env)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue