File: deprecated_sanitizer_test.rb

package info (click to toggle)
ruby-rails-deprecated-sanitizer 1.0.3-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 244 kB
  • sloc: ruby: 1,737; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 1,015 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'test_helper'

class DeprecatedSanitizerTest < ActiveSupport::TestCase
  def sanitize_helper
    Class.new do
      include ActionView::Helpers::SanitizeHelper
    end
  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