Allow cascade delete Unit/Quantity

Closes #32
This commit is contained in:
2026-02-22 17:50:43 +01:00
parent 1ba7d29441
commit 80130fb7d1
9 changed files with 19 additions and 17 deletions

View File

@@ -6,14 +6,14 @@ require "application_system_test_case"
# * user with no units
class UnitsTest < ApplicationSystemTestCase
LINK_LABELS = {
new_unit: t('units.index.new_unit'),
new_subunit: t('units.unit.new_subunit'),
edit: nil
}
LINK_LABELS = {}
setup do
@user = sign_in
LINK_LABELS.clear
LINK_LABELS[:new_unit] = t('units.index.new_unit')
LINK_LABELS[:new_subunit] = t('units.unit.new_subunit')
LINK_LABELS[:edit] = Regexp.union(@user.units.map(&:symbol))
visit units_path
@@ -26,7 +26,7 @@ class UnitsTest < ApplicationSystemTestCase
end
# Cannot #destroy_all due to {dependent: :restrict*} on Unit.subunits association
@user.units.order(Unit.arel_table[:base_id].eq(nil)).delete_all
@user.units.delete_all
visit units_path
within 'tbody' do
assert_selector 'tr', count: 1

View File

@@ -157,8 +157,9 @@ class UsersTest < ApplicationSystemTestCase
end
assert_difference ->{ User.count }, -1 do
accept_confirm { click_on t("users.registrations.edit.delete") }
assert_current_path new_user_session_path
end
assert_current_path new_user_session_path
assert_text t("devise.registrations.destroyed")
end
test "index forbidden for non admin" do