Skip to content

Commit

Permalink
[BUGFIX beta] Add deprecation for view helper
Browse files Browse the repository at this point in the history
  * change env value RAISE_ON_DEPRECATION to false
  * change tests for Ember.deprecate that relied on RAISE_ON_DEPRECATION being true

refs emberjs#11377
  • Loading branch information
bantic committed Jun 9, 2015
1 parent 205e6df commit c5be1b0
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 c5be1b0

Please sign in to comment.