Sha256: 629cf054b45fa45ddc7cac3c4ee6730db7b6a28ab8d66e5c04aefa0f12f8f486

Contents?: true

Size: 1.33 KB

Versions: 48

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require "abstract_unit"
require "action_dispatch/middleware/session/abstract_store"

module ActionDispatch
  module Session
    class AbstractStoreTest < ActiveSupport::TestCase
      class MemoryStore < AbstractStore
        def initialize(app)
          @sessions = {}
          super
        end

        def find_session(env, sid)
          sid ||= 1
          session = @sessions[sid] ||= {}
          [sid, session]
        end

        def write_session(env, sid, session, options)
          @sessions[sid] = session
        end
      end

      def test_session_is_set
        env = {}
        as = MemoryStore.new app
        as.call(env)

        assert @env
        assert Request::Session.find ActionDispatch::Request.new @env
      end

      def test_new_session_object_is_merged_with_old
        env = {}
        as = MemoryStore.new app
        as.call(env)

        assert @env
        session = Request::Session.find ActionDispatch::Request.new @env
        session["foo"] = "bar"

        as.call(@env)
        session1 = Request::Session.find ActionDispatch::Request.new @env

        assert_not_equal session, session1
        assert_equal session.to_hash, session1.to_hash
      end

      private
        def app(&block)
          @env = nil
          lambda { |env| @env = env }
        end
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
jets-1.9.7 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.9.6 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.9.5 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.9.4 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.9.3 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.9.2 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.9.1 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.9.0 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.14 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.13 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.12 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.11 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.10 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.9 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.8 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.7 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.6 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.5 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.4 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb
jets-1.8.3 vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb