-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: master
Are you sure you want to change the base?
Conversation
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 |
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.
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! } |
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.
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
715c29e
to
f6020fc
Compare
…will be deleted anyways
f6020fc
to
a22fd73
Compare
…will be deleted anyways