Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix posting element created on client #871 #993

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

miiihi
Copy link

@miiihi miiihi commented Jan 6, 2015

Resolves #871

@grabbou
Copy link
Contributor

grabbou commented Feb 19, 2015

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

@daviesgeek
Copy link
Collaborator

daviesgeek commented Jun 18, 2016

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

@miiihi
Copy link
Author

miiihi commented Nov 21, 2016

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.

@bostrom
Copy link
Collaborator

bostrom commented Nov 24, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

restangularizeElement sets parentResource when first argument is null
4 participants