Skip to content

OBPIH-5813 Items statuses before fulfilment - Approvals statuses#4588

Merged
awalkowiak merged 6 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-5813
Apr 22, 2024
Merged

OBPIH-5813 Items statuses before fulfilment - Approvals statuses#4588
awalkowiak merged 6 commits intofeature/upgrade-to-grails-3.3.10from
OBPIH-5813

Conversation

@alannadolny
Copy link
Collaborator

I decided to avoid modifying the original function for getting statuses because it can introduce regression (as I saw it was in calculating line items in requisition, in this case, we based on our previous "APPROVED" status)

@Unroll
class RequisitionItemSpec extends Specification implements DomainUnitTest<RequisitionItem> {

void 'RequisitionItem.getDisplayStatus() should return: #requisitionItemStatus for requisition status #requisitionStatus'() {
Copy link
Member

@ewaterman ewaterman Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nitpicky but in Spock you want to have your declarations like:

given:
<assign your fields, mocks and stubs here>

when:
<call the method you're trying to test here>

then:
<do your asserts here>

or if you just want to do some simple asserts (like you're doing here) you can do:

given:
<assign your fields, mocks and stubs here>

expect:
<call the method you're trying to test here and do the asserts at the same time>

Also, the general rule for your where: block is:

where:
givenFieldX | givenFieldY || expectedResultZ

so the fields on the left of the || is what you feed into the method in your given: block and the fields on the right is what you verify in the then: or expect: blocks.

Here's an example of everything together:

        given:
        domain.requisition = new Requisition()
        domain.requisition.status = requisitionStatus

        expect:
        domain.displayStatus == requisitionItemStatus

        where:
        requisitionStatus                  || requisitionItemStatus
        RequisitionStatus.PENDING_APPROVAL || RequisitionItemStatus.PENDING
        ...

@ewaterman
Copy link
Member

nice rework! These tests are awesome 👍

}
}

RequisitionItemStatus getDisplayStatus() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alannadolny An afterthought. Is the above getStatus() still used? Seems like this one is adding two additional ifs at the top. Could we remove the other one and leave only this?

Btw GJ with tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Or if we are afraid that we can break something here after the two new ifs we could just call the other method.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awalkowiak awalkowiak merged commit 10f03d6 into feature/upgrade-to-grails-3.3.10 Apr 22, 2024
@awalkowiak awalkowiak deleted the OBPIH-5813 branch April 22, 2024 08:58
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

Successfully merging this pull request may close these issues.

3 participants