Skip to content

Instantly share code, notes, and snippets.

View neokoenig's full-sized avatar

Tom King neokoenig

View GitHub Profile
<cfscript>
mapper()
.namespace("admin")
.resources("users")
.end()
.wildcard()
.root(to="wheels##wheels", method="get")
.end()
</cfscript>
component extends="Admin" {
function config() {
super.config();
verifies(except="index,new,create", params="key", paramsTypes="integer", handler="objectNotFound");
verifies(post=true, only="create,update,delete");
}
function index() {
users=model("user").findAll();
component extends="app.controllers.Controller"
{
function config() {
filters(through="checkAdminPermissions");
}
// This is highly simplified for illustration only
private function checkAdminPermissions(){
if(session.user.role != "admin"){
abort;
// asserts that a failed user update returns a 302 http response, an error exists in the flash and will be redirected to the error page
function testStatusFlashAndRedirect() {
local.params = {
controller = "users",
action = "update"
};
result = processRequest(params=local.params, method="post", rollback=true, returnAs="struct");
assert("result.status == 302");
assert("StructKeyExists(result.flash, 'error') == true");
assert("result.redirect == '/common/error'");
function test_addme() {
  actual = addMe(1, 2);
  expected = 3;
  assert("actual eq expected");
}
@neokoenig
neokoenig / .travis.yml
Created May 15, 2017 11:29
Travis Commandbox Plugin Test
language: java
sudo: required
jdk:
- oraclejdk8
before_install:
# Get Commandbox
- sudo apt-key adv --keyserver keys.gnupg.net --recv 6DA70622
- sudo echo "deb http://downloads.ortussolutions.com/debs/noarch /" | sudo tee -a /etc/apt/sources.list.d/commandbox.list
install:
# Install Commandbox
/**
* Add your description here
*
* [section: Plugins]
* [category: Your Plugin Name]
*
* @myParam A description of this parameter
*/
public array function awesomeFunction(required string myParam){
local.rv=[];
/**
* Removes all HTML tags from a string.
*
* [section: View Helpers]
* [category: Sanitization Functions]
*
* @html The HTML to remove tag markup from.
*/
public string function stripTags(required string html) {
local.rv = REReplaceNoCase(arguments.html, "<\ *[a-z].*?>", "", "all");
$ box install cfwheels-cli
Installing package [forgebox:cfwheels-cli]
Verifying package 'cfwheels-cli' in ForgeBox, please wait...
Installing version [0.1.6].
Verified entry in ForgeBox: 'cfwheels-cli'
Deferring to [github] endpoint for ForgeBox entry [cfwheels-cli]...
Using branch [v0.1.6]
Cloning Git URL [https://github.com/neokoenig/cfwheels-cli.git]
remote: Counting objects: 632
remote: Compressing objects: 100% (39/39)
// In controller.cfc
function getStuff(){
myStuff=model("foo").findAll(order="name");
}
// Mycontroller.cfc
init(){
filters(through="getStuff", only="index");
}