RCFilters: Fix getFilterRepresentation to consider '0' as false
authorMoriel Schottlender <moriel@gmail.com>
Sat, 13 May 2017 19:28:38 +0000 (12:28 -0700)
committerMoriel Schottlender <moriel@gmail.com>
Sat, 13 May 2017 20:22:58 +0000 (13:22 -0700)
commitee5397eaa025908ac9dfaa3d4688f027c09c8a7d
tree1170a7ed9a47f803344cd5dd6d35ff2450ee96bf
parenta6a7f754b6c848ee652482017891d847e85592ce
RCFilters: Fix getFilterRepresentation to consider '0' as false

Because '0' is a string, it's true, but for our purposes, it's
supposed to be false. Thanks JavaScript.

This bug was actually pretty horrific, it meant that when you refresh
the representation is all wrong (all items in the group were considered
true if the group was 'send_unselected_if_any' which meant that most
of those (that are full coverage) 'corrected themselves' to be all-false
which meant you lost filters when refreshing, even though the parameters
appeared in the URL (the url helpfully corrects itself based on the model
but the model was wrong.)

How did this pass unit tests, one might ask. Well, the unit tests were
treating parameter values as numbers, rather than strings, a fact that
is promptly fixed in this commit.

Also, for consistency and proper data validation, all parameters are
now always stored and handled as strings, in the model.

Bug: T165230
Change-Id: I16d8d95be067b3e48e557ef25f8eb6a49736aa4e
resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FilterGroup.js
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
tests/qunit/suites/resources/mediawiki.rcfilters/dm.FiltersViewModel.test.js