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

Expire cache when users follow/unfollow #4463

Merged
merged 3 commits into from
Apr 13, 2021
Merged

Expire cache when users follow/unfollow #4463

merged 3 commits into from
Apr 13, 2021

Conversation

javierm
Copy link
Member

@javierm javierm commented Apr 5, 2021

References

Objectives

  • Make sure we display the right button to follow/unfollow proposals or budget investments after users reload the page
  • Make sure users cannot delete other people's follows
  • Reduce the number of security warnings reported by brakeman

@javierm javierm added the Bug label Apr 5, 2021
@javierm javierm self-assigned this Apr 5, 2021
@javierm javierm added this to Reviewing in Consul Democracy via automation Apr 5, 2021
@javierm javierm force-pushed the fix_follow_cache branch 2 times, most recently from 4d0e058 to ac040a4 Compare April 5, 2021 10:35
@javierm javierm linked an issue Apr 5, 2021 that may be closed by this pull request
Base automatically changed from failure_screeshots to master April 6, 2021 15:27
@javierm javierm force-pushed the fix_follow_cache branch 2 times, most recently from d1b7559 to e4e1384 Compare April 9, 2021 15:55
@Senen Senen self-requested a review April 13, 2021 10:27
@Senen Senen self-assigned this Apr 13, 2021
@Senen Senen removed their request for review April 13, 2021 10:39
Copy link
Member

@Senen Senen left a comment

Choose a reason for hiding this comment

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

The PR #4456 fixed the failing spec, so I think we are good to go.

Consul Democracy automation moved this from Reviewing to Testing Apr 13, 2021
Although it wasn't a real security concern because we were only calling
a `find` method based on the user input, it's a good practice to avoid
using constants based on user parameters.

Since we don't use the `find` method anymore but we still need to check
the associated record exists, we're changing the `followable` validation
in the `Follow` model to do exactly that.
Since we're defining abilities with cancancan and using
`load_and_authorize_resource`, we're also modifying the `create` action
for consistency.
When users followed/unfollowed a proposal or a budget investment, the
cache did not expire and so the wrong button was displayed after
reloading the page.
@javierm javierm merged commit d5ee76a into master Apr 13, 2021
Consul Democracy automation moved this from Testing to Release 1.3.0 Apr 13, 2021
@javierm javierm deleted the fix_follow_cache branch April 13, 2021 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Follow proposal button not indicating actual follow state
2 participants