diff --git a/.github/patches/testbox-full-null.patch b/.github/patches/testbox-full-null.patch deleted file mode 100644 index ec53024c..00000000 --- a/.github/patches/testbox-full-null.patch +++ /dev/null @@ -1,63 +0,0 @@ -diff --git a/testbox/system/coverage/CoverageService.cfc b/testbox/system/coverage/CoverageService.cfc ---- a/testbox/system/coverage/CoverageService.cfc -+++ b/testbox/system/coverage/CoverageService.cfc -@@ -175 +175 @@ -- if ( isNull( opts.coverageTresholds ) ) { -+ if ( !structKeyExists( opts, "coverageTresholds" ) || isNull( opts.coverageTresholds ) ) { -@@ -178 +178 @@ -- if ( isNull( opts.coverageTresholds.good ) ) { -+ if ( !structKeyExists( opts.coverageTresholds, "good" ) || isNull( opts.coverageTresholds.good ) ) { -@@ -181 +181 @@ -- if ( isNull( opts.coverageTresholds.bad ) ) { -+ if ( !structKeyExists( opts.coverageTresholds, "bad" ) || isNull( opts.coverageTresholds.bad ) ) { -diff --git a/testbox/system/TestBox.cfc b/testbox/system/TestBox.cfc ---- a/testbox/system/TestBox.cfc -+++ b/testbox/system/TestBox.cfc -@@ -408 +408 @@ -- if ( !isNull( url.testBundles ) ) { -+ if ( structKeyExists( url, "testBundles" ) && !isNull( url.testBundles ) ) { -@@ -411 +411 @@ -- if ( !isNull( url.testSuites ) ) { -+ if ( structKeyExists( url, "testSuites" ) && !isNull( url.testSuites ) ) { -@@ -414 +414 @@ -- if ( !isNull( url.testSpecs ) ) { -+ if ( structKeyExists( url, "testSpecs" ) && !isNull( url.testSpecs ) ) { -@@ -417 +417 @@ -- if ( !isNull( url.testMethod ) ) { -+ if ( structKeyExists( url, "testMethod" ) && !isNull( url.testMethod ) ) { -@@ -259 +259 @@ -- if ( isNull( variables.env ) ) { -+ if ( !structKeyExists( variables, "env" ) || isNull( variables.env ) ) { -diff --git a/testbox/system/util/Util.cfc b/testbox/system/util/Util.cfc ---- a/testbox/system/util/Util.cfc -+++ b/testbox/system/util/Util.cfc -@@ -203 +203 @@ -- if ( isNull( variables.engineMappingHelper ) ) { -+ if ( !structKeyExists( variables, "engineMappingHelper" ) || isNull( variables.engineMappingHelper ) ) { -diff --git a/testbox/system/util/Env.cfc b/testbox/system/util/Env.cfc ---- a/testbox/system/util/Env.cfc -+++ b/testbox/system/util/Env.cfc -@@ -87 +87 @@ -- if ( isNull( variables.javaSystem ) ) { -+ if ( !structKeyExists( variables, "javaSystem" ) || isNull( variables.javaSystem ) ) { -diff --git a/testbox/system/BaseSpec.cfc b/testbox/system/BaseSpec.cfc ---- a/testbox/system/BaseSpec.cfc -+++ b/testbox/system/BaseSpec.cfc -@@ -1627 +1627 @@ -- if ( isNull( variables.$cbMockData ) ) { -+ if ( !structKeyExists( variables, "$cbMockData" ) || isNull( variables.$cbMockData ) ) { -@@ -1640 +1640 @@ -- if ( isNull( variables.$utility ) ) { -+ if ( !structKeyExists( variables, "$utility" ) || isNull( variables.$utility ) ) { -@@ -1653 +1653 @@ -- if ( isNull( variables.$env ) ) { -+ if ( !structKeyExists( variables, "$env" ) || isNull( variables.$env ) ) { -@@ -1668 +1668 @@ -- if ( isNull( this.$mockbox ) ) { -+ if ( !structKeyExists( this, "$mockbox" ) || isNull( this.$mockbox ) ) { -diff --git a/testbox/system/runners/BDDRunner.cfc b/testbox/system/runners/BDDRunner.cfc ---- a/testbox/system/runners/BDDRunner.cfc -+++ b/testbox/system/runners/BDDRunner.cfc -@@ -159 +159 @@ -- isNull( thisSuite ) ? {} : thisSuite -+ !structKeyExists( local, "thisSuite" ) || isNull( local.thisSuite ) ? {} : local.thisSuite diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 92825024..fc2409ba 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -85,7 +85,6 @@ jobs: - name: Install dependencies run: | box install - git apply --unidiff-zero .github/patches/testbox-full-null.patch git apply --unidiff-zero .github/patches/mementifier-full-null.patch box config set modules.commandbox-dotenv.checkEnvPreServerStart=false box install ${{ matrix.coldbox }} --noSave diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 93f2ac0e..d9bac6f1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -73,7 +73,6 @@ jobs: - name: Install dependencies run: | box install - git apply --unidiff-zero .github/patches/testbox-full-null.patch git apply --unidiff-zero .github/patches/mementifier-full-null.patch box config set modules.commandbox-dotenv.checkEnvPreServerStart=false box install ${{ matrix.coldbox }} --noSave diff --git a/box.json b/box.json index 74366b87..86d952a6 100644 --- a/box.json +++ b/box.json @@ -36,7 +36,7 @@ }, "devDependencies":{ "coldbox":"^8.0.0", - "testbox":"^7.0.0", + "testbox":"^7.1.0", "cfcollection":"^3.6.4", "cfmigrations":"^5.0.0" }, diff --git a/dsl/QuickServiceDSL.cfc b/dsl/QuickServiceDSL.cfc index 3d3493b1..90214459 100644 --- a/dsl/QuickServiceDSL.cfc +++ b/dsl/QuickServiceDSL.cfc @@ -26,7 +26,9 @@ component { public any function process( required struct definition ) { return variables.injector.getInstance( name = "BaseService@quick", - initArguments = { entity : variables.injector.getInstance( listRest( arguments.definition.dsl, ":" ) ) } + initArguments = { + entity : variables.injector.getInstance( listRest( arguments.definition.dsl, ":" ) ) + } ); } diff --git a/models/BaseEntity.cfc b/models/BaseEntity.cfc index c5b9ffa0..2c7f3df0 100644 --- a/models/BaseEntity.cfc +++ b/models/BaseEntity.cfc @@ -367,7 +367,7 @@ component accessors="true" { metadataInspection(); if ( !variables._loadShallow ) { setUpMementifier(); - fireEvent( "instanceReady", { entity : this } ); + fireEvent( "instanceReady", { entity : this } ); } } @@ -1172,7 +1172,7 @@ component accessors="true" { */ public any function markLoaded() { variables._loaded = true; - fireEvent( "postLoad", { entity : this } ); + fireEvent( "postLoad", { entity : this } ); return this; } @@ -1510,7 +1510,7 @@ component accessors="true" { */ public any function fresh() { var hasRefreshQuery = variables.keyExists( "_refreshQuery" ) && !isNull( variables._refreshQuery ); - var freshEntity = hasRefreshQuery ? variables._refreshQuery.clone().offset( 0 ) : newQuery(); + var freshEntity = newRefreshQuery(); freshEntity.from( tableName() ); var entityKeyNames = keyNames(); var entityKeyValues = keyValues(); @@ -1521,6 +1521,9 @@ component accessors="true" { } freshQB.addNestedWhereQuery( freshConstraints ); var freshData = freshEntity.first(); + if ( isStruct( freshData ) && structIsEmpty( freshData ) ) { + return javacast( "null", "" ); + } if ( !isStruct( freshData ) || structKeyExists( freshData, "isQuickEntity" ) ) { return freshData; } @@ -1537,9 +1540,7 @@ component accessors="true" { public any function refresh() { variables._relationshipsData = {}; variables._relationshipsLoaded = {}; - var refreshedEntity = !variables.keyExists( "_refreshQuery" ) || isNull( variables._refreshQuery ) ? newQuery() : variables._refreshQuery - .clone() - .offset( 0 ); + var refreshedEntity = newRefreshQuery(); refreshedEntity.from( tableName() ); var entityKeyNames = keyNames(); var entityKeyValues = keyValues(); @@ -1558,6 +1559,23 @@ component accessors="true" { return this; } + /** + * Reuse loaded projections, but refresh by key under current global scopes + * rather than the original query's filters, whose values may have changed. + */ + private any function newRefreshQuery() { + var scopedQuery = newQuery(); + if ( !variables.keyExists( "_refreshQuery" ) || isNull( variables._refreshQuery ) ) { + return scopedQuery; + } + var globalQuery = scopedQuery.activateGlobalScopes().getQB(); + var refreshQuery = variables._refreshQuery.clone().offset( 0 ); + refreshQuery.setWheres( globalQuery.getWheres() ); + var refreshBindings = refreshQuery.getRawBindings(); + refreshBindings.where = globalQuery.getRawBindings().where; + return refreshQuery; + } + /** * Return a clone of this entity. * @@ -1950,7 +1968,7 @@ component accessors="true" { */ public any function delete() { guardReadOnly(); - fireEvent( "preDelete", { entity : this } ); + fireEvent( "preDelete", { entity : this } ); guardAgainstNotLoaded( "This instance is not loaded so it cannot be deleted. " & "Did you maybe mean to use `deleteAll`?" @@ -1968,12 +1986,12 @@ component accessors="true" { deleteQuery.updateAll( { "#column#" : deletedDate } ); assignAttribute( column, deletedDate ); assignOriginalAttributes( retrieveAttributesData() ); - fireEvent( "postDelete", { entity : this } ); + fireEvent( "postDelete", { entity : this } ); return this; } forceDelete( fireEvents = false ); - fireEvent( "postDelete", { entity : this } ); + fireEvent( "postDelete", { entity : this } ); return this; } @@ -1984,7 +2002,7 @@ component accessors="true" { guardReadOnly(); guardAgainstNotLoaded( "This instance is not loaded so it cannot be force deleted." ); if ( arguments.fireEvents ) { - fireEvent( "preDelete", { entity : this } ); + fireEvent( "preDelete", { entity : this } ); } var deleteQuery = newQuery().withoutGlobalScope( "softDeletes" ); @@ -2008,7 +2026,7 @@ component accessors="true" { variables._loaded = false; if ( arguments.fireEvents ) { - fireEvent( "postDelete", { entity : this } ); + fireEvent( "postDelete", { entity : this } ); } return this; } @@ -2456,7 +2474,7 @@ component accessors="true" { invoke( this, relationshipMethod, - { entity : relatedEntity } + { entity : relatedEntity } ); } fireEvent( @@ -3967,7 +3985,7 @@ component accessors="true" { param variables._queryOptions = {}; if ( variables._queryOptions.isEmpty() && variables._meta.originalMetadata.keyExists( "datasource" ) ) { - variables._queryOptions = { datasource : variables._meta.originalMetadata.datasource }; + variables._queryOptions = { datasource : variables._meta.originalMetadata.datasource }; } variables._readonly = variables._meta.readonly; variables._softDeletes = variables._meta.softDeletes; @@ -4723,7 +4741,7 @@ component accessors="true" { invoke( this, arguments.eventName, - { eventData : arguments.eventData } + { eventData : arguments.eventData } ); } announceInterceptionPoint( "quick" & arguments.eventName, arguments.eventData ); diff --git a/models/QuickBuilder.cfc b/models/QuickBuilder.cfc index 64fd6803..37222a15 100644 --- a/models/QuickBuilder.cfc +++ b/models/QuickBuilder.cfc @@ -203,7 +203,7 @@ component accessors="true" transientCache="false" { } for ( var keyColumn in getEntity().keyColumns() ) { - var qualifiedKey = getEntity().qualifyColumn( keyColumn ); + var qualifiedKey = qualifyColumnForQuery( keyColumn, variables.qb ); var hasKey = false; for ( var column in selectedColumns ) { if ( column.type == "simple" && compareNoCase( column.value, qualifiedKey ) == 0 ) { @@ -1344,17 +1344,9 @@ component accessors="true" transientCache="false" { return result; } - throw( - type = "QuickMissingMethod", - message = arrayToList( - [ - "Quick couldn't figure out what to do with [#arguments.missingMethodName#].", - "We tried checking columns, aliases, scopes, and relationships locally.", - "We also forwarded the call on to qb to see if it could do anything with it, but it couldn't." - ], - " " - ) - ); + // A delegated method may succeed without returning a value (for example, + // qb's existence assertions). Missing methods already throw from qb. + return; } /** diff --git a/resources/testing/FactoryManager.cfc b/resources/testing/FactoryManager.cfc index 5df5c2ed..bcda0359 100644 --- a/resources/testing/FactoryManager.cfc +++ b/resources/testing/FactoryManager.cfc @@ -27,11 +27,11 @@ component { variables.factories[ arguments.name ] = variables.wirebox.getInstance( name = "#variables.factoryPath#.#arguments.name#Factory", initArguments = { - entityProvider : variables.wirebox.getInstance( + entityProvider : variables.wirebox.getInstance( dsl = "provider:#arguments.name#", targetObject = this ), - context : variables.context + context : variables.context } ); } diff --git a/tests/resources/factories/UserFactory.cfc b/tests/resources/factories/UserFactory.cfc index a467b707..fb4d74d1 100644 --- a/tests/resources/factories/UserFactory.cfc +++ b/tests/resources/factories/UserFactory.cfc @@ -17,11 +17,11 @@ component extends="quick.resources.testing.Factory" { } any function administrator() { - return state( { type : "admin" } ); + return state( { type : "admin" } ); } any function wired() { - return state( { firstName : isObject( variables.wirebox ) ? "Injected" : "Missing" } ); + return state( { firstName : isObject( variables.wirebox ) ? "Injected" : "Missing" } ); } } diff --git a/tests/specs/integration/BaseEntity/ChildClassSpec.cfc b/tests/specs/integration/BaseEntity/ChildClassSpec.cfc index f72592a5..20ae5db2 100644 --- a/tests/specs/integration/BaseEntity/ChildClassSpec.cfc +++ b/tests/specs/integration/BaseEntity/ChildClassSpec.cfc @@ -378,7 +378,7 @@ component extends="tests.resources.ModuleIntegrationSpec" { // comment id 4 = internal comment var internalComment = getInstance( "Comment" ) .findOrFail( 4 ) - .update( { reason : "Super private, ya know?" } ); + .update( { reason : "Super private, ya know?" } ); var uInternalComment = getInstance( "Comment" ).findOrFail( 4 ); @@ -386,7 +386,9 @@ component extends="tests.resources.ModuleIntegrationSpec" { expect( uInternalComment.getReason() ).toBe( "Super private, ya know?" ); // comment id 5 = picture comment - var pictureComment = getInstance( "Comment" ).findOrFail( 5 ).update( { filename : "Lenna.jpeg" } ); + var pictureComment = getInstance( "Comment" ) + .findOrFail( 5 ) + .update( { filename : "Lenna.jpeg" } ); var uPictureComment = getInstance( "Comment" ).findOrFail( 5 ); diff --git a/tests/specs/integration/BaseEntity/ColumnsSpec.cfc b/tests/specs/integration/BaseEntity/ColumnsSpec.cfc index d1050d06..c8711807 100644 --- a/tests/specs/integration/BaseEntity/ColumnsSpec.cfc +++ b/tests/specs/integration/BaseEntity/ColumnsSpec.cfc @@ -100,7 +100,7 @@ component extends="tests.resources.ModuleIntegrationSpec" { it( "translates attributes to their column names", function() { expect( function() { - getInstance( "Link" ).create( { url : "https://example.com" } ); + getInstance( "Link" ).create( { url : "https://example.com" } ); } ).notToThrow(); } ); @@ -124,6 +124,31 @@ component extends="tests.resources.ModuleIntegrationSpec" { expect( user.getUsername() ).toBe( "elpete" ); } ); + it( "qualifies automatically selected keys with a derived table alias", function() { + var users = getInstance( "User" ) + .newQuery() + .fromSub( "selected_users", getInstance( "User" ).select( [ "id", "username" ] ) ) + .reselect( "selected_users.username" ) + .orderBy( "selected_users.id" ) + .get(); + expect( users[ 1 ].getId() ).toBe( 1 ); + expect( users[ 1 ].getUsername() ).toBe( "elpete" ); + } ); + + it( "does not add the original table key when a derived key is already selected", function() { + var users = getInstance( "User" ) + .newQuery() + .fromSub( "selected_users", getInstance( "User" ).select( [ "id", "username" ] ) ) + .reselect( [ + "selected_users.id", + "selected_users.username" + ] ) + .orderBy( "selected_users.id" ) + .get(); + expect( users[ 1 ].getId() ).toBe( 1 ); + expect( users[ 1 ].getUsername() ).toBe( "elpete" ); + } ); + it( "preserves every composite key column when selecting specific columns", function() { var composite = getInstance( "Composite" ).select( "a" ).findOrFail( [ 1, 2 ] ); diff --git a/tests/specs/integration/BaseEntity/GetSpec.cfc b/tests/specs/integration/BaseEntity/GetSpec.cfc index 6d4b524c..b3f899e2 100644 --- a/tests/specs/integration/BaseEntity/GetSpec.cfc +++ b/tests/specs/integration/BaseEntity/GetSpec.cfc @@ -22,7 +22,7 @@ component extends="tests.resources.ModuleIntegrationSpec" { it( "passes query options when finding an entity by primary key", function() { structDelete( request, "baseEntityGetSpecPreQBExecute" ); - var user = getInstance( "User" ).find( 1, { datasource : "quick" } ); + var user = getInstance( "User" ).find( 1, { datasource : "quick" } ); var executionsWithDatasource = request.baseEntityGetSpecPreQBExecute.filter( function( execution ) { return execution.options.keyExists( "datasource" ); } ); @@ -80,6 +80,32 @@ component extends="tests.resources.ModuleIntegrationSpec" { expect( user.getLatestPostId() ).toBe( 1245 ); } ); + it( "refreshes a scoped projection after the original filter value changes", function() { + var user = getInstance( "User" ) + .withFullName() + .whereUsername( "elpete" ) + .firstOrFail(); + user.update( { "username" : "changed" } ); + user.refresh(); + expect( user.isLoaded() ).toBeTrue(); + expect( user.getId() ).toBe( 1 ); + expect( user.getUsername() ).toBe( "changed" ); + expect( user.getFullName() ).toBe( "Eric Peterson" ); + } ); + + it( "retrieves a fresh projected entity after the original filter value changes", function() { + var user = getInstance( "User" ) + .withFullName() + .whereUsername( "elpete" ) + .firstOrFail(); + user.update( { "username" : "changed" } ); + var freshUser = user.fresh(); + expect( freshUser ).notToBeNull(); + expect( freshUser.getId() ).toBe( 1 ); + expect( freshUser.getUsername() ).toBe( "changed" ); + expect( freshUser.getFullName() ).toBe( "Eric Peterson" ); + } ); + it( "can get a fresh instance from the database", function() { var user = getInstance( "User" ).find( 1 ); expect( user.getUsername() ).toBe( "elpete" ); @@ -142,6 +168,28 @@ component extends="tests.resources.ModuleIntegrationSpec" { } ).toThrow( type = "EntityNotFound", regex = "No User found with that criteria" ); } ); + it( "forwards successful void qb assertions without treating them as missing methods", function() { + expect( function() { + getInstance( "User" ).whereUsername( "doesnt-exist" ).expectNotToExist(); + getInstance( "User" ).whereUsername( "johndoe" ).expectToExist(); + } ).notToThrow(); + } ); + + it( "preserves failures from forwarded qb assertions", function() { + expect( function() { + getInstance( "User" ).whereUsername( "johndoe" ).expectNotToExist(); + } ).toThrow( "TestBox.AssertionFailed" ); + expect( function() { + getInstance( "User" ).whereUsername( "doesnt-exist" ).expectToExist(); + } ).toThrow( "TestBox.AssertionFailed" ); + } ); + + it( "still rejects a method that qb does not provide", function() { + expect( function() { + getInstance( "User" ).methodThatDoesNotExist(); + } ).toThrow( "QuickMissingMethod" ); + } ); + it( "can return if an entity exists", function() { expect( getInstance( "User" ).whereUsername( "johndoe" ).exists() ).toBeTrue(); diff --git a/tests/specs/integration/BaseEntity/GlobalScopeSpec.cfc b/tests/specs/integration/BaseEntity/GlobalScopeSpec.cfc index e0c844ee..210504ca 100644 --- a/tests/specs/integration/BaseEntity/GlobalScopeSpec.cfc +++ b/tests/specs/integration/BaseEntity/GlobalScopeSpec.cfc @@ -55,6 +55,23 @@ component extends="tests.resources.ModuleIntegrationSpec" { expect( user.getCountryName() ).toBe( "United States" ); } ); + it( "retains global restrictions when replacing stale refresh filters", function() { + var user = getInstance( "Admin" ).whereUsername( "elpete" ).firstOrFail(); + user.update( { "username" : "changed_admin" } ); + user.refresh(); + expect( user.getUsername() ).toBe( "changed_admin" ); + expect( user.getType() ).toBe( "admin" ); + var freshUser = user.fresh(); + expect( freshUser.getId() ).toBe( 1 ); + expect( freshUser.getLatestPostId() ).toBe( 523526 ); + } ); + + it( "does not bypass global restrictions when refreshing a projected entity", function() { + var user = getInstance( "Admin" ).whereUsername( "elpete" ).firstOrFail(); + user.update( { "type" : "limited" } ); + expect( user.fresh() ).toBeNull(); + } ); + it( "returns global scoped virtual columns with the memento by default", function() { var user = getInstance( "UserWithGlobalScope" ).findOrFail( 1 ).getMemento(); expect( user ).toHaveKey( "countryName" ); diff --git a/tests/specs/integration/BaseEntity/ReadOnlyEntitySpec.cfc b/tests/specs/integration/BaseEntity/ReadOnlyEntitySpec.cfc index 36ada53d..0c054ce7 100644 --- a/tests/specs/integration/BaseEntity/ReadOnlyEntitySpec.cfc +++ b/tests/specs/integration/BaseEntity/ReadOnlyEntitySpec.cfc @@ -12,7 +12,7 @@ component extends="tests.resources.ModuleIntegrationSpec" { it( "prevents create from being performed on new instances", function() { expect( function() { - getInstance( "Referral" ).create( { type : "internal" } ); + getInstance( "Referral" ).create( { type : "internal" } ); } ).toThrow( type = "QuickReadOnlyException" ); } ); @@ -27,13 +27,13 @@ component extends="tests.resources.ModuleIntegrationSpec" { it( "prevents updates from being performed on existing instances", function() { var referral = getInstance( "Referral" ).findOrFail( 1 ); expect( function() { - referral.update( { type : "external" } ); + referral.update( { type : "external" } ); } ).toThrow( type = "QuickReadOnlyException" ); } ); it( "prevents mass updates from being performed on existing instances", function() { expect( function() { - getInstance( "Referral" ).updateAll( { type : "external" } ); + getInstance( "Referral" ).updateAll( { type : "external" } ); } ).toThrow( type = "QuickReadOnlyException" ); } ); diff --git a/tests/specs/integration/BaseEntity/ReadOnlyPropertySpec.cfc b/tests/specs/integration/BaseEntity/ReadOnlyPropertySpec.cfc index 1b505057..33178f8b 100644 --- a/tests/specs/integration/BaseEntity/ReadOnlyPropertySpec.cfc +++ b/tests/specs/integration/BaseEntity/ReadOnlyPropertySpec.cfc @@ -31,7 +31,7 @@ component extends="tests.resources.ModuleIntegrationSpec" { it( "prevents create from setting read-only properties", function() { expect( function() { - getInstance( "Link" ).create( { createdDate : now() } ); + getInstance( "Link" ).create( { createdDate : now() } ); } ).toThrow( type = "QuickReadOnlyException" ); } ); @@ -45,20 +45,20 @@ component extends="tests.resources.ModuleIntegrationSpec" { it( "prevents fill from being called containing a read-only property", function() { var link = getInstance( "Link" ).findOrFail( 1 ); expect( function() { - link.fill( { createdDate : now() } ); + link.fill( { createdDate : now() } ); } ).toThrow( type = "QuickReadOnlyException" ); } ); it( "prevents updates from being performed on a read-only property", function() { var link = getInstance( "Link" ).findOrFail( 1 ); expect( function() { - link.update( { createdDate : now() } ); + link.update( { createdDate : now() } ); } ).toThrow( type = "QuickReadOnlyException" ); } ); it( "prevents mass updates from being performed on read-only properties", function() { expect( function() { - getInstance( "Link" ).updateAll( { createdDate : now() } ); + getInstance( "Link" ).updateAll( { createdDate : now() } ); } ).toThrow( type = "QuickReadOnlyException" ); } ); diff --git a/tests/specs/integration/BaseServiceSpec.cfc b/tests/specs/integration/BaseServiceSpec.cfc index 58bea79e..604b91a0 100644 --- a/tests/specs/integration/BaseServiceSpec.cfc +++ b/tests/specs/integration/BaseServiceSpec.cfc @@ -17,12 +17,12 @@ component extends="tests.resources.ModuleIntegrationSpec" { describe( "instantiation", function() { it( "can be instantiated with an entity", function() { var user = getInstance( "User" ); - var service = getInstance( name = "BaseService@quick", initArguments = { entity : user } ); + var service = getInstance( name = "BaseService@quick", initArguments = { entity : user } ); expect( service.entityName() ).toBe( "User" ); } ); it( "can be instantiated with a wirebox mapping", function() { - var service = getInstance( name = "BaseService@quick", initArguments = { entity : "User" } ); + var service = getInstance( name = "BaseService@quick", initArguments = { entity : "User" } ); expect( service.entityName() ).toBe( "User" ); } ); @@ -62,7 +62,7 @@ component extends="tests.resources.ModuleIntegrationSpec" { var users = variables.service .whereNotNull( "created_date" ) - .get( options = { datasource : "quick" } ); + .get( options = { datasource : "quick" } ); expect( users ).toBeArray(); expect( request.baseServiceSpecPreQBExecute ).toHaveLength( 1 ); diff --git a/tests/specs/integration/CBORMCompatEntitySpec.cfc b/tests/specs/integration/CBORMCompatEntitySpec.cfc index 2587de7f..e5899d86 100644 --- a/tests/specs/integration/CBORMCompatEntitySpec.cfc +++ b/tests/specs/integration/CBORMCompatEntitySpec.cfc @@ -27,7 +27,7 @@ component extends="tests.resources.ModuleIntegrationSpec" { it( "list (with arguments)", function() { var users = user.list( - criteria = { lastName : "Doe" }, + criteria = { lastName : "Doe" }, sortOrder = "username", max = 2, offset = 1, @@ -101,7 +101,7 @@ component extends="tests.resources.ModuleIntegrationSpec" { } ); it( "findWhere", function() { - var john = user.findWhere( { firstName : "John" } ); + var john = user.findWhere( { firstName : "John" } ); expect( john.getId() ).toBe( 2 ); expect( john.getUsername() ).toBe( "johndoe" ); } ); @@ -178,14 +178,14 @@ component extends="tests.resources.ModuleIntegrationSpec" { } ); it( "new (with properties)", function() { - var newUser = user.new( { username : "new_username" } ); + var newUser = user.new( { username : "new_username" } ); expect( newUser.isLoaded() ).toBeFalse(); expect( newUser.getUsername() ).toBe( "new_username" ); } ); it( "populate", function() { var newUser = user.new(); - newUser.populate( { username : "new_username" } ); + newUser.populate( { username : "new_username" } ); expect( newUser.getUsername() ).toBe( "new_username" ); } ); diff --git a/tests/specs/integration/FactorySpec.cfc b/tests/specs/integration/FactorySpec.cfc index cecc4512..2e72d28d 100644 --- a/tests/specs/integration/FactorySpec.cfc +++ b/tests/specs/integration/FactorySpec.cfc @@ -3,9 +3,9 @@ component extends="tests.resources.ModuleIntegrationSpec" { function run() { describe( "Quick model factories", function() { it( "makes unsaved entities from defaults and explicit overrides", function() { - var user = newFactoryManager( { suffix : "make" } ) + var user = newFactoryManager( { suffix : "make" } ) .factory( "User" ) - .make( { firstName : "Overridden" } ); + .make( { firstName : "Overridden" } ); expect( user ).toBeInstanceOf( "User" ); expect( user.isLoaded() ).toBeFalse(); @@ -16,17 +16,17 @@ component extends="tests.resources.ModuleIntegrationSpec" { } ); it( "combines counts, named states, sequences, and persisted Quick entities", function() { - var users = newFactoryManager( { suffix : "sequence" } ) + var users = newFactoryManager( { suffix : "sequence" } ) .factory( "User" ) .count( 3 ) .administrator() .state( function( attributes, context ) { - return { firstName : "State #context.index#" }; + return { firstName : "State #context.index#" }; } ) .sequence( [ - { lastName : "Sequence A" }, + { lastName : "Sequence A" }, function( attributes, context ) { - return { lastName : "Sequence #context.index#" }; + return { lastName : "Sequence #context.index#" }; } ] ) .create(); @@ -55,7 +55,7 @@ component extends="tests.resources.ModuleIntegrationSpec" { var created = []; var user = newFactoryManager() .factory( "User" ) - .state( { username : "factory-callback" } ) + .state( { username : "factory-callback" } ) .afterMaking( function( entity, attributes ) { arrayAppend( made, attributes.username ); } )