diff --git a/src/groovy/com/megatome/grails/recaptcha/ReCaptcha.groovy b/src/groovy/com/megatome/grails/recaptcha/ReCaptcha.groovy index c1a03c0..59b3a89 100644 --- a/src/groovy/com/megatome/grails/recaptcha/ReCaptcha.groovy +++ b/src/groovy/com/megatome/grails/recaptcha/ReCaptcha.groovy @@ -45,7 +45,7 @@ public class ReCaptcha { */ public String createRecaptchaHtml(Map options) { def includeScriptForInstance = includeScript - if (options.containsKey('includeScript')) { + if (options?.containsKey('includeScript')) { includeScriptForInstance = Boolean.valueOf(options.includeScript) } @@ -105,7 +105,7 @@ public class ReCaptcha { * @param options Options for creating the tag. Only lang is supported. * @return */ - public String createScriptTag(Map options) { + public static String createScriptTag(Map options) { def qs = new QueryString() if (options?.lang) { qs.add("hl", URLEncoder.encode(options.remove("lang"))) @@ -154,6 +154,6 @@ public class ReCaptcha { if (!responseObject) { return false } - responseObject.success?.trim()?.toBoolean() == true + return responseObject.success } } \ No newline at end of file diff --git a/test/unit/com/megatome/grails/recaptcha/ReCaptchaTests.groovy b/test/unit/com/megatome/grails/recaptcha/ReCaptchaTests.groovy index 8f476ac..72a8a32 100644 --- a/test/unit/com/megatome/grails/recaptcha/ReCaptchaTests.groovy +++ b/test/unit/com/megatome/grails/recaptcha/ReCaptchaTests.groovy @@ -36,7 +36,6 @@ public class ReCaptchaTests extends GroovyTestCase { assertTrue r.createRecaptchaHtml(null).contains("") def options = new Properties() @@ -45,54 +44,46 @@ public class ReCaptchaTests extends GroovyTestCase { assertTrue html.contains("data-theme=\"mytheme\"") } - - public void testCreateCaptchaHtmlWithLangInURL() { - def recap = new ReCaptcha(privateKey: "testing", publicKey: "testing", includeNoScript: false, includeScript: true) - + public void testCreateCaptchaHtmlWithLangInOptions() { def options = [:] options.lang = "fr" - def html = recap.createRecaptchaHtml(options) + def html = r.createRecaptchaHtml(options) assertTrue html.contains("