ember-data issue 847
Reproducing the problem with App.reset() and DS.get("defaultStore").
HTML
<script src="https://s3.amazonaws.com/kiddsoftware-jsfiddle/handlebars-1.0.0-rc.3.js"></script>
<link rel="stylesheet" href="https://s3.amazonaws.com/kiddsoftware-jsfiddle/mocha-1.9.0.css">
<script src="https://s3.amazonaws.com/kiddsoftware-jsfiddle/mocha-1.9.0.js"></script>
<script src="https://s3.amazonaws.com/kiddsoftware-jsfiddle/sinon-1.6.0.js"></script>
<script src=" https://s3.amazonaws.com/kiddsoftware-jsfiddle/chai-1.5.0.js"></script>
<script src="https://s3.amazonaws.com/kiddsoftware-jsfiddle/ember-1.0.0-rc.2.js"></script>
<script src="https://s3.amazonaws.com/kiddsoftware-jsfiddle/ember-data-a29070da.min.js"></script>
<!-- Mocha test output goes here. -->
<div id="mocha"></div>
<!-- Handlebars templates for our application. -->
<script type="text/x-handlebars">
<h1>Ember-Data breaks App.reset()</h1>
<p><a href="https://github.com/emberjs/data/issues/847">As reported here.</a></p>
{{outlet}}
</script>
JavaScript
//================================================================================
// Application Code
window.App = Ember.Application.create();
App.Employee = DS.Model.extend({
name: DS.attr("string")
});
//================================================================================
// Test Code
// Configure Mocha, telling both it and chai to use BDD-style tests.
mocha.setup("bdd");
chai.should();
App.Store = DS.Store.extend({
revision: 12,
adapter: DS.FixtureAdapter.create({ simulateRemoteResponse: false })
});
App.Employee.FIXTURES = [{
id: 1,
name: "Jane Q. Public",
}];
beforeEach(function () {
// This leave DS.get("defaultStore") broken. Comment out the reset and
// the test will pass.
App.reset();
Ember.testing = true;
});
afterEach(function () {
Ember.testing = false;
});
describe("App.Employee", function () {
it("has a name", function () {
var jane;
// Load in Ember.run so we actually get data.
Ember.run(function () { jane = App.Employee.find(1); });
jane.get("name").should.equal("Jane Q. Public");
});
});
// Run all our test suites. Only necessary in the browser.
mocha.run();