Skip to content

Commit

Permalink
Revert "Raise FilterNotFound on use of non-existent filter"
Browse files Browse the repository at this point in the history
This reverts commit 01c25a1.

Conflicts:

	test/context_test.rb
  • Loading branch information
jamesmacaulay authored and Tobias Lütke committed Jan 14, 2010
1 parent 2e0a661 commit 9854877
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/liquid/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def invoke(method, *args)
if strainer.respond_to?(method)
strainer.__send__(method, *args)
else
raise FilterNotFound, "Filter '#{method}' not found"
args.first
end
end

Expand Down
4 changes: 1 addition & 3 deletions test/context_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ def hi(output)
assert_equal 'hi? hi!', context.invoke(:hi, 'hi?')

context = Context.new
assert_raises(FilterNotFound) {
context.invoke(:hi, 'hi?')
}
assert_equal 'hi?', context.invoke(:hi, 'hi?')

context.add_filters(filter)
assert_equal 'hi? hi!', context.invoke(:hi, 'hi?')
Expand Down
8 changes: 4 additions & 4 deletions test/security_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ class SecurityTest < Test::Unit::TestCase

def test_no_instance_eval
text = %( {{ '1+1' | instance_eval }} )
expected = %! Liquid error: Error - filter 'instance_eval' in ''1+1' | instance_eval' could not be found. !
expected = %| 1+1 |

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

def test_no_existing_instance_eval
text = %( {{ '1+1' | __instance_eval__ }} )
expected = %! Liquid error: Error - filter '__instance_eval__' in ''1+1' | __instance_eval__' could not be found. !
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 = %! Liquid error: Error - filter 'instance_eval' in ''1+1' | instance_eval' could not be found. !
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 = %! Liquid error: Error - filter 'instance_eval' in ''1+1' | add_one | instance_eval' could not be found. !
expected = %| 1+1 + 1 |

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

0 comments on commit 9854877

Please sign in to comment.