PaulUithol / Backbone-relational

Get and set relations (one-to-one, one-to-many, many-to-one) for Backbone models
http://backbonerelational.org
MIT License
2.34k stars 330 forks source link

Collection#parse called with RelationalModel as the response argument after Collection#create with wait: true #555

Open wojcikstefan opened 8 years ago

wojcikstefan commented 8 years ago

This test passes:

        test( "Prove that Collection#parse is called with a RelationalModel as the response", function() {
            var parseArg;

            var Contact = Backbone.RelationalModel.extend();
            var Contacts = Backbone.Collection.extend({
                model: Contact,
                url: '/contacts',
                parse: function( response ) {
                    parseArg = response;
                    return response.items;
                }
            });

            var contacts = new Contacts();
            contacts.create({ foo: 3 }, {
                wait: true,
                // fake response for testing
                response: {
                    status: 200,
                    responseText: { foo: 3 }
                }
            });

            equal(parseArg instanceof Backbone.RelationalModel, true);
        });

and I doubt it's the expected behavior given that w/o wait: true the same test fails. Collection#parse is also never called if you use the original backbone model instead of the RelationalModel.

wojcikstefan commented 8 years ago

@PaulUithol could you confirm if that's the expected behavior?

wojcikstefan commented 8 years ago

Bump - just following up here :)