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

with_papertrail broken when using Papertrail 9x #216

Closed
key88sf opened this issue Apr 17, 2018 · 7 comments
Closed

with_papertrail broken when using Papertrail 9x #216

key88sf opened this issue Apr 17, 2018 · 7 comments

Comments

@key88sf
Copy link
Contributor

key88sf commented Apr 17, 2018

The behavior of this option and its intent is now broken in Papertrail 9 due to this issue:
paper-trail-gem/paper_trail#1076

When using the with_papertrail option and a change is made which affects a counter_culture model, the model's counted row is not updated in the papertrail versions table.

@magnusvk
Copy link
Owner

Interesting. I don’t use this feature myself. It’s interesting though that the tests are green for this behavior in counter_culture as of now. How is that? Would you have a failing test to demonstrate the issue? Also sounds like it might be something that should be fixed in paper_trail rather than here?

@key88sf
Copy link
Contributor Author

key88sf commented Apr 17, 2018

It definitely needs to be fixed in paper_trail. I'm just referencing it here to make people aware. I have a unit test in our application which is failing because of this. Can prob come up with a simplified test case here too.

@magnusvk
Copy link
Owner

magnusvk commented May 2, 2018

@key88sf so PaperTrail added save_with_version which I can use here, too. I think at that point we're back to the previous behavior? Can you verify that fixes your spec?

If so, could you please help me find a spec to include here in counter_culture to verify this behavior going forward? I'm still confused as to which behavior has changed here: Our spec here seems to assert that a version does actually get created.

A related question: This just creates a new version with no object_changes recorded. Is that intended? I'm guessing not, but I also don't think that ever worked, given that counter_culture runs the update with update_all and never assigns attributes to the instance itself. What is even the use-case for this? It turns out this isn't even documented. 😄 I'm starting to think maybe the right approach is to remove this support in this gem?

@key88sf
Copy link
Contributor Author

key88sf commented May 2, 2018

@magnusvk Yes this fixes it.

The spec needs to look within the version created (not just if a version is created). Specifically, it needs to look at the object hash and test that the counter column has been changed/incremented. You are correct object_changes isn't modified by this, however, the value in object should be accurate. That is the test we need, and which will fail if the with_papertrail option is not used.

@magnusvk
Copy link
Owner

magnusvk commented May 3, 2018

@key88sf I added another spec in #218 — but found that I also had to make another change so that it would record the actual, updated count. Previously, it was saving the count as it was before it was incremented, rather than after the increment.

Can you take another look? If #218 still looks good I can merge and release a new gem version.

@key88sf
Copy link
Contributor Author

key88sf commented May 3, 2018

Commented -- I think there is 1 problem. Let me know. Thanks!

@magnusvk
Copy link
Owner

magnusvk commented May 7, 2018

@key88sf update released as 1.11.0. Thanks for your help figuring this out!

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

No branches or pull requests

2 participants