mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
Feat: Data "reset" button (#1913)
* feat: Allow admins to delete family data * feat: Allow self-hosting users to delete cached data * Remove system tests
This commit is contained in:
parent
f7064fd4dd
commit
8208722247
13 changed files with 206 additions and 16 deletions
|
@ -45,4 +45,39 @@ class Settings::HostingsControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_equal NEW_RENDER_DEPLOY_HOOK, Setting.render_deploy_hook
|
||||
end
|
||||
end
|
||||
|
||||
test "can clear data cache when self hosting is enabled" do
|
||||
account = accounts(:investment)
|
||||
holding = account.holdings.first
|
||||
exchange_rate = exchange_rates(:one)
|
||||
security_price = holding.security.prices.first
|
||||
account_balance = account.balances.create!(date: Date.current, balance: 1000, currency: "USD")
|
||||
|
||||
with_self_hosting do
|
||||
perform_enqueued_jobs(only: DataCacheClearJob) do
|
||||
delete clear_cache_settings_hosting_url
|
||||
end
|
||||
end
|
||||
|
||||
assert_redirected_to settings_hosting_url
|
||||
assert_equal I18n.t("settings.hostings.clear_cache.cache_cleared"), flash[:notice]
|
||||
|
||||
assert_not ExchangeRate.exists?(exchange_rate.id)
|
||||
assert_not Security::Price.exists?(security_price.id)
|
||||
assert_not Account::Holding.exists?(holding.id)
|
||||
assert_not Account::Balance.exists?(account_balance.id)
|
||||
end
|
||||
|
||||
test "can clear data only when admin" do
|
||||
with_self_hosting do
|
||||
sign_in users(:family_member)
|
||||
|
||||
assert_no_enqueued_jobs do
|
||||
delete clear_cache_settings_hosting_url
|
||||
end
|
||||
|
||||
assert_redirected_to settings_hosting_url
|
||||
assert_equal I18n.t("settings.hostings.not_authorized"), flash[:alert]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue