Fix posting element created on client #871
Resolves #871
To be merged but unit tests are welcome as well. I might add something tomorrow.
@miiihi Can you rebase and add some unit tests please?
Sorry, I'm not working with the Restangular at the moment, don't have any working installs and no time to spare...
Anyhow, this fix is really simple (one condition added!) and resolves an important issue - creating new objects (see issue #871). Rebasing and creating unit test should be really simple for any developer/maintaner.
I'm having some difficulties in understanding the original issue poster's description of the problem, but does this spec correctly capture the situation?
@miiihi @aaronpeterson
it('Should keep parent property when element is created', function() {
var account1 = Restangular.restangularizeElement(null, {}, 'accounts');
$httpBackend.expectPOST('/accounts');
account1.name = 'Hey';
account1.save().then(function(accountFromServer) {
expect(accountFromServer.parentResource).toBe(null);
expect(accountFromServer.route).not.toBe(null);
});
$httpBackend.flush();
});