Skip to content
Closed
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
5 changes: 2 additions & 3 deletions system/Bootstrap.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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 ) ) ) {
Expand All @@ -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 )
Expand Down
62 changes: 62 additions & 0 deletions tests/specs/BootstrapTest.cfc
Original file line number Diff line number Diff line change
@@ -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()
} )
} )
}

}
Loading