Skip to content

Instantly share code, notes, and snippets.

View sergiomichels's full-sized avatar

Sérgio Michels sergiomichels

View GitHub Profile
@sergiomichels
sergiomichels / UrlMappings.groovy
Created September 23, 2013 20:14
Magic to access request inside UrlMappings
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
@sergiomichels
sergiomichels / _Events.groovy
Created September 19, 2013 21:38
_Events with custom test phase
import org.codehaus.groovy.runtime.StackTraceUtils;
//Script para executar os testes unitários de JavaScript
includeTargets << new File("${basedir}/scripts/_RunJavaScriptUnitTests.groovy")
includeTargets << new File("${basedir}/scripts/_RunJavaScriptUiTests.groovy")
/*
* Configuração do Tomcat que é executado internamente, utilizando GZIP para JavaScript.
*/
eventConfigureTomcat = { tomcat ->
@sergiomichels
sergiomichels / stacktrace.groovy
Created September 19, 2013 21:34
Stacktrace of the application in my custom test phase
This file has been truncated, but you can view the full file.
2013-09-19 18:30:36,625 [http-bio-8080-exec-1] ERROR StackTrace - Full Stack Trace:
groovy.lang.MissingPropertyException: No such property: org.codehaus.grails.INCLUDED_JS_LIBRARIES for class: org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:273)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters$_closure1_closure2_closure3.doCall(JavascriptLibraryFilters.groovy:27)
at org.codehaus.gro
@sergiomichels
sergiomichels / _Events.groovy
Created September 17, 2013 19:00
Enable GZIP for embedded Tomcat, compressing html and javascript.
eventConfigureTomcat = { tomcat ->
tomcat.connector.setAttribute("compression", "on")
tomcat.connector.setAttribute("compressableMimeType", "text/html,text/xml,text/plain,application/javascript")
}
@sergiomichels
sergiomichels / MyTreeStoreExample.js
Created September 13, 2013 19:36
Make sure to add NodeInterface fields in your model
/**
Custom model to a TreeStore. It's important to define text and qtip!
*/
Ext.define('MyApp.model.MyTreeModel',{
extend: 'Ext.data.Model',
fields: [{
name: 'text',
type: 'string'
},{
name: 'leaf',
@sergiomichels
sergiomichels / JavascriptServiceSpec.groovy
Last active December 22, 2015 17:49
Accentuation not works
class JavascriptServiceSpec extends IntegrationSpec {
static final Locale PT = new Locale("pt","BR")
static final Locale EN = new Locale("en","US")
def javascriptService
def setup() {
}
@sergiomichels
sergiomichels / RecenteControllerSpec.groovy
Last active December 22, 2015 00:39
I'm not treating Spock nice?
class RecenteControllerSpec extends IntegrationSpec {
def grailsApplication
@Shared
Long formId
def setup() {
formId = null
@sergiomichels
sergiomichels / BuildConfig.groovy
Created August 29, 2013 17:24
My custom plugin BuildConfig
grails.project.work.dir = 'target/work'
grails.project.target.level = 1.6
grails.project.dependency.resolution = {
inherits("global") {
excludes 'svn'
}
legacyResolve false
@sergiomichels
sergiomichels / Demo.groovy
Created August 29, 2013 16:42
Params is playing with me?
class Category {
String name
String description
Category parent
static hasMany = [subcategories : Category]
@sergiomichels
sergiomichels / InspectConstraints.groovy
Created August 21, 2013 14:39
Inspect Grails Domain Class constraints
class Test {
String name
Integer age
BigDecimal salary
static constraints = {
name blank: false, maxSize: 60