Skip to content

Commit

Permalink
Add test to reproduce Issue #13945
Browse files Browse the repository at this point in the history
  • Loading branch information
jdaugherty committed Dec 30, 2024
1 parent 874f552 commit 268e386
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import grails.testing.gorm.DataTest
import grails.testing.web.controllers.ControllerUnitTest
import grails.validation.Validateable
import spock.lang.Issue
import spock.lang.PendingFeature
import spock.lang.Specification

class CommandObjectsSpec extends Specification implements ControllerUnitTest<TestController>, DataTest {
Expand Down Expand Up @@ -304,6 +305,37 @@ class CommandObjectsSpec extends Specification implements ControllerUnitTest<Tes
commandObject.firstName == 'Douglas'
commandObject.lastName == 'Mendes'
}

@Issue('https://github.com/grails/grails-core/issues/13945')
void "calling actions involving inherited command objects - child command"() {
given:
params.testId = 1
params.myId = 3
params.pId = 2

when:
def model = controller.zMethodTakingChild()
def commandObject = model.commandObject

then:
commandObject.testId == 1
commandObject.myId == 3
model.pId == 2
}

@PendingFeature()
@Issue('https://github.com/grails/grails-core/issues/13945')
void "calling actions involving inherited command objects - parent command"() {
given:
params.testId = 1

when:
def model = controller.methodTakingParent()
def commandObject = model.commandObject

then:
commandObject.testId == 1
}
}

@Artefact('Controller')
Expand Down Expand Up @@ -362,6 +394,23 @@ class TestController {
def methodActionWithGenericBasedCommand(ConcreteGenericBased co) {
[commandObject: co]
}

def zMethodTakingChild(ChildCommand command, long pId) {
[commandObject: command, pId: pId]
}

def methodTakingParent(ParentCommand command) {
[commandObject: command, pId: 2]
}
}


class ParentCommand {
int testId
}

class ChildCommand extends ParentCommand {
int myId
}

class DateComamndObject {
Expand Down

0 comments on commit 268e386

Please sign in to comment.