Currently our system uses the email of the user as a primary key, and other collections uses the email to find the user document.
A coworker suggested that we change the primary key to the Mongo ID, which seems reasonable. The issue is that when I started changing it most of the tests broke, and it is going to take a ton of work to update the all the tests.
So I have a few questions:
-
Since this change has caused most of the tests to break, is there something about the tests that is brittle? Is there a way to build tests that would not be brittle in this way?
-
Is there a way to “refactor the tests so that it is easy to make this change?”
-
Part of the issue is that the new design requires a “profile” for each user. So, wherever I create a user using a factory (girl), I need to create a profile first. Is there an elegant way to run a before filter with Factory Girl to create another document?
-
It is very slow and tedious to go through each test and figure out why it is not working and fix it. Most of the time I am just changing the test. This seems to be a very poor process and I don’t think it is good for the test codebase.