Add test case for template leakage

See https://github.com/rails/rails/pull/8936