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

Failing test: 'When a record is loaded a second time, isLoaded should stay true #731

Merged
merged 2 commits into from
Apr 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/ember-data/lib/system/model/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,6 @@ var states = {
// SUBSTATES

materializing: DS.State.create({
// FLAGS
isLoaded: false,

// EVENTS
willSetProperty: Ember.K,
didSetProperty: Ember.K,
Expand All @@ -540,6 +537,9 @@ var states = {

// SUBSTATES
firstTime: DS.State.create({
// FLAGS
isLoaded: false,

exit: function(manager) {
var record = get(manager, 'record');

Expand Down
24 changes: 24 additions & 0 deletions packages/ember-data/tests/integration/reload_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,27 @@ asyncTest("If a record is modified, it cannot be reloaded", function() {
}, /uncommitted/);
}
});


asyncTest("When a record is loaded a second time, isLoaded stays true", function() {
store.load(Person, { id: 1, name: "Tom Dale" });

var person = store.find(Person, 1);

equal(get(person, 'isLoaded'), true, "The person is loaded");

function isLoadedDidChange() {
// This shouldn't be hit
equal(get(person, 'isLoaded'), true, "The person is still loaded after change");
}
person.addObserver('isLoaded', isLoadedDidChange);

// Reload the record
store.load(Person, { id: 1, name: "Tom Dale" });
equal(get(person, 'isLoaded'), true, "The person is still loaded after load");

person.removeObserver('isLoaded', isLoadedDidChange);

start();

});