Skip to content

Commit

Permalink
Apply cfformat changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jclausen authored and github-actions[bot] committed Jul 25, 2022
1 parent 8337597 commit d306349
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 95 deletions.
6 changes: 1 addition & 5 deletions modules/contentbox/models/comments/CommentService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,7 @@ component extends="cborm.models.VirtualEntityService" singleton {
}

// Check if user has already an approved comment. If they do, then approve them
if (
inSettings.cb_comments_moderation_whitelist AND userHasPreviousAcceptedComment(
inComment.getAuthorEmail()
)
) {
if ( inSettings.cb_comments_moderation_whitelist AND userHasPreviousAcceptedComment( inComment.getAuthorEmail() ) ) {
inComment.setIsApproved( true );
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/contentbox/seeders/BaseSeeder.cfc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
abstract component {
abstract component {

// DI
property name="packageService" inject="PackageService";
Expand Down
63 changes: 25 additions & 38 deletions modules_app/contentbox-custom/ModuleConfig.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,80 +6,67 @@
* This Module loads all of a user's custom assets:
* - content - media manager assets
* - themes - custom themes
* - modules - custom modules
* - modules - custom modules
*/
component {

// Module Properties
this.title = "ContentBox Custom Module";
this.author = "Ortus Solutions, Corp";
this.webURL = "https://www.ortussolutions.com";
this.description = "This module is where all custom user assets can be placed and version controlled";
this.viewParentLookup = true;
this.title = "ContentBox Custom Module";
this.author = "Ortus Solutions, Corp";
this.webURL = "https://www.ortussolutions.com";
this.description = "This module is where all custom user assets can be placed and version controlled";
this.viewParentLookup = true;
this.layoutParentLookup = true;
// URL Entry Point
this.entryPoint = "cbCustom";
this.entryPoint = "cbCustom";
// Model Namespace
this.modelNamespace = "contentbox-custom";
this.modelNamespace = "contentbox-custom";
// CF Mapping
this.cfmapping = "contentbox-custom";
this.cfmapping = "contentbox-custom";
// ContentBox must be loaded first
this.dependencies = [ "contentbox" ];
this.dependencies = [ "contentbox" ];

/**
* Configure Module
*/
* Configure Module
*/
function configure(){

// contentbox settings
settings = {

};
settings = {};

// CB Module Conventions
conventions = {
layoutsLocation = "_themes",
viewsLocation = "_themes"
};
conventions = { layoutsLocation : "_themes", viewsLocation : "_themes" };

// Parent Affected Settings
parentSettings = {

};
parentSettings = {};

// interceptor settings
interceptorSettings = {
// ContentBox Custom Events
customInterceptionPoints = []
customInterceptionPoints : []
};

// interceptors
interceptors = [

];

interceptors = [];
}

/**
* Development tier
*/
* Development tier
*/
function development(){
}

/**
* Fired when the module is registered and activated.
*/
* Fired when the module is registered and activated.
*/
function onLoad(){

}

/**
* Fired when the module is unregistered and unloaded
*/
* Fired when the module is unregistered and unloaded
*/
function onUnload(){
}

/************************************** PRIVATE *********************************************/


}
6 changes: 4 additions & 2 deletions modules_app/contentbox-custom/_content/Application.cfc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
component{
component {

abort;
}

}
19 changes: 10 additions & 9 deletions modules_app/contentbox-custom/_widgets/Hola.cfc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* A widget that shows you a 'hello world'
*/
component extends="contentbox.models.ui.BaseWidget" singleton{
* A widget that shows you a 'hello world'
*/
component extends="contentbox.models.ui.BaseWidget" singleton {

function init(){
// Widget Properties
Expand All @@ -10,23 +10,24 @@ component extends="contentbox.models.ui.BaseWidget" singleton{
setDescription( "A hello world widget" );
setAuthor( "Ortus Solutions" );
setAuthorURL( "https://www.ortussolutions.com" );
setIcon( "info" );
setIcon( "info" );

return this;
}

/**
* Give you a nice welcome in Spanish
*
* @titleLevel The H{level} to use, by default we use H2
*/
any function renderIt( string titleLevel="2" ){
var rString = "";
any function renderIt( string titleLevel = "2" ){
var rString = "";

saveContent variable="rString"{
saveContent variable="rString" {
writeOutput( "<h#arguments.titleLevel#>Hola mi amigo!</h#arguments.titleLevel#>" );
}

return rString;
}

}
}
44 changes: 25 additions & 19 deletions tests/resources/BaseApiTest.cfc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
component extends="tests.resources.BaseTest" appMapping="/root" autowire=true{
component
extends ="tests.resources.BaseTest"
appMapping="/root"
autowire =true
{

// DI
property name="securityService" inject="securityService@contentbox";
property name="cbsecure" inject="CBSecurity@cbsecurity";
property name="jwt" inject="JWTService@cbsecurity";
property name="cbsecure" inject="CBSecurity@cbsecurity";
property name="jwt" inject="JWTService@cbsecurity";

/**
* --------------------------------------------------------------------------
Expand All @@ -13,9 +17,9 @@ component extends="tests.resources.BaseTest" appMapping="/root" autowire=true{
*/
variables.bCryptHashOfPasswordTest = "$2a$12$FE2J7ZLWaI2rSqejAu/84uLy7qlSufQsDsSE1lNNKyA05GG30gr8C";
variables.testPassword = "test";
variables.testAdminUsername = "lmajano";
variables.testAdminPassword = "lmajano";
variables.testAdminEmail = "[email protected]";
variables.testAdminUsername = "lmajano";
variables.testAdminPassword = "lmajano";
variables.testAdminEmail = "[email protected]";

function beforeAll(){
super.beforeAll();
Expand All @@ -30,7 +34,7 @@ component extends="tests.resources.BaseTest" appMapping="/root" autowire=true{

// Add Custom Matchers: REMOVE once we fix the issue in the ColdBox matchers.
addMatchers( {
toHaveStatus : function( expectation, args = {} ) {
toHaveStatus : function( expectation, args = {} ){
// handle both positional and named arguments
param args.statusCode = "";
if ( structKeyExists( args, 1 ) ) {
Expand All @@ -53,7 +57,7 @@ component extends="tests.resources.BaseTest" appMapping="/root" autowire=true{
return true;
},
// Verifies invalid cbValidation data
toHaveInvalidData : function( expectation, args = {} ) {
toHaveInvalidData : function( expectation, args = {} ){
param args.field = "";
if ( structKeyExists( args, 1 ) ) {
args.field = args[ 1 ];
Expand Down Expand Up @@ -84,10 +88,9 @@ component extends="tests.resources.BaseTest" appMapping="/root" autowire=true{
}
// We have a field to check and it has data
if (
!structKeyExists(
expectation.actual.getData(),
!structKeyExists( expectation.actual.getData(), args.field ) || expectation.actual.getData()[
args.field
) || expectation.actual.getData()[ args.field ].isEmpty()
].isEmpty()
) {
expectation.message = "#args.message#. The requested field [#args.field#] does not have any invalid data.";
debug( expectation.actual.getMemento() );
Expand All @@ -98,7 +101,9 @@ component extends="tests.resources.BaseTest" appMapping="/root" autowire=true{
try {
expect(
expectation.actual.getData()[ args.field ]
.map( function( item ) { return item.message; } )
.map( function( item ){
return item.message;
} )
.toList()
).toInclude( args.error );
} catch ( any e ) {
Expand All @@ -123,10 +128,7 @@ component extends="tests.resources.BaseTest" appMapping="/root" autowire=true{
super.setup();

if ( !isNull( request.testUserData ) ) {
getRequestContext().setValue(
"x-auth-token",
request.testUserData.token
);
getRequestContext().setValue( "x-auth-token", request.testUserData.token );
}

return;
Expand All @@ -140,13 +142,17 @@ component extends="tests.resources.BaseTest" appMapping="/root" autowire=true{
* @return struct of { user:logged in user, token: their token}
*/
struct function loginUser( username = variables.testAdminUsername ){
var oUser = variables.securityService.authenticate( username : arguments.username, password : variables.testAdminPassword, logThemIn : true);
var oUser = variables.securityService.authenticate(
username : arguments.username,
password : variables.testAdminPassword,
logThemIn: true
);
var tokens = variables.jwt.fromUser( oUser );

// Setup request data
request.testUserData = {
"token" : tokens.access_token,
"user" : oUser,
"token" : tokens.access_token,
"user" : oUser,
"refresh_token" : tokens.refresh_token
};

Expand Down
2 changes: 1 addition & 1 deletion tests/resources/BaseTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This is the Base Integration Test CFC
* Place any helpers or traits for all integration tests here.
*/
component extends="coldbox.system.testing.BaseTestCase" appMapping="/root"{
component extends="coldbox.system.testing.BaseTestCase" appMapping="/root" {

// Load on first test
this.loadColdBox = true;
Expand Down
35 changes: 17 additions & 18 deletions tests/resources/SeedData.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ component extends="tests.resources.BaseTest" {
function beforeAll(){
super.beforeAll();
authorService = getInstance( "AuthorService@contentbox" );
siteService = getInstance( "siteService@contentbox" );
currentSite = siteService.getDefaultSite();
siteService = getInstance( "siteService@contentbox" );
currentSite = siteService.getDefaultSite();
currentAuthor = authorService.retrieveUserByUsername( "lmajano" );
pageService = getInstance( "pageService@contentbox" );
entryService = getInstance( "entryService@contentbox" );
pageService = getInstance( "pageService@contentbox" );
entryService = getInstance( "entryService@contentbox" );

contentToLoad = 100;
}
Expand All @@ -29,10 +29,10 @@ component extends="tests.resources.BaseTest" {
} );

it( "can load all pages", function(){
for( x=1; x lte contentToLoad; x++ ){
for ( x = 1; x lte contentToLoad; x++ ) {
var testId = createUUID();
// create a page
var page = pageService.new(
var page = pageService.new(
properties = {
title : "This is a random #testId# page",
slug : "randompage-#testId#",
Expand All @@ -46,40 +46,39 @@ component extends="tests.resources.BaseTest" {
page.setCreator( currentAuthor );
page.setSite( currentSite );
page.addNewContentVersion(
content = "<p>#mockData( content = "lorem", $num=1 )[ 1 ].content#</p>",
content = "<p>#mockData( content = "lorem", $num = 1 )[ 1 ].content#</p>",
changelog = "First creation",
author = currentAuthor
);
pageService.save( page );
debug( "Added #page.getTitle()#" );
}
});
} );

fit( "can load all entries", function(){
for( x=1; x lte contentToLoad; x++ ){
for ( x = 1; x lte contentToLoad; x++ ) {
var testId = createUUID();
// create a page
var entry = entryService.new(
var entry = entryService.new(
properties = {
title : "This is a random #testId# entry",
slug : "randompage-#testId#",
publishedDate : now(),
isPublished : true,
allowComments : false
title : "This is a random #testId# entry",
slug : "randompage-#testId#",
publishedDate : now(),
isPublished : true,
allowComments : false
}
);
entry.setCreator( currentAuthor );
entry.setSite( currentSite );
entry.addNewContentVersion(
content = "<p>#mockData( content = "lorem", $num=1 )[ 1 ].content#</p>",
content = "<p>#mockData( content = "lorem", $num = 1 )[ 1 ].content#</p>",
changelog = "First creation",
author = currentAuthor
);
entryService.save( entry );
debug( "Added #entry.getTitle()#" );
}
});

} );
} );
}

Expand Down
2 changes: 1 addition & 1 deletion tests/specs/contentbox-api/AuthorsSpec.cfc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="tests.resources.BaseApiTest"{
component extends="tests.resources.BaseApiTest" {

property name="siteService" inject="siteService@contentbox";
property name="authorService" inject="authorService@contentbox";
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/contentbox-api/CategoriesSpec.cfc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
component extends="tests.resources.BaseApiTest"{
component extends="tests.resources.BaseApiTest" {

property name="siteService" inject="siteService@contentbox";
property name="categoryService" inject="categoryService@contentbox";
Expand Down

0 comments on commit d306349

Please sign in to comment.