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

Deprecate Controller#content alias #15528

Merged
merged 1 commit into from
Aug 3, 2017
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 features.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"ember-views.render-double-modify": "2.0.0",
"ember-routing.router-resource": "2.0.0",
"ember-routing.top-level-render-helper": "2.11.0",
"ember-runtime.controller-content": "2.16.0",
"ember-runtime.controller-proxy": "2.0.0",
"ember-runtime.action-handler-_actions": "2.0.0",
"ember-runtime.enumerable-contains": "2.7.0",
"ember-runtime.will-merge-mixin": "2.0.0",
"ember-runtime.frozen-copy": "2.0.0",
"ember-runtime.freezable-init": "2.0.0",
"ember-string-utils.fmt": "2.0.0",
Expand Down
13 changes: 8 additions & 5 deletions packages/ember-runtime/lib/mixins/controller.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Mixin, alias } from 'ember-metal';
import { deprecatingAlias } from '../computed/computed_macros';
import ActionHandler from './action_handler';
import ControllerContentModelAliasDeprecation from './controller_content_model_alias_deprecation';

/**
@class ControllerMixin
@namespace Ember
@uses Ember.ActionHandler
@private
*/
export default Mixin.create(ActionHandler, ControllerContentModelAliasDeprecation, {
export default Mixin.create(ActionHandler, {
/* ducktype as a controller */
isController: true,

Expand Down Expand Up @@ -38,12 +38,15 @@ export default Mixin.create(ActionHandler, ControllerContentModelAliasDeprecatio

@property model
@public
*/
*/
model: null,

/**
@private
*/
content: alias('model')

content: deprecatingAlias('model', {
id: 'ember-runtime.controller.content-alias',
until: '2.17.0',
url: 'https://emberjs.com/deprecations/v2.x/#toc_controller-content-alias'
})
});

This file was deleted.

29 changes: 16 additions & 13 deletions packages/ember-runtime/tests/controllers/controller_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,18 @@ QUnit.module('Controller deprecations');

QUnit.module('Controller Content -> Model Alias');

QUnit.test('`model` is aliased as `content`', function() {
expect(1);
QUnit.test('`content` is a deprecated alias of `model`', function() {
expect(2);
let controller = Controller.extend({
model: 'foo-bar'
}).create();

equal(controller.get('content'), 'foo-bar', 'content is an alias of model');
expectDeprecation(function () {
equal(controller.get('content'), 'foo-bar', 'content is an alias of model');
});
});

QUnit.test('`content` is moved to `model` when `model` is unset', function() {
QUnit.test('`content` is not moved to `model` when `model` is unset', function() {
expect(2);
let controller;

Expand All @@ -121,18 +123,19 @@ QUnit.test('`content` is moved to `model` when `model` is unset', function() {
}).create();
});

equal(controller.get('model'), 'foo-bar', 'model is set properly');
equal(controller.get('content'), 'foo-bar', 'content is set properly');
notEqual(controller.get('model'), 'foo-bar', 'model is set properly');
equal(controller.get('content'), 'foo-bar', 'content is not set properly');
});

QUnit.test('specifying `content` (without `model` specified) results in deprecation', function() {
expect(1);
QUnit.test('specifying `content` (without `model` specified) does not result in deprecation', function() {
expect(2);
expectNoDeprecation();

expectDeprecation(function() {
Controller.extend({
content: 'foo-bar'
}).create();
}, 'Do not specify `content` on a Controller, use `model` instead.');
let controller = Controller.extend({
content: 'foo-bar'
}).create();

equal(get(controller, 'content'), 'foo-bar');
});

QUnit.test('specifying `content` (with `model` specified) does not result in deprecation', function() {
Expand Down