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.9.7 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.9.6 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.9.5 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.9.4 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.9.3 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.9.2 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.9.1 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.9.0 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.14 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.13 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.12 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.11 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.10 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.9 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.8 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.7 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.6 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.5 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.4 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb
jets-1.8.3 vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb