mirror of https://github.com/rails/rails
Raise an error if FileUpdateChecker#execute is called with no block
This commit is contained in:
parent
d506f3def1
commit
3585155f1b
|
@ -74,7 +74,11 @@ module ActiveSupport
|
|||
|
||||
def execute
|
||||
@updated.make_false
|
||||
@block.call
|
||||
if @block.nil?
|
||||
raise ArgumentError, "no block given: #{self.inspect}, please pass a block when you initialize #{self.class}"
|
||||
else
|
||||
@block.call
|
||||
end
|
||||
end
|
||||
|
||||
def execute_if_updated
|
||||
|
|
|
@ -74,7 +74,11 @@ module ActiveSupport
|
|||
def execute
|
||||
@last_watched = watched
|
||||
@last_update_at = updated_at(@last_watched)
|
||||
@block.call
|
||||
if @block.nil?
|
||||
raise ArgumentError, "no block given: #{self.inspect}, please pass a block when you initialize #{self.class}"
|
||||
else
|
||||
@block.call
|
||||
end
|
||||
ensure
|
||||
@watched = nil
|
||||
@updated_at = nil
|
||||
|
|
|
@ -273,4 +273,11 @@ module FileUpdateCheckerSharedTests
|
|||
assert checker.execute_if_updated
|
||||
assert_equal 2, i
|
||||
end
|
||||
|
||||
test "execute raises an ArgumentError if no block given" do
|
||||
checker = new_checker([])
|
||||
assert_raise ArgumentError do
|
||||
checker.execute
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue