From ec576530eaf5f0b9d196285ae7281b71d095cfe2 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Sat, 22 Aug 2026 07:18:46 -0600 Subject: [PATCH] test: cover has-many deleteAll bindings Refs #124 --- .../BaseEntity/Relationships/HasManySpec.cfc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/specs/integration/BaseEntity/Relationships/HasManySpec.cfc b/tests/specs/integration/BaseEntity/Relationships/HasManySpec.cfc index b0e61399..2e543b6a 100644 --- a/tests/specs/integration/BaseEntity/Relationships/HasManySpec.cfc +++ b/tests/specs/integration/BaseEntity/Relationships/HasManySpec.cfc @@ -112,6 +112,16 @@ component extends="tests.resources.ModuleIntegrationSpec" { expect( user.fresh().getPosts() ).toHaveLength( 3 ); } ); + it( "deletes related entities using the actual foreign key value", function() { + var user = getInstance( "User" ).findOrFail( 1 ); + expect( user.posts().count() ).toBe( 2 ); + + user.posts().deleteAll(); + + expect( getInstance( "Post" ).where( "user_id", 1 ).count() ).toBe( 0 ); + expect( getInstance( "Post" ).where( "user_id", 4 ).count() ).toBeGT( 0 ); + } ); + it( "can first off of the relationship", function() { var user = getInstance( "User" ).find( 1 ); var post = user.posts().first();