mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #2344 from bcardarella/resolve_warning_for_capture_helper_test
Reset @dirty to false when slicing an instance of SafeBuffer
This commit is contained in:
@@ -86,6 +86,12 @@ module ActiveSupport #:nodoc:
|
||||
end
|
||||
end
|
||||
|
||||
def[](*args)
|
||||
new_safe_buffer = super
|
||||
new_safe_buffer.instance_eval { @dirty = false }
|
||||
new_safe_buffer
|
||||
end
|
||||
|
||||
def safe_concat(value)
|
||||
raise SafeConcatError if dirty?
|
||||
original_concat(value)
|
||||
|
||||
@@ -106,4 +106,10 @@ class SafeBufferTest < ActiveSupport::TestCase
|
||||
test "should not fail if the returned object is not a string" do
|
||||
assert_kind_of NilClass, @buffer.slice("chipchop")
|
||||
end
|
||||
|
||||
test "Should initialize @dirty to false for new instance when sliced" do
|
||||
dirty = @buffer[0,0].send(:dirty?)
|
||||
assert_not_nil dirty
|
||||
assert !dirty
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user