From 28504216e0cd9b8de8ee4bbb67da6f749addec44 Mon Sep 17 00:00:00 2001 From: Mitch Lloyd Date: Mon, 25 May 2015 15:19:09 -0400 Subject: [PATCH] Change assertion to deprecation --- .../ember-application/lib/utils/validate-type.js | 12 ++++++++++++ .../default_resolver_test.js | 16 +++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/ember-application/lib/utils/validate-type.js b/packages/ember-application/lib/utils/validate-type.js index 9ad12a21957..994891cabfd 100644 --- a/packages/ember-application/lib/utils/validate-type.js +++ b/packages/ember-application/lib/utils/validate-type.js @@ -17,6 +17,18 @@ export default function validateType(resolvedType, parsedName) { return; } + // 2.0TODO: Remove this deprecation warning + if (parsedName.type === 'service') { + Ember.deprecate( + "In Ember 2.0 service factories must have an `isServiceFactory` " + + `property set to true. You registered ${resolvedType} as a service ` + + "factory. Either add the `isServiceFactory` property to this factory or " + + "extend from Ember.Service.", + resolvedType.isServiceFactory + ); + return; + } + let [factoryFlag, expectedType] = validationAttributes; Ember.assert(`Expected ${parsedName.fullName} to resolve to an ${expectedType} but instead it was ${resolvedType}.`, function() { diff --git a/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js b/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js index d77b7d7447f..360a4237706 100644 --- a/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js +++ b/packages/ember-application/tests/system/dependency_injection/default_resolver_test.js @@ -178,7 +178,8 @@ QUnit.test("lookup description", function() { }); QUnit.test("validating resolved objects", function() { - let types = ['route', 'component', 'view', 'service']; + // 2.0TODO: Add service to this list + let types = ['route', 'component', 'view']; // Valid setup application.FooRoute = Route.extend(); @@ -207,3 +208,16 @@ QUnit.test("validating resolved objects", function() { }, matcher, `Should assert for ${type}`); }); }); + +QUnit.test("deprecation warning for service factories without isServiceFactory property", function() { + expectDeprecation(/service factories must have an `isServiceFactory` property/); + application.FooService = EmberObject.extend(); + registry.resolve('service:foo'); + +}); + +QUnit.test("no deprecation warning for service factories that extend from Ember.Service", function() { + expectNoDeprecation(); + application.FooService = Service.extend(); + registry.resolve('service:foo'); +});