server/apps/files/tests
Daniel Calviño Sánchez be56374c51 Fix sorting of favorite files
The sort comparator checks the "isFavorite" property of the FileInfo
objects to compare. That property is set when the file list is loaded
and the response from the server is parsed, and thus a freshly loaded
file list has the proper sorting for favorite files. However, the
property is not set in other cases, like when the FileInfo objects are
derived from FileInfoModels due to a file being marked as a favorite or
a text editor being closed, which causes the file to be sorted in the
wrong position.

There is no need to add the property in those situations, though; in all
cases the TagsPlugin adds a "tags" array property that contains an
OC.TAG_FAVORITE tag, so that tag can be checked instead of "isFavorite".
Moreover, although "isFavorite" was added by the main "_parseFileInfo"
function it did not really belong there but to the "FileInfoParser" from
the TagsPlugin; however, as that property now is not used anywhere it
was removed altogether.

A cleaner solution would have been to make the sort comparator
extensible by plugins like other behaviours of the file list and then
add the sorting logic related to favorite files to the TagsPlugin.
However, right now only the TagsPlugin would need to alter the main
sorting logic, and it seems like a corner case anyway. Even if it is
implemented as a plugin, favorite files is a core feature, so for the
time being it will be taken into account directly in the main sorting
logic; making the sort comparator extensible by plugins is defered until
there are other use cases for that.

Fixes #5410

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-07-05 15:01:23 +02:00
..
Activity Add tests for getUser() 2017-02-07 12:01:28 +01:00
BackgroundJob Fix getMock files 2016-09-06 09:29:27 +02:00
Command Introduce an event for first time login based on the last login time stamp 2016-11-14 14:50:10 +01:00
Controller Adjust the unit test 2017-06-13 11:17:44 +02:00
js Fix sorting of favorite files 2017-07-05 15:01:23 +02:00
Service Add tests for favorite action 2016-12-04 12:54:34 +01:00
Settings Use MockBuilder instead of createMock 2016-08-15 16:43:22 +02:00
HelperTest.php Update with robin 2016-07-21 18:13:58 +02:00