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

fix revision access failing when limit is enabled #639

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dbil25
Copy link

@dbil25 dbil25 commented Oct 3, 2022

When limit is enabled and reached, if a field was initialized but never changed, it will be merged and result in a audit like that:

action: "update", audited_changes: {"name" => "Brandon", "username" => ["brandon", "keepers"]}

(notice the action: "update" and the value in "name" beeing a single value, not an array)

and then, when trying to access a revision, we get this error:

undefined method `last' for "Brandon":String
        attrs[attr] = (action == "update" ? values.last : values)

So in this fix, i added a failing test, then fixed it by changing
attrs[attr] = (action == "update" ? values.last : values) to
attrs[attr] = (values.is_a?(Array) ? values.last : values)

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.

1 participant