Sha256: d979ba08df22df1552f95c856025329135c4e3efb996af88a9b1a3e20dde896e

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

class Gon
  module SpecHelper
    module Rails
      extend ActiveSupport::Concern

      module ClassMethods
        module GonSession
          def process(*, **)
            # preload threadlocal & store controller instance
            if controller.is_a? ActionController::Base
              controller.gon
              Gon.send(:current_gon).env[Gon::EnvFinder::ENV_CONTROLLER_KEY] =
               controller
            end
            super
          end
        end

        def new(*)
          super.extend(GonSession)
        end
      end
    end
  end
end

if ENV['RAILS_ENV'] == 'test' && defined?(ActionController::TestCase::Behavior)
  ActionController::TestCase::Behavior.send :include, Gon::SpecHelper::Rails
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gon-6.4.0 lib/gon/spec_helpers.rb