If you try to go to the Works in Collections page for a user that does not exist, e.g. https://test.archiveofourown.org/users/IMNOTREAL/works/collected, you get a 500 error.
You should get a 404 instead.
Ruby and rails newbie here, so I started looking into this to as way to learn about the routing. I think we just need a guard here for invalid users:
What would be the desired behaviour in this situation? Straight up 404, or the same as https://archiveofourown.org/users/randomfakeuser with redirect to search?
Also I would like to add a test, but not sure what's the right file for that (there's no works_controller_spec I could find).
We want a 404 instead of a redirect, yeah.
I think what we’ve done elsewhere to solve problems like this is use find_by! instead of find_by, e.g. and .
Because the works controller is so big, we’ve divided the specs up a bit. It looks like the specs for the collected action are here: https://github.com/otwcode/otwarchive/blob/master/spec/controllers/works/default_rails_actions_spec.rb#L504 (A little counterintuitive since collected is not a default Rails action like index or show, but we probably didn’t want to put it in a separate file.)