Sha256: 44de01c232173a21553c639f74736d272930858efb2dd9e8c6b5bc7de5b71bae

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'test_helper'
require 'action_view'
require 'action_view/helpers/sanitize_helper'

class DeprecatedSanitizerTest < ActiveSupport::TestCase
  def sanitize_helper
    ActionView::Helpers::SanitizeHelper
  end

  test 'Action View sanitizer vendor is set to deprecated sanitizer' do
    assert_equal Rails::DeprecatedSanitizer, sanitize_helper.sanitizer_vendor
  end

  test 'Action View sanitizer vendor returns constant from HTML module' do
    assert_equal HTML::LinkSanitizer, sanitize_helper.sanitizer_vendor.link_sanitizer
  end

  test 'setting allowed tags modifies HTML::WhiteListSanitizers allowed tags' do
    sanitize_helper.sanitized_allowed_tags = %w(horse)
    assert_includes HTML::WhiteListSanitizer.allowed_tags, 'horse'
  end

  test 'setting allowed attributes modifies HTML::WhiteListSanitizers allowed attributes' do
    attrs = %w(for your health)
    sanitize_helper.sanitized_allowed_attributes = attrs
    attrs.each do |attr|
      assert_includes HTML::WhiteListSanitizer.allowed_attributes, attr
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-deprecated_sanitizer-1.0.2 test/deprecated_sanitizer_test.rb
rails-deprecated_sanitizer-1.0.1 test/deprecated_sanitizer_test.rb
rails-deprecated_sanitizer-1.0.0 test/deprecated_sanitizer_test.rb