require 'apartment' require 'ims/lti' require 'attr_encrypted' require 'secure_headers' module PandaPal class Engine < ::Rails::Engine config.autoload_once_paths += Dir["#{config.root}/lib/**/"] isolate_namespace PandaPal config.generators do |g| g.test_framework :rspec g.fixture_replacement :factory_girl, :dir => 'spec/factories' end initializer :append_migrations do |app| config.paths["db/migrate"].expanded.each do |expanded_path| app.config.paths["db/migrate"] << expanded_path end # Apartment will modify this, but it doesn't fully support engine migrations, so we'll reset it here ActiveRecord::Migrator.migrations_paths = Rails.application.paths['db/migrate'].to_a end initializer 'interop dependencies' do if $LOADED_FEATURES.grep(/\/ros-apartment-\d/).present? if $LOADED_FEATURES.grep(/\/apartment-\d/).present? || $LOADED_FEATURES.grep(/\/apartment-sidekiq-\d/).present? raise "ros-apartment is used, but apartment or apartment-sidekiq is loaded. Do not mix legacy and ros- variants! (You most likely need to update your Gemfile to use the ros- variant)" end end if defined?(Sidekiq) begin require 'apartment-sidekiq' rescue LoadError raise "Sidekiq is used, but apartment-sidekiq is not installed. Add [gem 'ros-apartment-sidekiq'] to your Gemfile" end end end initializer 'Sidekiq Scheduler Hooks' do ActiveSupport.on_load(:active_record) do if defined?(Sidekiq) && Sidekiq.server? && PandaPal::Organization.respond_to?(:sync_schedules) PandaPal::Organization.sync_schedules ActiveSupport::Reloader.to_prepare do PandaPal::Organization.sync_schedules end end end end initializer 'panda_pal.app_controller' do |app| OAUTH_10_SUPPORT = true ActiveSupport.on_load(:action_controller) do include PandaPal::Helpers::ControllerHelper end end initializer 'panda_pal.route_helper' do |route| ActionDispatch::Routing::Mapper.send :include, PandaPal::Helpers::RouteHelper end initializer 'panda_pal.route_options', after: :build_middleware_stack do |app| ActiveSupport.on_load(:action_controller) do Rails.application.reload_routes! PandaPal::validate_pandapal_config! end end initializer "panda_pal.assets.precompile" do |app| app.config.assets.precompile << "panda_pal_manifest.js" rescue nil end initializer :secure_headers do |app| begin ::SecureHeaders::Configuration.default do |config| PandaPal::SecureHeaders.apply_defaults(config) end rescue ::SecureHeaders::Configuration::AlreadyConfiguredError # The App already applied settings end ::SecureHeaders::Configuration.override(:safari_override) do |config| config.cookies = ::SecureHeaders::OPT_OUT end end end end