Skip to content

Commit

Permalink
Merge branch 'hotfix/5.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
temi committed Nov 12, 2021
2 parents 893c53c + a376a52 commit 5bd20d1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
plugins {
id 'war'
}
version "5.2.3"
version "5.2.4-SNAPSHOT"

group "au.org.ala"

Expand Down
2 changes: 1 addition & 1 deletion grails-app/assets/javascripts/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ var ActivitiesAndRecordsViewModel = function (placeHolder, view, user, ignoreMap
var elem = event.target ? event.target : event.srcElement;
var asyncDownloadThreshold = DEFAULT_EMAIL_DOWNLOAD_THRESHOLD;
if (elem) {
asyncDownloadThreshold = $(elem).attr("dataemailthreshold");
asyncDownloadThreshold = $(elem).data("email-threshold");
}

var url = constructQueryUrl(fcConfig.downloadProjectDataUrl, 0, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DownloadController {
} else {
String fileExtension = params.fileExtension ?: 'zip'
webService.proxyGetRequest(response, "${grailsApplication.config.ecodata.service.url}/search/downloadProjectDataFile/${params.id}?fileExtension=${fileExtension}", true, true)
return null
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package au.org.ala.biocollect

import au.org.ala.biocollect.merit.WebService
import grails.test.mixin.TestFor
import org.apache.http.HttpStatus
import spock.lang.Specification
Expand All @@ -17,6 +18,7 @@ class DownloadControllerSpec extends Specification {
File hubPath
File modelPath
File configPath
WebService webService

void setup() {

Expand All @@ -32,6 +34,7 @@ class DownloadControllerSpec extends Specification {
configPath.mkdir()

controller.grailsApplication.config.app.file.script.path = scriptsPath.getAbsolutePath()
controller.grailsApplication.config.ecodata.service.url = ""

// Setup three files, one that should be accessible, and others that should not
File validFile = new File(modelPath, "validFile.js")
Expand Down Expand Up @@ -145,4 +148,24 @@ class DownloadControllerSpec extends Specification {
new File("${scriptsPath}${File.separator}${params.hub}${File.separator}${params.model}", params.filename).exists()
response.status == HttpStatus.SC_NOT_FOUND
}

def "Data can be downloaded for a created file if id and file extension is provided"(String inputFormat, String expectedOutputFormat) {
setup:
String projectId = 'p1'
controller.webService = webService = Mock(WebService)

when:
params.id = projectId
params.fileExtension = inputFormat
Map result = controller.downloadProjectDataFile()

then:
1 * webService.proxyGetRequest(response, '/search/downloadProjectDataFile/'+projectId+'?fileExtension='+expectedOutputFormat, true, true)
result == null

where:
inputFormat | expectedOutputFormat
'zip' | 'zip'
'' | 'zip'
}
}

0 comments on commit 5bd20d1

Please sign in to comment.