Sha256: 2d07fb588e62c60f0a9e9068456a68d63b6127cb9d02ddc801c1a0f90df320cf

Contents?: true

Size: 1.02 KB

Versions: 47

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "abstract_unit"
require "action_controller/metal/strong_parameters"

class AlwaysPermittedParametersTest < ActiveSupport::TestCase
  def setup
    ActionController::Parameters.action_on_unpermitted_parameters = :raise
    ActionController::Parameters.always_permitted_parameters = %w( controller action format )
  end

  def teardown
    ActionController::Parameters.action_on_unpermitted_parameters = false
    ActionController::Parameters.always_permitted_parameters = %w( controller action )
  end

  test "returns super on missing constant other than NEVER_UNPERMITTED_PARAMS" do
    ActionController::Parameters.superclass.stub :const_missing, "super" do
      assert_equal "super", ActionController::Parameters::NON_EXISTING_CONSTANT
    end
  end

  test "permits parameters that are whitelisted" do
    params = ActionController::Parameters.new(
      book: { pages: 65 },
      format: "json")
    permitted = params.permit book: [:pages]
    assert_predicate permitted, :permitted?
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
jets-1.8.2 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.1 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.0 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.7.2 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.7.1 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.7.0 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.9 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.8 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.7 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.6 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.5 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.4 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.3 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.2 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.1 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.6.0 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.5.10 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.5.9 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.5.8 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.5.7 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb