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

[BUGFIX release] Do not register the service store when it has already been registered #3460

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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