Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Domain.build(save:false)" saves immediately #115

Open
koji-k opened this issue Oct 16, 2018 · 0 comments
Open

"Domain.build(save:false)" saves immediately #115

koji-k opened this issue Oct 16, 2018 · 0 comments

Comments

@koji-k
Copy link

koji-k commented Oct 16, 2018

Hi,
I use Grails 3.3.8 and build-test-data:3.3.1

I worte following Integration test code. comments explain this problem.

def sample () {
    setup:

    assert RoomType.count == 0 // it will be "0". no problem.

    RoomType roomType1 = RoomType.build(save: false)

    assert roomType1.id == null // no problem.

    assert RoomType.count == 0 // this test fails... RoomType.count returns "1"
}

so, Grails's test report shows such as following message.

Condition not satisfied:

RoomType.count == 0 // this test fails... RoomType.count returns "1"
         |     |
         1     false

I think that the following actions are originally correct:

  • RomoType.build(save: false) creates a instance of RoomType domain of Grails.
  • But not save into data store(I use H2 for Integration test), because be specified save: false in build method.

However, like a above my sample code, that instance saves immediately.

Is this behavior correct? or i understand it wrong?

@koji-k koji-k changed the title "Domain.build(svae:false)" saves immediately "Domain.build(save:false)" saves immediately Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant