Check for agent class file to determine if it's valid (#1907)

The previous approach of checking if the class is defined caused problems when
the agent class had not yet been loaded by the process. Using Agent.valid_type?
instead seems to be the approach that is taken elsewhere in the codebase, and it
does not suffer from this problem.
This commit is contained in:
Kevin Yank 2017-02-13 07:08:19 +11:00 committed by Andrew Cantino
parent 11b6a2c459
commit 3dda1ffb63

View file

@ -418,7 +418,7 @@ class Agent < ActiveRecord::Base
return if schedule == 'never'
types = where(:schedule => schedule).group(:type).pluck(:type)
types.each do |type|
next unless const_defined?(type)
next unless valid_type?(type)
type.constantize.bulk_check(schedule)
end
end