Skip to content

Commit

Permalink
Do not register the service store when it has already been registered
Browse files Browse the repository at this point in the history
  • Loading branch information
ppcano committed Jun 29, 2015
1 parent 7eb7302 commit c71c525
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-data/lib/initializers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function initializeStore(registry, application) {

if (store) {
registry.register('service:store', store, { instantiate: false });
} else {
} else if (!registry.has('service:store')) {
registry.register('service:store', application && application.Store || Store);
}
}
24 changes: 24 additions & 0 deletions packages/ember-data/tests/integration/application-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,30 @@ test("ember-data initializer is run", function() {
ok(ran, 'ember-data initializer was found');
});

test("ember-data initializer does not register the store service when it was already registered", function() {

var AppStore = Store.extend({
isCustomStore: true
});

App.initializer({
name: "after-ember-data",
before: "ember-data",
initialize: function(registry) {
registry.register('service:store', AppStore);
}
});

run(function() {
app = App.create();
container = app.__container__;
});

var store = getStore();
ok(store && store.get('isCustomStore'), 'ember-data initializer does not overwrite the previous registered service store');

});

test("store initializer is run (DEPRECATED)", function() {
var ran = false;
App.initializer({
Expand Down

0 comments on commit c71c525

Please sign in to comment.