Skip to content

Conversation

bcardarella
Copy link
Contributor

This resolves the warning being throw in actionpack/capture_helper_test#test_flush_output_buffer_concats_output_buffer_to_response

After the OutputBuffer was being flushed by calling [0,0] on it the @dirty instance variable was not initialized in the new instance. This was throwing a warning.

The fix here will set the @dirty instance variable to false on the new instance when the slice method is invoked.

@josevalim
Copy link
Contributor

This is weird. Why is slice not calling initialize in the first place? Is there a Ruby hook that it should call? /cc @tenderlove

@bcardarella
Copy link
Contributor Author

Not certain, that threw me for a loop as well. That would make things much simpler and it would ensure the super call in the SafeBuffer initializer is called.

@bcardarella
Copy link
Contributor Author

TBH, I'm not a big fan of the solution I submitted but it was the only one that worked.

@tenderlove
Copy link
Member

@josevalim this is the danger of subclassing core classes. It's an optimization that basically all core classes have (and why we should prefer composition over inheritance).

tenderlove added a commit that referenced this pull request Jul 29, 2011
…_helper_test

Reset @dirty to false when slicing an instance of SafeBuffer
@tenderlove tenderlove merged commit 3e8fe1d into rails:master Jul 29, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants