models: delete AdministrateursProcedure when destroying Administrateur
By default, `has_and_belongs_to_many` properly deletes the record in the join table. However, as the association is declared manually with a `has_many / through`, it doesn't delete the joined record automatically. As we also lack a foreign-key contraint on the join table, that means a dangling record remains in the join table. To fix this, let's declare it a proper `has_and_belongs_to_many` association, which will let the join record be deleted automatically on destroy.
This commit is contained in:
parent
9bd1d128d4
commit
71e1b6c973
2 changed files with 2 additions and 3 deletions
|
@ -3,7 +3,7 @@ describe Administrateur, type: :model do
|
|||
|
||||
describe 'associations' do
|
||||
it { is_expected.to have_and_belong_to_many(:instructeurs) }
|
||||
it { is_expected.to have_many(:procedures) }
|
||||
it { is_expected.to have_and_belong_to_many(:procedures) }
|
||||
end
|
||||
|
||||
describe "#renew_api_token" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue