<commit_before>module('Ajax delete', {
    setup: function() {
        App.Post = BD.Model.extend({
            title: BD.attr('string'),
            comments: BD.hasMany('App.Comment', 'post')
        });
        App.Comment = BD.Model.extend({
            post: BD.belongsTo('App.Post', {isParent: true}),
            text: BD.attr('string')
        });
        BD.store.loadMany(App.Post, [
            {
                id: 101,
                title: 'Delete yes, yes'
            }
        ]);
        BD.store.loadMany(App.Comment, [
            {
                id: 201,
                postId: 101,
                text: 'I agree!'
            },
            {
                id: 202,
                postId: 101,
                text: 'I disagree!'
            }
        ]);
    },
    teardown: function() {
        
        BD.store.reset();
    }
});

test('Test ajax request options', function() {
    expect(2);
    BD.ajax = function(hash) {
        equal(hash.type, 'DELETE');
        equal(hash.url, '/posts/101');
    };
    var post = App.Post.find(101);
    post.deleteRecord();
    flushAjax();
});

test('Other records that were also deleted by the API should be removed from the store', function() {
    fakeAjaxSuccess({
        meta: {
            success: true,
            statusCode: 200,
            deletedRecords: {
                comments: [
                    201,
                    202
                ]
            }
        }
    });
    var post = App.Post.find(101);
    post.deleteRecord();
    flushAjax();
    equal(BD.store.recordForTypeAndId(App.Post, 101), null, 'Post should have been deleted');
    equal(BD.store.recordForTypeAndId(App.Comment, 201), null, 'Comment should have been deleted');
    equal(BD.store.recordForTypeAndId(App.Comment, 202), null, 'Comment should have been deleted');
});<commit_msg>Fixed small things in delete test<commit_after>module('Ajax delete', {
    setup: function() {
        App.Post = BD.Model.extend({
            title: BD.attr('string'),
            comments: BD.hasMany('App.Comment', 'post', {isEmbedded: true})
        });
        App.Comment = BD.Model.extend({
            post: BD.belongsTo('App.Post', {isParent: true}),
            text: BD.attr('string')
        });
        BD.store.loadMany(App.Post, [
            {
                id: 101,
                title: 'Delete yes, yes'
            }
        ]);
        BD.store.loadMany(App.Comment, [
            {
                id: 201,
                postId: 101,
                text: 'I agree!'
            },
            {
                id: 202,
                postId: 101,
                text: 'I disagree!'
            }
        ]);
    },
    teardown: function() {
        
        BD.store.reset();
    }
});

test('Test ajax request options', function() {
    expect(2);
    BD.ajax = function(hash) {
        equal(hash.type, 'DELETE');
        equal(hash.url, '/posts/101');
    };
    var post = App.Post.find(101);
    post.deleteRecord();
});

test('Other records that were also deleted by the API should be removed from the store', function() {
    fakeAjaxSuccess({
        meta: {
            success: true,
            statusCode: 200,
            deletedRecords: {
                comments: [
                    201,
                    202
                ]
            }
        }
    });
    var post = App.Post.find(101);
    post.deleteRecord();
    flushAjax();
    equal(BD.store.recordForTypeAndId(App.Post, 101), null, 'Post should have been deleted');
    equal(BD.store.recordForTypeAndId(App.Comment, 201), null, 'Comment should have been deleted');
    equal(BD.store.recordForTypeAndId(App.Comment, 202), null, 'Comment should have been deleted');
});
{'fraction_non_alphanumeric': 0.13736996532408643, 'fraction_numerical': 0.022939450520138703, 'mean_word_length': 1.508361204013378, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '74604', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1052, 'n_words': 238}