forked from pedjak/grails-csv
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CsvTestControllerSpec and also moved resources file to src/main…
… resources folder and fixed test files path.
- Loading branch information
sachin-verma
committed
Jul 9, 2015
1 parent
c240dbc
commit fa6608d
Showing
6 changed files
with
55 additions
and
20 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
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
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
47 changes: 47 additions & 0 deletions
47
src/integration-test/groovy/org/grails/plugins/csv/CsvTestControllerSpec.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.grails.plugins.csv | ||
|
||
import grails.test.mixin.TestFor | ||
import spock.lang.Specification | ||
|
||
|
||
@TestFor(CsvTestController) | ||
class CsvTestControllerSpec extends Specification { | ||
|
||
def populateValidParams(params) { | ||
assert params != null | ||
} | ||
|
||
void "test render as csv"() { | ||
|
||
when: "The writeCsv action is executed without ant params" | ||
controller.writeCsv() | ||
|
||
then: "The response is correct" | ||
response.contentType == 'text/csv' | ||
response.contentAsString == '"x","y"\n"1","2"\n"3","4"\n"5","6"' | ||
!response.getHeader('Content-Disposition') | ||
} | ||
|
||
|
||
void "test render as csv as attachments"() { | ||
|
||
when: "The writeCsv action is executed with params containing filename" | ||
params.filename = 'my.csv' | ||
controller.writeCsv() | ||
|
||
then: "The response is correct" | ||
response.getHeader('Content-Disposition') == 'attachment; filename="my.csv";' | ||
} | ||
|
||
void "test render as csv as inline"() { | ||
|
||
when: "The writeCsv action is executed with params containing filename and attachment as false" | ||
params.filename = 'my.csv' | ||
params.attachment = false | ||
controller.writeCsv() | ||
|
||
then: "The response is correct" | ||
response.getHeader('Content-Disposition') == 'inline; filename="my.csv";' | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.