[openstreetmap/openstreetmap-website] Some tests still rely on fixtures (#2614)
Andy Allan
notifications at github.com
Thu May 7 09:05:11 UTC 2020
Some of our tests are written in a way that despite the fixtures being removed (in https://github.com/openstreetmap/openstreetmap-website/pull/1556) they still pass. For example:
* [api/ways_controller_test#test_full](https://github.com/openstreetmap/openstreetmap-website/blob/8b588ee1f9eef3ee1ae7deddf05a3914185c8d5c/test/controllers/api/ways_controller_test.rb#L66-L90) - this test iterates over `Way.all` but there are no ways in the database, so this does nothing.
* [changesets_controller_test#test_index](https://github.com/openstreetmap/openstreetmap-website/blob/8b588ee1f9eef3ee1ae7deddf05a3914185c8d5c/test/controllers/changesets_controller_test.rb#L33-L47) - this checks to ensure that some changesets have rendered, but there are none in the database and checking against an empty `Changesets.all` returns no errors
* similar for `test_index_xhr`, `test_index_bbox`
* `test_index_max_id` - I can't even figure out what this is doing, but it involves checking the id of changesets without any being in the database.
I think the common thread is these tests are all using database queries to build the list of expected objects, instead of stating them explicitly. This allows empty databases to pass (since the list of items shown on the page == list of items in query == 0). It's much better to be explicit about which items to expect.
So we should fix the above tests. And we should double-check if there are any other tests that involve queries to build the list of expected objects. I've grepped around a bit but maybe there's a better way.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/2614
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20200507/7051789d/attachment.htm>
More information about the rails-dev
mailing list