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: Accepting another answer does not commit #360

Merged
merged 1 commit into from
Apr 7, 2025
Merged

Conversation

nattsw
Copy link
Contributor

@nattsw nattsw commented Apr 4, 2025

When an answer already exists, clicking "✅ Solution" on another post works, but does not commit.

This PR fixes that and also adds a test, and a transaction around accepting a solution (deleting the topic timer, previous user action, etc).

Copy link
Contributor

@tyb-talks tyb-talks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor comment, otherwise lgtm.

unless acting_user.id == post.user_id
Notification.create!(
notification_type: Notification.types[:custom],
user_id: post.user_id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should make it more obvious the only difference between these 2 Notification.create calls is the user_id? Could be a signal to DRY these other attributes out to a common variable as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, but the notification should only be created in the case of the conditions above, I suspect which is why the original author didn't try to optimise further as well.

@nattsw nattsw merged commit 6e12858 into main Apr 7, 2025
6 checks passed
@nattsw nattsw deleted the accept-reaccept branch April 7, 2025 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants