Skip to content

Commit 924b432

Browse files
committed
Add test to verify the content disposition filename is surrounded with quotes
1 parent 33f209a commit 924b432

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

grails-test-suite-web/src/test/groovy/grails/rest/web/RespondMethodSpec.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.grails.plugins.web.mime.MimeTypesFactoryBean
2525
import grails.web.mime.MimeType
2626
import grails.core.support.proxy.ProxyHandler
2727
import org.grails.web.util.GrailsApplicationAttributes
28+
import org.springframework.http.HttpHeaders
2829
import org.springframework.web.servlet.ModelAndView
2930
import spock.lang.Issue
3031
import spock.lang.Specification
@@ -251,6 +252,15 @@ class RespondMethodSpec extends Specification{
251252
response.json.name == 'Jeff'
252253
response.status == 201
253254
}
255+
256+
@Issue(['grails/grails-core#10312'])
257+
void 'Test respond with a file argument'() {
258+
when:
259+
controller.respondWithFile()
260+
261+
then: "the fileName has quotes around it"
262+
response.getHeader(HttpHeaders.CONTENT_DISPOSITION) == 'attachment;filename="good morning.txt"'
263+
}
254264
}
255265

256266
@Artefact("Controller")
@@ -278,6 +288,10 @@ class BookController {
278288
def respondWithMapAndNamedArguments() {
279289
respond([name: 'Jeff'], status: 201)
280290
}
291+
292+
def respondWithFile() {
293+
respond([file: "abc".bytes, fileName: "good morning.txt"])
294+
}
281295
}
282296
@Entity
283297
class Book {

0 commit comments

Comments
 (0)