Sha256: f3b92cf06fa76d51b8a905082861673200b96168190f073f284888ae9068c9e2

Contents?: true

Size: 1.67 KB

Versions: 48

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

require "abstract_unit"
require "stringio"

class ActionController::TestRequestTest < ActionController::TestCase
  def test_test_request_has_session_options_initialized
    assert @request.session_options
  end

  def test_mutating_session_options_does_not_affect_default_options
    @request.session_options[:myparam] = 123
    assert_nil ActionController::TestSession::DEFAULT_OPTIONS[:myparam]
  end

  def test_content_length_has_bytes_count_value
    non_ascii_parameters = { data: { content: "Latin + Кириллица" } }
    @request.set_header "REQUEST_METHOD", "POST"
    @request.set_header "CONTENT_TYPE", "application/json"
    @request.assign_parameters(@routes, "test", "create", non_ascii_parameters,
                               "/test", [:data, :controller, :action])
    assert_equal(StringIO.new(non_ascii_parameters.to_json).length.to_s,
                 @request.get_header("CONTENT_LENGTH"))
  end

  ActionDispatch::Session::AbstractStore::DEFAULT_OPTIONS.each_pair do |key, value|
    test "rack default session options #{key} exists in session options and is default" do
      if value.nil?
        assert_nil(@request.session_options[key],
                   "Missing rack session default option #{key} in request.session_options")
      else
        assert_equal(value, @request.session_options[key],
                     "Missing rack session default option #{key} in request.session_options")
      end
    end

    test "rack default session options #{key} exists in session options" do
      assert(@request.session_options.has_key?(key),
                   "Missing rack session option #{key} in request.session_options")
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

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