Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/resources/app/models/User.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ component extends="quick.models.BaseEntity" accessors="true" {
return hasOne( "Post", "post_pk", "favoritePost_id" );
}

function favoritePostAuthor() {
return hasOneThrough( [ "favoritePost", "author" ] );
}

function latestPostWithEmptyDefault() {
return hasOne( "Post", "user_id" ).latest().withDefault();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ component extends="tests.resources.ModuleIntegrationSpec" {
expect( country.getLatestPost().getPost_Pk() ).toBe( 523526 );
expect( country.getLatestPost().getBody() ).toBe( "My second awesome post body" );
} );

it( "can start with a hasOne relationship", function() {
var user = getInstance( "User" ).findOrFail( 1 );

expect( user.getFavoritePostAuthor() ).notToBeNull();
expect( user.getFavoritePostAuthor().getId() ).toBe( user.getId() );
} );
} );
}

Expand Down
Loading