emberjs/ember.js — pull request #4875 by dragulceo (2014-05-16 02:39:06+00:00)
Title: Fixed array_proxy’s clear method when sortable_array mixin is applied

I've stumbled upon what I think is a bug.

Here you can see the [jsbin](http://emberjs.jsbin.com/jirec/2/edit) with the issue and the error being triggered.

I added a failing test that will pass with the submitted change.

Description
--------------
A instance of `ArrayProxy` that has applied the `SortableMixin` and has sorting properties an error will be triggered when `clear()` method is called with the message 'Using replace on an arranged ArrayProxy is not allowed.'

Fix
----
The `clear` method calls `replace` method where it's checked if the current object is sortable (contains an `arrangeContent` attribute) and if sortable triggers the error.

I checked the way that `_replace` method works where `replaceContent` method is called which finally calls `EnumerableUtils.replace`. For the case when the `objects` array given as third parameter is empty the instance's content is cleared. So I mutated the if condition so that when an empty replacement objects array is given the `_replace` method will be called, the array will be cleared, and the error not thrown anymore.