quickdraw/compilation_equivalence_cases/data_references.rb

Lines

100%

16 of 16 covered

Branches

—

0 of 0 covered

Methods

100%

3 of 3 covered

1# frozen_string_literal: true
2
31module EquivalenceCases
41 module DataReferences
5 # `data` is a URL on `object`, unless it's a Hash of `data-*` attributes.
61 class DataReferences < Phlex::HTML
7 VALUES = [
81 "/files/report.pdf",
9 "javascript:alert(1)",
10 "&#106;avascript:alert(1)",
11 :"javascript:alert(1)",
12 ["javascript:alert(1)"],
13 [],
14 { controller: "x", action: "javascript:y" },
15 nil,
16 ].freeze
17
181 def self.equivalence_scenarios
192 VALUES.each_with_index.to_h do |value, index|
2032 ["value #{index}", -> (klass) { klass.new(value).call }]
21 end
22 end
23
241 def initialize(value)
2516 @value = value
26 end
27
281 def view_template
298 object(data: @value)
308 object(data: @value, type: "application/pdf")
318 object("data" => @value)
328 object(data: "/files/#{@value}")
338 object(data: "#{@value}")
348 div(data: { controller: @value.to_s })
35 end
36 end
37 end
38end