Skip to content

Commit

Permalink
Merge pull request #11273 from mitchlloyd/deprecate-service-validation
Browse files Browse the repository at this point in the history
Change assertion to deprecation
  • Loading branch information
rwjblue committed May 25, 2015
2 parents 850aba3 + 2850421 commit 9407d4c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/ember-application/lib/utils/validate-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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');
});

0 comments on commit 9407d4c

Please sign in to comment.