restangular icon indicating copy to clipboard operation
restangular copied to clipboard

Fix posting element created on client #871

Open miiihi opened this issue 10 years ago • 4 comments

Resolves #871

miiihi avatar Jan 06 '15 17:01 miiihi

To be merged but unit tests are welcome as well. I might add something tomorrow.

grabbou avatar Feb 19 '15 23:02 grabbou

@miiihi Can you rebase and add some unit tests please?

daviesgeek avatar Jun 18 '16 00:06 daviesgeek

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.

miiihi avatar Nov 21 '16 19:11 miiihi

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();
    });

bostrom avatar Nov 24 '16 21:11 bostrom