So I have this one CakePHP web application that I'm trying to refactor.
There is a large portion of code that usually works like this:
E.g. "Flag":
User clicks flag button
Redirect the user to the flag action
Flag action flags post
Redirect user to post that was just flagged.
I am also trying to enhance it with JavaScript like so:
User clicks flag button
Javascript makes AJAX request to that action
Call returns with a status that JS inteprets
Is there some way to streamline this sort of flow so that it is easily testable and can be covered with a javascript that doesn't need redirection?