Class: AeTestCoverage::Collectors::ActiveRecord::ModelFileFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/ae_test_coverage/collectors/active_record/model_file_finder.rb

Instance Method Summary collapse

Instance Method Details

#file_path(model) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ae_test_coverage/collectors/active_record/model_file_finder.rb', line 7

def file_path(model)
  Rails.application.config.paths['app/models'].each do |model_root|
    path = Rails.root.join(model_root, "#{model.name.underscore}.rb").to_s
    return path if File.exist?(path)
  end
  Rails::Engine.subclasses.each do |engine|
    engine.paths['app/models'].each do |model_root|
      path = engine.root.join(model_root, "#{model.name.underscore}.rb").to_s
      return path if File.exist?(path)
    end
  end

  nil
end