Sha256: 96bdc7219476ca24499509a6f6e26b47d463d7f9c8a8068501d3a279c8ae90bd

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

require 'test_helper'

class Person
  include ActiveModel::MassAssignmentSecurity
  include ActiveModel::SuppressForbiddenAttributes

  public :sanitize_for_mass_assignment
end

class ActiveModelSuppressForbiddenAttributesTest < ActiveSupport::TestCase
  def setup
    @log = StringIO.new
    ParamsPatrol.handler= lambda { |x| Logger.new(@log).info(x) }
  end

  test 'forbidden attributes are logged' do
    Person.new.sanitize_for_mass_assignment(ActionController::Parameters.new(a: 'b'))
    @log.rewind
    assert_block do
      /ActiveModel::ForbiddenAttributes/.match(@log.read)
    end
  end

  test 'no error is thrown' do
    assert_nothing_thrown do
      Person.new.sanitize_for_mass_assignment(ActionController::Parameters.new(a: 'b'))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
params_patrol-0.1.0 test/active_model_suppress_forbidden_attributes_test.rb