Skip to content

Commit

Permalink
Merge pull request #11389 from bantic/deprecate-view-helper
Browse files Browse the repository at this point in the history
[BUGFIX beta] Add deprecation for view helper
  • Loading branch information
rwjblue committed Jun 9, 2015
2 parents 7cf3535 + c5be1b0 commit c471c0f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
25 changes: 24 additions & 1 deletion packages/ember-debug/tests/main_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
import Ember from 'ember-metal/core';

QUnit.module('ember-debug');
let originalEnvValue;

QUnit.module('ember-debug', {
setup() {
originalEnvValue = Ember.ENV.RAISE_ON_DEPRECATION;
Ember.ENV.RAISE_ON_DEPRECATION = true;
},

teardown() {
Ember.ENV.RAISE_ON_DEPRECATION = originalEnvValue;
}
});

QUnit.test('Ember.deprecate does not throw if RAISE_ON_DEPRECATION env value is false', function(assert) {
assert.expect(1);
Ember.ENV.RAISE_ON_DEPRECATION = false;

try {
Ember.deprecate('Should not throw', false);
assert.ok(true, 'Ember.deprecate did not throw');
} catch(e) {
assert.ok(false, `Expected Ember.deprecate not to throw but it did: ${e.message}`);
}
});

QUnit.test('Ember.deprecate throws deprecation if second argument is falsy', function() {
expect(3);
Expand Down
1 change: 1 addition & 0 deletions packages/ember-htmlbars/lib/keywords/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import objectKeys from "ember-metal/keys";

export default {
setupState(state, env, scope, params, hash) {
Ember.deprecate(`Using the "view" helper is deprecated.`, !!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT, { url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-view' });
var read = env.hooks.getValue;
var targetObject = read(scope.self);
var viewClassOrInstance = state.viewClassOrInstance;
Expand Down
15 changes: 15 additions & 0 deletions packages/ember-htmlbars/tests/helpers/view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,21 @@ QUnit.test("View lookup - App.FuView (DEPRECATED)", function() {
equal(jQuery('#fu').text(), 'bro');
});

QUnit.test("View lookup in a template using 'view' helper is deprecated", function() {
var FuView = viewClass({});

registry.register('view:fu', FuView);

view = EmberView.extend({
template: compile("{{view 'fu'}}"),
container: container
}).create();

expectDeprecation(function() {
runAppend(view);
}, `Using the "view" helper is deprecated.`);
});

QUnit.test("View lookup - 'fu'", function() {
var FuView = viewClass({
elementId: "fu",
Expand Down
4 changes: 3 additions & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
// Don't worry about jQuery version
ENV['FORCE_JQUERY'] = true;

ENV['RAISE_ON_DEPRECATION'] = true;
// FIXME Many tests need to be ported to not use "{{view}}" before this
// can be re-enabled
ENV['RAISE_ON_DEPRECATION'] = false;
})();
</script>

Expand Down

0 comments on commit c471c0f

Please sign in to comment.