Bug 21909 - Koha::Account::outstanding_* methods should preserve call context
Summary: Koha::Account::outstanding_* methods should preserve call context
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Josef Moravec
URL:
Keywords:
Depends on: 20946 20990
Blocks:
  Show dependency treegraph
 
Reported: 2018-11-29 12:51 UTC by Tomás Cohen Arazi
Modified: 2020-01-06 20:15 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 21909: Unit tests (3.96 KB, patch)
2018-11-29 15:16 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 21909: Make Koha::Account::outstanding_* preserve context (1.50 KB, patch)
2018-11-29 15:16 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 21909: Add return type explanation to POD (1.14 KB, patch)
2018-11-29 15:16 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 21909: Unit tests (4.02 KB, patch)
2018-11-29 15:37 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 21909: Make Koha::Account::outstanding_* preserve context (1.56 KB, patch)
2018-11-29 15:37 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 21909: Add return type explanation to POD (1.21 KB, patch)
2018-11-29 15:37 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 21909: Unit tests (4.08 KB, patch)
2018-11-30 16:52 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 21909: Make Koha::Account::outstanding_* preserve context (1.62 KB, patch)
2018-11-30 16:52 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 21909: Add return type explanation to POD (1.26 KB, patch)
2018-11-30 16:52 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 21909: Unit tests (4.12 KB, patch)
2018-12-26 17:51 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 21909: Make Koha::Account::outstanding_* preserve context (1.71 KB, patch)
2018-12-26 17:51 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 21909: Add return type explanation to POD (1.26 KB, patch)
2018-12-26 17:51 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2018-11-29 12:51:34 UTC
They should return lists in list context, and the iterator in scalar, as other methods like '->lines'.
Comment 1 Tomás Cohen Arazi 2018-11-29 15:16:09 UTC Comment hidden (obsolete)
Comment 2 Tomás Cohen Arazi 2018-11-29 15:16:16 UTC Comment hidden (obsolete)
Comment 3 Tomás Cohen Arazi 2018-11-29 15:16:22 UTC Comment hidden (obsolete)
Comment 4 Martin Renvoize 2018-11-29 15:37:51 UTC Comment hidden (obsolete)
Comment 5 Martin Renvoize 2018-11-29 15:37:55 UTC Comment hidden (obsolete)
Comment 6 Martin Renvoize 2018-11-29 15:37:58 UTC Comment hidden (obsolete)
Comment 7 Martin Renvoize 2018-11-29 15:38:21 UTC
Nice catch, works as expected.. Signing Off.
Comment 8 Josef Moravec 2018-11-30 16:52:43 UTC Comment hidden (obsolete)
Comment 9 Josef Moravec 2018-11-30 16:52:48 UTC Comment hidden (obsolete)
Comment 10 Josef Moravec 2018-11-30 16:52:52 UTC Comment hidden (obsolete)
Comment 11 Nick Clemens 2018-12-26 15:59:29 UTC
Simple rebase needed
Comment 12 Tomás Cohen Arazi 2018-12-26 17:51:02 UTC
Created attachment 83511 [details] [review]
Bug 21909: Unit tests

This patch introduces regression tests for the behaviour to be
introduced. Both outstanding_credits and outstanding_debits methods
should return a Koha::Account::Lines object in scalar context, and a
list of Koha::Account::Line objects in list context.

To test:
- Apply this patch
- Run
  $ kshell
 k$ prove t/db_dependent/Koha/Account.t
=> FAIL: The current behaviour doesn't match the described

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 13 Tomás Cohen Arazi 2018-12-26 17:51:07 UTC
Created attachment 83512 [details] [review]
Bug 21909: Make Koha::Account::outstanding_* preserve context

This patch modifies the methods so they preserve the caller's context
(list and scalar).

To test:
- Apply the first patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/Account.t
=> FAIL: outstanding_credits and outstanding_debits tests fail
- Apply this patch
- Run:
 k$ prove t/db_dependent/Koha/Account.t
=> SUCCESS: We are so happy now :-D
- Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 14 Tomás Cohen Arazi 2018-12-26 17:51:11 UTC
Created attachment 83513 [details] [review]
Bug 21909: Add return type explanation to POD

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 15 Tomás Cohen Arazi 2018-12-26 17:51:43 UTC
(In reply to Nick Clemens from comment #11)
> Simple rebase needed

Tests count mismatch, done!
Comment 16 Nick Clemens 2019-01-02 21:10:24 UTC
Awesome work all!

Pushed to master for 19.05
Comment 17 Martin Renvoize 2019-01-07 15:02:37 UTC
I'm changing this from 'enhancement' to 'minor' as I believe it was a mistake and thus a bug in the first place for the caller context to be lost..  as such:

Pushed to 18.11.x for 18.11.02.
Comment 18 Lucas Gass 2019-01-08 23:21:12 UTC
cannot cleanly apply this for 18.05. if this is needed in 18.05 can we please rebase.
Comment 19 Tomás Cohen Arazi 2019-01-09 09:51:46 UTC
(In reply to Lucas Gass from comment #18)
> cannot cleanly apply this for 18.05. if this is needed in 18.05 can we
> please rebase.

You can skip it, Lucas.