Sha256: 9987a1bb1476d68d434656c259919cf35b9a8fdc2472b7b369adade4e36bc4d4

Contents?: true

Size: 949 Bytes

Versions: 6

Compression:

Stored size: 949 Bytes

Contents

require 'test_helper'

module SecurityFilter
  def add_one(input)
    "#{input} + 1"
  end
end

class SecurityTest < Test::Unit::TestCase
  include Liquid

  def test_no_instance_eval
    text = %( {{ '1+1' | instance_eval }} )
    expected = %| 1+1 |

    assert_equal expected, Template.parse(text).render(@assigns)
  end

  def test_no_existing_instance_eval
    text = %( {{ '1+1' | __instance_eval__ }} )
    expected = %| 1+1 |

    assert_equal expected, Template.parse(text).render(@assigns)
  end


  def test_no_instance_eval_after_mixing_in_new_filter
    text = %( {{ '1+1' | instance_eval }} )
    expected = %| 1+1 |

    assert_equal expected, Template.parse(text).render(@assigns)
  end


  def test_no_instance_eval_later_in_chain
    text = %( {{ '1+1' | add_one | instance_eval }} )
    expected = %| 1+1 + 1 |

    assert_equal expected, Template.parse(text).render(@assigns, :filters => SecurityFilter)
  end
end # SecurityTest

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
liquid-2.4.1 test/liquid/security_test.rb
liquid-2.4.0 test/liquid/security_test.rb
spinto-liquid-2.3.0.3 test/liquid/security_test.rb
spinto-liquid-2.3.0.2 test/liquid/security_test.rb
spinto-liquid-2.3.0.1 test/liquid/security_test.rb
liquid-2.3.0 test/liquid/security_test.rb