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

Change assertion to deprecation #11273

Merged
merged 1 commit into from
May 25, 2015
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
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');
});