-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Feat: Data "reset" button #1913
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work here! Just added a few suggestions, but overall this works great.
Family.update_all(last_synced_at: nil) | ||
Family.find_each(&:broadcast_refresh) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though we'll be deleting records across families and a self hosted instance will typically just be one family, I still think we should pass in perform(family)
here and call family.sync_later
at the end of this:
ExchangeRate.delete_all
Security::Price.delete_all
family.accounts.each do |account|
account.balances.delete_all
account.holdings.delete_all
end
# We can replace the Family.update_all and Family.find_each(&:broadcast_refresh) with this:
family.sync_later
}} | ||
%> | ||
</div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a Current.user.admin?
guard for this too?
test/system/settings_test.rb
Outdated
|
||
assert_current_path settings_hosting_path | ||
assert_text I18n.t("settings.hostings.clear_cache.cache_cleared") | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we remove these system tests and keep all our testing for this feature in controller/job tests?
We're trying to keep the system test suite as minimal and stable as possible for CI speed and reliability, and I think we're adding in a lot of dependence on the UI structure here, which may change in the future. The most important tests I think we need for this feature is to validate that:
- Jobs actually delete the intended data
- Admins can't trigger these jobs ever, regardless of what the UI looks like (the UI guards should be purely visual aids)
app/jobs/family_reset_job.rb
Outdated
|
||
# Reset last_synced_at and broadcast refresh | ||
family.update!(last_synced_at: nil) | ||
family.broadcast_refresh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to above, I'd just replace these with a family.sync_later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, nice work!
feat: Allow admins to delete family data
feat: Allow self-hosting users to delete cached data
Close #1901