Ctskf 831 cccd refactor attachment links actual ticket #7174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This ticket is very much WIP.
I started by removing the download actions for each controller as Active Storage has it's own controller that provides this functionality.
I then removed any reference to
download
from the routes config as it will no longer generate a url from here but will be instead generated through the Active Storage resources routes. I also removeddownload
from anybefore action
in the controllers as this action now no longer exists.I then replaced the previous rails magic routes method in the view partials with the new Active Storage urls. Iit all seemed to work when I ran my local server!! Which made me very happy :).
However - I have been struggling a lot with the tests - they are obviously failing in a number of places!
I decided to remove some failing tests in the Message spec and give them their own active_storage spec as download was no longer part of 'Message'.
This test...
Was not working for me - and saying that it was getting a
Expected response to be a <3XX: redirect>, but was a <404: Not Found>
I did some googling and did this in the routes file
I didn't really understand it at all but it changed my test result to
but was a redirect to ...
I tried to understand what
disk
was!It all continued to go a little wrong from here!!
Ticket
CCCD - Refactor attachment links
Why
Active Storage provides its own controller for this purpose and a link can be created with rails_blobs_path or rails_blob_url.
We should move to using Active Storage rather than the controller actions.
How