Unit test for the issue 8178

Test for the issue  https://github.com/rails/rails/issues/8178
Please review it and let me know if any changes are required.