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

Delete records created by MockCreateRequest #58

Merged
merged 1 commit into from
Jan 23, 2015

Conversation

mmelvin0
Copy link
Contributor

When I use FactoryGuyTestMixin#handleCreate without a match, it correctly mocks my POST request. When I use a match, it creates a record in my app's store from the match data. Thus my assertion that there should be one record fails, as there are two.

I'm not sure if this is the correct approach, but immediately deleting the record after serialization solves the problem for me. Here's my test case. MODEL is the factory fixture name and helper is a FactoryGuyTestMixin.

test('Create', function () {
    expect(2);
    visit('/');
    andThen(function () {
        equal(find('#main table tbody tr').length, 0, 'There should be no todos');
        fillIn('#new-todo', 'Item 1');
        // after this, there is one record
        // helper.handleCreate(MODEL);
        // after this, there are two records
        helper.handleCreate(MODEL, {match: {title: 'Item 1', isCompleted: false}});
        keyEvent('#new-todo', 'keyup', 13);
    });
    andThen(function() {
        equal(find('#main table tbody tr').length, 1, 'There should be one todo');
    });
});

danielspaniel added a commit that referenced this pull request Jan 23, 2015
Delete records created by MockCreateRequest
@danielspaniel danielspaniel merged commit 48f7349 into adopted-ember-addons:master Jan 23, 2015
@danielspaniel
Copy link
Collaborator

Yikes, that is a good catch @mmelvin0 .. how did I not see that before??
If you need a new patch version or gem created let me know. Otherwise if you using bower you can just bower update ember-data-factory-guy , and you should get new code.

@danielspaniel
Copy link
Collaborator

Oh well .. I pushed a new version out anyway .. to fix another bug .. so v0.9.7 has this fix

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

Successfully merging this pull request may close these issues.

2 participants