OBPIH-5813 Items statuses before fulfilment - Approvals statuses#4588
OBPIH-5813 Items statuses before fulfilment - Approvals statuses#4588awalkowiak merged 6 commits intofeature/upgrade-to-grails-3.3.10from
Conversation
…ending, and cancelled when requisition is rejected)
| @Unroll | ||
| class RequisitionItemSpec extends Specification implements DomainUnitTest<RequisitionItem> { | ||
|
|
||
| void 'RequisitionItem.getDisplayStatus() should return: #requisitionItemStatus for requisition status #requisitionStatus'() { |
There was a problem hiding this comment.
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
...
|
nice rework! These tests are awesome 👍 |
| } | ||
| } | ||
|
|
||
| RequisitionItemStatus getDisplayStatus() { |
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
(Or if we are afraid that we can break something here after the two new ifs we could just call the other method.)
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)