Clear the transaction state when AR object is duped #31751
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
Original issue is "ActiveRecord persisted? returns true after rollback when using duped record". Can you test that issue is fixed? |
@kamipo, here is the test before and after the fix: $ git co master $ git co clear_transaction_state_when_ar_object_is_duped |
Yeah, can you add the test in the commit to catch a future regression? |
@kamipo done |
def test_dup_transaction_state_and_transaction_record_state_are_cleared | ||
topic = Topic.first | ||
topic.send(:set_transaction_state, ActiveRecord::ConnectionAdapters::TransactionState.new(:rollback)) | ||
topic.send(:remember_transaction_record_state) |
kamipo
Jan 24, 2018
Member
We don't need to test internal states with private methods as long as it can be tested from public API.
And also, this test case does not show that the state of the record when the transaction was rolled back has been fixed.
We don't need to test internal states with private methods as long as it can be tested from public API.
And also, this test case does not show that the state of the record when the transaction was rolled back has been fixed.
yoreek
Jan 24, 2018
Author
Contributor
Thanks for review.
This test only checks that the transaction state is cleared in the duped record. I think that we must clear this state as well as other statuses. Do you think it is necessary to test the complete scheme with the rollback of the transaction?
And, unfortunately I did not find a public methods to access to @transaction_state
and @_start_transaction_state
, could you help me ?
Thanks for review.
This test only checks that the transaction state is cleared in the duped record. I think that we must clear this state as well as other statuses. Do you think it is necessary to test the complete scheme with the rollback of the transaction?
And, unfortunately I did not find a public methods to access to @transaction_state
and @_start_transaction_state
, could you help me ?
kamipo
Jan 25, 2018
Member
Since these are internal states we don't have any way to access to the states.
So it is enough to test the transaction behavior which tested in the following test rather than testing the states.
The test_dup_record_not_persisted_after_rollback_transaction
sufficiently shows which behavior is fixed.
So we simply remove the test_dup_transaction_state_and_transaction_record_state_are_cleared
.
Since these are internal states we don't have any way to access to the states.
So it is enough to test the transaction behavior which tested in the following test rather than testing the states.
The test_dup_record_not_persisted_after_rollback_transaction
sufficiently shows which behavior is fixed.
So we simply remove the test_dup_transaction_state_and_transaction_record_state_are_cleared
.
yoreek
Jan 25, 2018
Author
Contributor
ok, I removed the test and added the entry to CHANGELOG.
ok, I removed the test and added the entry to CHANGELOG.
Can you add CHANGELOG entry what issue is fixed? |
226116a
Fixes #31670