module NotifiableAdmin
  
  class Engine < ::Rails::Engine
    isolate_namespace NotifiableAdmin
    
    engine_name 'notifiable_admin'
    
    # use rspec for testing
    config.generators do |g|
      g.test_framework      :rspec,        :fixture => false
      g.fixture_replacement :factory_girl, :dir => 'spec/factories'
      g.assets false
      g.helper false
    end
    
    # load notifiable_admin decorators
    config.to_prepare do
      Dir.glob(File.dirname(__FILE__) + "/../../app/decorators/**/*_decorator*.rb").each do |c|
        require_dependency(c)
      end
    end    
    
    # load app decorators
    config.to_prepare do
      Dir.glob(Rails.root + "app/decorators/**/*_decorator*.rb").each do |c|
        require_dependency(c)
      end
    end
    
    # append migrations
    initializer :append_migrations do |app|
      #unless app.root.to_s.match root.to_s
        config.paths["db/migrate"].expanded.each do |expanded_path|
          app.config.paths["db/migrate"] << expanded_path
        end
      #end
    end
  end

end
