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

Call really_destroy! in validate_roles, to not throw error when role … #1444

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

njaeggi
Copy link
Contributor

@njaeggi njaeggi commented Dec 30, 2024

…will be deleted anyways

@njaeggi njaeggi linked an issue Dec 30, 2024 that may be closed by this pull request
it "is valid with membership in different section active since today" do
create_role(:matterhorn_mitglieder, "Mitglied", start_on: Time.zone.today)
expect(switch).to be_valid
expect(switch).to be_valid
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason calling .delete only fails when calling this method twice? In our request this method is called twice, resulting in this bug, to recreate it in this spec we have to call it twice...

@@ -40,7 +40,7 @@ def validate_roles
# But this method should not save the roles, so we must roll back after checking the validity.
Role.transaction(requires_new: true) do
roles_to_destroy, roles_to_update = roles.partition(&:marked_for_destruction?)
roles_to_destroy.each { |role| role.delete }
roles_to_destroy.each { |role| role.really_destroy! }
Copy link
Contributor Author

@njaeggi njaeggi Dec 30, 2024

Choose a reason for hiding this comment

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

We should call the same as we would in our save method anyways, where we use really_destroy! for all roles marked for destruction...

This still won't destroy the role on validation, because of the transaction

@njaeggi njaeggi force-pushed the bug/1357/switch-stammsektion-with-new-role branch from 715c29e to f6020fc Compare December 31, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Sektionswechsel mit Mitgliedschaft gültig ab heute
1 participant