Sha256: f60103c8d96d8988aa548dbe81db91b72b8e263abef03656807c5bfc01c02d87

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

require 'test_helper'

class UsersController < ActionController::Base
  include ActionController::HandleUnpermittedParameters

  def create
    params.permit(:user)
    head :ok
  end
end

class ActionControllerHandleUnpermittedParamsTest < ActionController::TestCase
  tests UsersController

  def setup
    @log = StringIO.new
    ParamsPatrol.handler= lambda { |x| Logger.new(@log).info(x) }
  end

  test 'missing required parameters will not raise an exception' do
    post :create, { fishing: true }
    assert_response :ok
  end

  test 'missing required parameters will log' do
    post :create, { fishing: true }
    @log.rewind
    assert_block do
      /ActionController::UnpermittedParameters/.match(@log.read)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
params_patrol-0.1.0 test/action_controller_handle_unpermitted_parameters_test.rb