abcfy2 opened a new issue, #14561:
URL: https://github.com/apache/grails-core/issues/14561
### Task List
- [x] Steps to reproduce provided
- [x] Stacktrace (if present) provided
- [x] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)
### Steps to Reproduce
Here is my Domain class: `grails-app/domain/mygrailsproj/MyDomain.groovy`
```groovy
package mygrailsproj
class MyDomain {
String field
def beforeUpdate() {
return false
}
}
```
Here is my unit test: `src/test/groovy/mygrailsproj/MyDomainSpec.groovy`:
```groovy
package mygrailsproj
import grails.testing.gorm.DomainUnitTest
import spock.lang.Specification
class MyDomainSpec extends Specification implements DomainUnitTest<MyDomain>
{
void "did not expect domain could be modified"() {
setup:
MyDomain myDomain = new MyDomain(field: 'old').save(flush: true)
when:
myDomain.field = 'new'
myDomain.save(flush: true)
myDomain.refresh()
then:
myDomain.field == 'old'
}
}
```
### Expected Behaviour
Domain will not be modified if `beforeUpdate()` returns false.
### Actual Behaviour
Test failed:
```
did not expect domain could be modified
Condition not satisfied:
myDomain.field == 'old'
| | |
| new false
| 3 differences (0% similarity)
| (new)
| (old)
mygrailsproj.MyDomain : 1
at mygrailsproj.MyDomainSpec.did not expect domain could be
modified(MyDomainSpec.groovy:17)
```
### Environment Information
- **Operating System**: Linxmint 19
- **GORM Version:** 6.1.10.RELEASE
- **Grails Version (if using Grails):** 3.3.6
- **JDK Version:** 1.8.0_172
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]