Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require comment if no audited_changes present #522

Conversation

james
Copy link
Contributor

@james james commented Nov 5, 2019

Change

If a model requires audit comments, but you only change attributes that are excluded from auditing, then don't require an audit comment.

Example of need

I'm working on a project with Southwark Council. We are creating a public audit log of changes to affordable housing in the local area. I have needed to monkey patch this fix/feature in twice:

dxw/affordable-housing-monitoring@1f0bc0d#diff-70e52879b0769bbfd76a2cc96ac3e32aR38 - I don't want to create an audit log entry when changing the aasm state field. By adding the state field as an excluded column, this fixes that, but then creates a validation error if I turn on comment_required

dxw/affordable-housing-monitoring@b5c6475#diff-02864dac712ea1f466e4165075e103cdR23 - A different user of the system edits two attributes on this model to the other attributes on the model, and I don't want to create audit logs for these either. Same problem as above

Considerations

I am pretty certain that this is a bug when it comes to updating a model. However, my suggested fix also makes it so that an audit comment isn't required if you're creating a model where only excluded attributes are present. I think there is more room for debate around whether this is expected/desired behaviour.

james added a commit to dxw/affordable-housing-monitoring that referenced this pull request Nov 5, 2019
We had two bugs with the audited gem, and I've opened PRs for both of them:

collectiveidea/audited#522
collectiveidea/audited#523

In the meantime, while we're waiting for them to hopefully be approved and merged, I have created my own fork with a branch that has both of those changes in.

This means that we no longer need the monkey pathes in the dwelling and development models. Also update the specs to reflect the new, fixed error messages.
If a model requires audit comments, but you only edit attributes that are excluded from auditing, then don't require an audit comment.
@james james force-pushed the fix/dont-require-comment-if-not-audited-changes branch from 9bbe252 to 692cc86 Compare December 23, 2020 16:00
@danielmorrison danielmorrison merged commit 8a194ab into collectiveidea:master May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants