Fix/annex mailer admin view - #643
Open
tsubik wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix annex mailer crash for history-only annexes
Sentry:
undefined method 'name_with_fmu' for nilindocument_valid.html.mjml.Cause
When an operator uploads a new version of a document (or the document is
destroyed),
OperatorDocument#disconnect_annexesdrops the annex→documentjoin rows, keeping only the join to
OperatorDocumentHistory. From then onannex.operator_documentis nil, whileannex.operatorstill resolves viathe history — so
notify_about_changespasses itsoperator.present?guard,the mail is sent, and the views blow up on the nil document. Admins can still
approve/reject such annexes from the annex list, which is what triggered it.
Changes
OperatorDocumentAnnex#related_operator_document— the live document, orthe last history entry.
#operatorand#operator_document_namenow gothrough it, so the notification guard and the mail body use the same object.
OperatorDocumentHistory#name/#name_with_fmu, mirroringOperatorDocument.@operator_document/@operator_document_nameonce; the sixannex mail views use them.
(History version)— in the mails(translated: en/fr/es) and in the Documents column of the admin annex list,
which now also links to the history record instead of rendering blank.
Tests
spec/mailers/operator_document_annex_mailer_spec.rb— all three mails, withthe annex attached and history-only, plus the fr translation of the suffix.
spec/controllers/admin/operator_document_annexes_controller_spec.rb— theDocuments column in both states.