Permalink
Browse files

Merge pull request #689 from badosu/dup-locals-hash

Duplicate locals hash when setting instance vars
  • Loading branch information...
2 parents 3a1e4f1 + b54c49b commit 053edd9e823e71d35eb351e094af5af2ef3ca2a6 @nesquena committed on GitHub Apr 19, 2017
Showing with 8 additions and 0 deletions.
  1. +2 −0 lib/rabl/engine.rb
  2. +6 −0 test/engine_test.rb
View
@@ -27,6 +27,8 @@ def source=(source)
# Renders the representation based on source, object, context_scope and locals
# Rabl::Engine.new("...source...", { :format => "xml" }).apply(context_scope, { :foo => "bar", :object => @user })
def apply(context_scope, locals, &block)
+ locals = locals.dup unless locals.nil?
+
set_instance_variables!(context_scope, locals)
reset_settings!
View
@@ -23,6 +23,12 @@
asserts_topic.assigns :_view_path
end
+ context "#apply" do
+ denies("that it raises exception when given frozen locals").raises(RuntimeError) do
+ Rabl::Engine.new("").apply(Object.new, {}.freeze)
+ end
+ end
+
context "#request_format" do
context "is json by default" do
setup do

0 comments on commit 053edd9

Please sign in to comment.