diff --git a/system/Bootstrap.cfc b/system/Bootstrap.cfc index d5d73f415..855b9a713 100644 --- a/system/Bootstrap.cfc +++ b/system/Bootstrap.cfc @@ -33,6 +33,7 @@ component serializable="false" accessors="true" { param name="COLDBOX_APP_KEY" default="cbController"; param name="COLDBOX_APP_MAPPING" default=""; param name="COLDBOX_WEB_MAPPING" default=""; + param name="appHash" default=""; param name="lockTimeout" default="30" type="numeric"; param name="COLDBOX_FAIL_FAST" default="true"; @@ -59,6 +60,7 @@ component serializable="false" accessors="true" { variables.COLDBOX_APP_MAPPING = arguments.COLDBOX_APP_MAPPING variables.COLDBOX_WEB_MAPPING = arguments.COLDBOX_WEB_MAPPING variables.COLDBOX_FAIL_FAST = arguments.COLDBOX_FAIL_FAST + variables.appHash = hash( getBaseTemplatePath() & application.applicationname ) // App Key Check if ( structKeyExists( arguments, "COLDBOX_APP_KEY" ) AND len( trim( arguments.COLDBOX_APP_KEY ) ) ) { @@ -77,9 +79,6 @@ component serializable="false" accessors="true" { var appKey = locateAppKey() var startTime = getTickCount() - // Param the incoming app hash - param name="appHash" default="#hash( getBaseTemplatePath() & application.applicationname )#"; - // Cleanup of old code, just in case if ( structKeyExists( application, appKey ) ) { structDelete( application, appKey ) diff --git a/tests/specs/BootstrapTest.cfc b/tests/specs/BootstrapTest.cfc new file mode 100644 index 000000000..1e117f39f --- /dev/null +++ b/tests/specs/BootstrapTest.cfc @@ -0,0 +1,62 @@ +component extends="coldbox.system.testing.BaseModelTest" { + + function run( testResults, testBox ){ + describe( "Bootstrap", function(){ + beforeEach( function(){ + param name="application.applicationname" default="cbtestharness" + + structDelete( application, "cbController" ) + structDelete( application, "fwReinit" ) + structDelete( request, "cb_requestContext" ) + structDelete( url, "fwreinit" ) + } ) + + afterEach( function(){ + structDelete( application, "cbController" ) + structDelete( application, "fwReinit" ) + structDelete( request, "cb_requestContext" ) + structDelete( url, "fwreinit" ) + } ) + + it( "initializes appHash before loadColdBox runs", function(){ + var bootstrap = createMock( "coldbox.system.Bootstrap" ).init( + "/cbtestharness/config/Coldbox.cfc", + expandPath( "/coldbox/test-harness" ), + "cbController" + ) + + expect( bootstrap.getAppHash() ).toBe( hash( getBaseTemplatePath() & application.applicationname ) ) + } ) + + it( "can enter reloadChecks before loadColdBox initializes the framework", function(){ + var bootstrap = createMock( "coldbox.system.Bootstrap" ).init( + "/cbtestharness/config/Coldbox.cfc", + expandPath( "/coldbox/test-harness" ), + "cbController" + ) + var mockController = createEmptyMock( "coldbox.system.web.Controller" ) + + mockController + .$( "getColdboxInitiated" ) + .$results( false, true ) + .$( "getSetting" ) + .$args( "Wirebox" ) + .$results( { singletonReload : false } ) + .$( "getSetting" ) + .$args( "HandlersIndexAutoReload" ) + .$results( false ) + + application.cbController = mockController + + bootstrap + .$( "locateAppKey", "cbController" ) + .$( "isfwReinit", false ) + + bootstrap.reloadChecks() + + expect( bootstrap.getAppHash() ).notToBeEmpty() + } ) + } ) + } + +}