Summary: | The fallback value for onshelfholds should be 0 | ||
---|---|---|---|
Product: | Koha | Reporter: | Tomás Cohen Arazi (tcohen) <tomascohen> |
Component: | Architecture, internals, and plumbing | Assignee: | Tomás Cohen Arazi (tcohen) <tomascohen> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | minor | ||
Priority: | P5 - low | CC: | 1joynelson, david |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | Trivial patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: |
20.05.00
|
|
Circulation function: | |||
Bug Depends on: | 18936 | ||
Bug Blocks: | |||
Attachments: |
Bug 24602: Tests for get_onshlefholds_policy
Bug 24602: Make get_onshelfholds_policy fallback to 0 Bug 24602: Tests for get_onshlefholds_policy Bug 24602: Make get_onshelfholds_policy fallback to 0 Bug 24602: Tests for get_onshlefholds_policy Bug 24602: Make get_onshelfholds_policy fallback to 0 |
Description
Tomás Cohen Arazi (tcohen)
2020-02-06 14:08:22 UTC
Created attachment 98532 [details] [review] Bug 24602: Tests for get_onshlefholds_policy Ths patch introduces tests for get_onshelf_policy. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/CirculationRules.t => FAIL: Tests fail because the current code returns undef instead of 0 Created attachment 98533 [details] [review] Bug 24602: Make get_onshelfholds_policy fallback to 0 The onshelfholds circulation rules values are more of an ENUM type (as opposed to other rules with integers like max*qty). In the quantities cases, it makes sense to have undef mean unlimited. In the enum type it is clearer to just set a default value (0) as the code already expects (Note: undef and 0 both eval to false so there's no behaviour problem, but warnings or we get forced to check for defined when the rule is used. It seems trivial to just make the rule fallback to a chosen default value). This patch makes it fallback to 0. To test: 1. Run: $ kshell k$ prove t/db_dependent/Koha/CirculationRules.t \ t/db_dependent/Reserves.t => FAIL: CirculationRules.t fails and Reserves.t prints a warning 2. Apply this patch 3. Repeat (1) => SUCCESS: Tests pass! No warning! 4. Sign off :-D Is this a warning? root@8881cb995d76:koha(bz24602)$ prove t/db_dependent/Reserves.t t/db_dependent/Reserves.t .. 8/62 Argument "book_reserved" isn't numeric in numeric eq (==) at /kohadevbox/koha/C4/Items.pm line 1776. t/db_dependent/Reserves.t .. ok All tests successful. Files=1, Tests=62, 8 wallclock secs ( 0.04 usr 0.00 sys + 6.64 cusr 0.63 csys = 7.31 CPU) Result: PASS (In reply to David Nind from comment #3) > Is this a warning? > > root@8881cb995d76:koha(bz24602)$ prove t/db_dependent/Reserves.t > t/db_dependent/Reserves.t .. 8/62 Argument "book_reserved" isn't numeric in > numeric eq (==) at /kohadevbox/koha/C4/Items.pm line 1776. > t/db_dependent/Reserves.t .. ok > All tests successful. > Files=1, Tests=62, 8 wallclock secs ( 0.04 usr 0.00 sys + 6.64 cusr 0.63 > csys = 7.31 CPU) > Result: PASS That's new, this is the warning I'm referring to: Use of uninitialized value $on_shelf_holds in numeric eq (==) at /kohadevbox/koha/C4/Reserves.pm line 1239. Created attachment 98554 [details] [review] Bug 24602: Tests for get_onshlefholds_policy Ths patch introduces tests for get_onshelf_policy. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/CirculationRules.t => FAIL: Tests fail because the current code returns undef instead of 0 Signed-off-by: David Nind <david@davidnind.com> Created attachment 98555 [details] [review] Bug 24602: Make get_onshelfholds_policy fallback to 0 The onshelfholds circulation rules values are more of an ENUM type (as opposed to other rules with integers like max*qty). In the quantities cases, it makes sense to have undef mean unlimited. In the enum type it is clearer to just set a default value (0) as the code already expects (Note: undef and 0 both eval to false so there's no behaviour problem, but warnings or we get forced to check for defined when the rule is used. It seems trivial to just make the rule fallback to a chosen default value). This patch makes it fallback to 0. To test: 1. Run: $ kshell k$ prove t/db_dependent/Koha/CirculationRules.t \ t/db_dependent/Reserves.t => FAIL: CirculationRules.t fails and Reserves.t prints a warning 2. Apply this patch 3. Repeat (1) => SUCCESS: Tests pass! No warning! 4. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Created attachment 98578 [details] [review] Bug 24602: Tests for get_onshlefholds_policy Ths patch introduces tests for get_onshelf_policy. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/CirculationRules.t => FAIL: Tests fail because the current code returns undef instead of 0 Signed-off-by: David Nind <david@davidnind.com> Created attachment 98579 [details] [review] Bug 24602: Make get_onshelfholds_policy fallback to 0 The onshelfholds circulation rules values are more of an ENUM type (as opposed to other rules with integers like max*qty). In the quantities cases, it makes sense to have undef mean unlimited. In the enum type it is clearer to just set a default value (0) as the code already expects (Note: undef and 0 both eval to false so there's no behaviour problem, but warnings or we get forced to check for defined when the rule is used. It seems trivial to just make the rule fallback to a chosen default value). This patch makes it fallback to 0. To test: 1. Run: $ kshell k$ prove t/db_dependent/Koha/CirculationRules.t \ t/db_dependent/Reserves.t => FAIL: CirculationRules.t fails and Reserves.t prints a warning 2. Apply this patch 3. Repeat (1) => SUCCESS: Tests pass! No warning! 4. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Nice work everyone! Pushed to master for 20.05 not pushed to 19.11.x branch due to dependencies |