Sha256: df66beee7fabbda42e8f07601919e51cb44a4ccaddee4001de4589ea49b762bd

Contents?: true

Size: 730 Bytes

Versions: 3

Compression:

Stored size: 730 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

3 entries across 3 versions & 1 rubygems

Version Path
gon-6.3.2 lib/gon/spec_helpers.rb
gon-6.3.1 lib/gon/spec_helpers.rb
gon-6.2.1 lib/gon/spec_helpers.rb