Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
14 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 4 additions & 45 deletions
49
test/integration/org/codehaus/groovy/grails/plugins/qrcode/QrcodeTagLibTests.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,12 @@ | ||
package org.codehaus.groovy.grails.plugins.qrcode | ||
|
||
import grails.test.GrailsUnitTestCase | ||
import org.codehaus.groovy.grails.plugins.testing.GrailsMockHttpServletResponse | ||
import grails.test.GroovyPagesTestCase | ||
|
||
class QrcodeTagLibTests extends GrailsUnitTestCase { | ||
|
||
StringWriter out | ||
def qrCodeService | ||
def controller | ||
def action | ||
def attributes | ||
|
||
protected void setUp() { | ||
super.setUp() | ||
out = new StringWriter() | ||
QrcodeTagLib.metaClass.out = out | ||
QrcodeTagLib.metaClass.createLink = { attrs -> | ||
controller = attrs.controller | ||
action = attrs.action | ||
attributes = attrs.params | ||
} | ||
QrcodeController.metaClass.params = [:] | ||
QrcodeController.metaClass.response = new GrailsMockHttpServletResponse() | ||
} | ||
|
||
protected void tearDown() { | ||
super.tearDown() | ||
def remove = GroovySystem.metaClassRegistry.&removeMetaClass | ||
remove QrcodeTagLib | ||
remove QrcodeController | ||
} | ||
class QrcodeTagLibTests extends GroovyPagesTestCase { | ||
|
||
void testImage() { | ||
QrcodeTagLib qr = new QrcodeTagLib() | ||
|
||
qr.image(height: "100", width: "100", text: "TEST TEXT") | ||
|
||
assertEquals "qrcode", controller | ||
assertEquals "text", action | ||
assertEquals "100", attributes.s | ||
assertEquals "TEST TEXT", attributes.text | ||
|
||
def ctl = new QrcodeController(params: attributes) | ||
ctl.qrCodeService = qrCodeService | ||
ctl.text() | ||
assertEquals "image/png", ctl.response.contentType | ||
assertEquals 200, ctl.response.status | ||
|
||
// reset "out" buffer | ||
out.getBuffer().setLength(0) | ||
def template = '<qrcode:image height="100" width="100" text="TEST TEXT"/>' | ||
assert applyTemplate(template) == '<img class="qrcode " alt="TEST TEXT" src="/qrcode/text?text=TEST+TEXT&s=100"/>' | ||
} | ||
} |
Binary file modified
BIN
+6 Bytes
(100%)
test/integration/org/codehaus/groovy/grails/plugins/qrcode/qrcode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.