diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f90d660f7b..0b12984295 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,11 +1,6 @@ name: Pull Requests on: - push: - branches-ignore: - - "main" - - "master" - - "development" pull_request: branches: - development diff --git a/box.json b/box.json index dee6c32b2a..3f7d8d960f 100644 --- a/box.json +++ b/box.json @@ -1,6 +1,6 @@ { "name":"ContentBox Tester Site", - "version":"5.1.1", + "version":"5.2.0", "author":"Ortus Solutions ", "shortDescription":"A tester site for developing the ContentBox Modular CMS", "type":"cms", diff --git a/build/patches/5.0.0/Updater.cfc b/build/patches/5.0.0/Updater.cfc index 62682dcfba..2ac7e95661 100644 --- a/build/patches/5.0.0/Updater.cfc +++ b/build/patches/5.0.0/Updater.cfc @@ -1,5 +1,5 @@ /** - * Update a v4 Installation to v5.0.0 + * Update a v4 Installation to v5 */ component { @@ -8,7 +8,7 @@ component { variables.cwd = getCWD(); variables.tempFolder = variables.cwd & "__temp"; - variables.targetVersion = "5.0.0"; + variables.targetVersion = "5"; if( directoryExists( variables.tempFolder ) ){ directoryDelete( variables.tempFolder, true ); @@ -54,26 +54,13 @@ component { return; } - // install contentbox-site so we can copy over new assets and run our migrations + // Install ContentBox print.blueLine( "Downloading ContentBox v#variables.targetVersion# assets to __temp folder..." ).toConsole(); command( "install contentbox-site@#variables.targetVersion#" ) .inWorkingDirectory( variables.tempFolder ) .run(); print.greenLine( "√ ContentBox assets downloaded!" ).toConsole(); - // Copy over migration resources - print.blueLine( "Installing new ContentBox resources folder..." ).toConsole(); - if( !directoryExists( variables.cwd & "resources" ) ){ - directoryCreate( variables.cwd & "resources" ); - }; - copy( variables.tempFolder & "/resources", variables.cwd & "resources" ); - print.greenLine( "√ ContentBox resources installed!" ).toConsole(); - - // Run Migrations - print.blueLine( "Migrating your database to version: #variables.targetVersion#..." ).toConsole(); - command( "run-script contentbox:migrate:up" ).run(); - print.greenLine( "√ Database migrated! Let's do some code now." ).toConsole(); - // Update ColdBox print.blueLine( "Uninstalling current version of ColdBox..." ).toConsole(); command( "uninstall coldbox" ).run(); @@ -84,7 +71,7 @@ component { // Update ContentBox print.blueLine( "Uninstalling current version of the ContentBox module..." ).toConsole(); command( "uninstall contentbox" ).run(); - print.blueLine( "Installing ContentBox v5.0.0" ).toConsole(); + print.blueLine( "Installing ContentBox v#variables.targetVersion#" ).toConsole(); command( "install contentbox@#variables.targetVersion# --save" ).run(); print.greenLine( "√ ContentBox v5 Installed!" ).toConsole(); @@ -97,19 +84,24 @@ component { print.greenLine( "√ New ContentBox bin folder installed!" ).toConsole(); // Copy over new files - replaceNewFiles(); + replaceNewSiteFiles(); // Remove temp folder directoryDelete( variables.tempFolder, true ); + // Run Migrations + print.blueLine( "Migrating your database to version: #variables.targetVersion#..." ).toConsole(); + command( "run-script contentbox:migrate:up" ).run(); + print.greenLine( "√ Database migrated! Let's do some code now." ).toConsole(); + // Final Comment print.boldRedLine( - "√ Eureka! You are now ready to startup your engines and run ContentBox v5.0.0!" + "√ Eureka! You are now ready to startup your engines and run ContentBox v#variables.targetVersion#!" ) .toConsole(); } - function replaceNewFiles(){ + function replaceNewSiteFiles(){ print.blueLine( "Starting to deploy new files..." ).line().toConsole(); var files = [ diff --git a/changelog.md b/changelog.md index 4f09db29ab..cc07941926 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ---- +## [5.1.2] => 2022-MAR-31 + +### Fixed + +- [CONTENTBOX-1415](https://ortussolutions.atlassian.net/browse/CONTENTBOX-1415) 5.x Updater was not running the right migrations +- [CONTENTBOX-1414](https://ortussolutions.atlassian.net/browse/CONTENTBOX-1414) Migration names cannot have a period or the migrations fail due to a CFC instantiation issue +- [CONTENTBOX-1413](https://ortussolutions.atlassian.net/browse/CONTENTBOX-1413) CBHelper siteBaseURL is not accounting for multi-site + +---- + ## [5.1.1] => 2022-MAR-17 ### Fixed @@ -18,7 +28,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [CONTENTBOX-1412](https://ortussolutions.atlassian.net/browse/CONTENTBOX-1412) VerifyPageLayout\(\) on the page rendering touches the filesystem on each request, removing this as it is not needed - [CONTENTBOX-1368](https://ortussolutions.atlassian.net/browse/CONTENTBOX-1368) rc.pageUri is only the first segment of the actual slug, now it contains the full hierarchical slug - ---- ## [5.1.0] => 2022-MAR-17 diff --git a/config/Coldbox.cfc b/config/Coldbox.cfc index f4ee413965..b6c95c7826 100755 --- a/config/Coldbox.cfc +++ b/config/Coldbox.cfc @@ -443,6 +443,13 @@ component { }; } + /** + * Testing Mode. + */ + function testing(){ + development(); + } + /** * Development environment * ORTUS DEVELOPMENT ENVIRONMENT, REMOVE FOR YOUR APP IF NEEDED diff --git a/modules/contentbox/migrations/2022_03_07_155812_v5.1.0_page_sslonly_removals.cfc b/modules/contentbox/migrations/2022_03_07_155812_v5_1_0_page_sslonly_removals.cfc similarity index 100% rename from modules/contentbox/migrations/2022_03_07_155812_v5.1.0_page_sslonly_removals.cfc rename to modules/contentbox/migrations/2022_03_07_155812_v5_1_0_page_sslonly_removals.cfc diff --git a/modules/contentbox/models/system/CBHelper.cfc b/modules/contentbox/models/system/CBHelper.cfc index 2a88a78309..9229cfd48d 100644 --- a/modules/contentbox/models/system/CBHelper.cfc +++ b/modules/contentbox/models/system/CBHelper.cfc @@ -101,6 +101,12 @@ component accessors="true" singleton threadSafe { */ any function setting( required key, defaultValue ){ var prc = getPrivateRequestCollection(); + + // See if all the settings are loaded, else lazy load them + if( isNull( prc.cbSettings ) || structIsEmpty( prc.cbSettings ) ){ + prc.cbSettings = variables.settingService.getAllSettings(); + } + // return setting if it exists if ( structKeyExists( prc.cbSettings, arguments.key ) ) { return prc.cbSettings[ key ]; @@ -128,6 +134,11 @@ component accessors="true" singleton threadSafe { any function siteSetting( required key, defaultValue ){ var prc = getPrivateRequestCollection(); + // See if all the settings are loaded, else lazy load them + if( isNull( prc.cbSiteSettings ) || structIsEmpty( prc.cbSiteSettings ) ){ + prc.cbSiteSettings = variables.settingService.getAllSiteSettings( prc.oCurrentSite.getSlug() ); + } + // return setting if it exists if ( structKeyExists( prc.cbSiteSettings, arguments.key ) ) { return prc.cbSiteSettings[ key ]; @@ -298,14 +309,20 @@ component accessors="true" singleton threadSafe { */ function siteRoot( string siteID = "" ){ // Return the appropriate site Uri - return this.site( arguments.siteID ).getSiteRoot() & getPrivateRequestCollection().cbEntryPoint; + return this.site( arguments.siteID ).getSiteRoot() & getModuleConfig( "contentbox-ui" ).entryPoint; } /** - * Get the site base html ref URL + * Get the HTML base URL that is used for the HTML tag. This also accounts for SSL or not. + * + * @siteID The site id to get the root from, by default we use the current site you are on */ - function siteBaseURL(){ - return getRequestContext().getHTMLBaseUrl(); + function siteBaseURL( string siteID = "" ){ + return reReplaceNoCase( + this.siteRoot( arguments.siteID ), + "index.cfm\/?", + "" + ); } /** diff --git a/tests/Application.cfc b/tests/Application.cfc index 126c8c9fee..13f77a75a1 100755 --- a/tests/Application.cfc +++ b/tests/Application.cfc @@ -24,6 +24,11 @@ component{ // Turn on/off remote cfc content whitespace this.suppressRemoteComponentContent = false; + /************************************** + TESTING ENV + **************************************/ + createObject( "java", "java.lang.System" ).setProperty( "ENVIRONMENT", "testing" ); + // FILL OUT: THE LOCATION OF THE CONTENTBOX MODULE rootPath = replacenocase( replacenocase( getDirectoryFromPath( getCurrentTemplatePath() ), "tests\", "" ), "tests/", "" ); @@ -89,4 +94,4 @@ component{ } -} \ No newline at end of file +} diff --git a/tests/specs/contentbox-web/contentbox/unit/system/CBHelperTest.cfc b/tests/specs/contentbox-web/contentbox/unit/system/CBHelperTest.cfc new file mode 100644 index 0000000000..45c91ce153 --- /dev/null +++ b/tests/specs/contentbox-web/contentbox/unit/system/CBHelperTest.cfc @@ -0,0 +1,61 @@ +/** + * ContentBox - A Modular Content Platform + * Copyright since 2012 by Ortus Solutions, Corp + * www.ortussolutions.com/products/contentbox + * --- + */ +component extends="tests.resources.BaseTest" { + + /*********************************** BDD SUITES ***********************************/ + + function run( testResults, testBox ){ + describe( "CB Helper", function(){ + beforeEach( function( currentSpec ){ + setup(); + cbHelper = getInstance( "CBHelper@contentbox" ); + } ); + + it( "can be created", function(){ + expect( cbHelper ).toBeComponent(); + } ); + + describe( "Site related methods", function(){ + it( "can build the site root", function(){ + expect( cbHelper.siteRoot() ).toInclude( "http://127.0.0.1" ); + }); + + it( "can build the site base url", function(){ + expect( cbHelper.siteBaseUrl() ) + .toInclude( "http://127.0.0.1" ) + .notToInclude( "index.cfm" ); + }); + + it( "can build the site name", function(){ + expect( cbHelper.siteName() ).toInclude( "Default Site" ); + }); + + it( "can build the site tag line", function(){ + expect( cbHelper.siteTagLine() ).notToBeEmpty(); + }); + + it( "can build the site description", function(){ + expect( cbHelper.siteDescription() ).notToBeEmpty(); + }); + + it( "can build the site keywords", function(){ + cbHelper.siteKeywords(); + }); + + it( "can build the site email", function(){ + expect( cbHelper.siteEmail() ).notToBeEmpty(); + }); + + it( "can build the site outgoing email", function(){ + expect( cbHelper.siteOutgoingEmail() ).notToBeEmpty(); + }); + }); + + } ); + } + +}