module Neo
  module Rails
    class Engine < ::Rails::Engine
      initializer "neo-rails.scenarios_helpers" do
        require 'neo/rails/scenarios/rails_helper'

        ActiveSupport.on_load(:action_view) do
          include Neo::Rails::Scenarios::RailsHelper
        end
      end

      initializer "neo-rails.presenter_method" do
        ActiveSupport.on_load(:action_controller) do
          before_action do |controller|
            Neo::Rails::Presenter.view_context = controller.view_context
          end
        end
      end
    end
  end
end

module Neo
  module Rails
    class Engine < ::Rails::Engine
      initializer "neo-rails.scenarios_helpers" do
        require 'neo/rails/scenarios/rails_helper'

        ActiveSupport.on_load(:action_view) do
          include Neo::Rails::Scenarios::RailsHelper
        end
      end

      initializer "neo-rails.presenter_method" do
        ActiveSupport.on_load(:action_controller) do
          before_action do |controller|
            Neo::Rails::Presenter.view_context = controller.view_context
          end
        end

        ActiveSupport.on_load(:action_mailer) do
          before_action do |mailer|
            Neo::Rails::Presenter.view_context = mailer.view_context
          end
        end
      end
    end
  end
end

Set global view_context before each action mailers call
Set global view_context before each action mailers call

Before this commit accessing `Neo::Rails::Presenter.view_context` in
`ActionMailer` from a delayed job did not work. It was `nil`.
