Skip to content
This repository has been archived by the owner on Nov 11, 2017. It is now read-only.

Properly expectDeprecation when test parameter is a function #153

Merged
merged 1 commit into from
Jun 12, 2015

Conversation

bantic
Copy link
Member

@bantic bantic commented Jun 12, 2015

Ember.deprecate is called with (message, test, options). When
test is falsy or a function that evaluates to falsy, the deprecation
is issued.

expectDeprecation was correctly evaluating the test param when it is
a function, but not pushing the correct result of that function into
actuals. This made using expectDeprecate fail for a deprecation that used
a test function.

Example:

// Ember code
function foo() {
  Ember.deprecate('message', function() { return false; });
}

// test code -- this test would erroneously fail because
// expectDeprecation pushes ['message', function() { return false; }]
// onto actuals instead of ['message', false]
expectDeprecation(function() {
  foo();
}, 'message');

@mixonic
Copy link
Member

mixonic commented Jun 12, 2015

waiting on a test

`Ember.deprecate` is called with `(message, test, options)`. When
`test` is falsy or a function that evaluates to falsy, the deprecation
is issued.

`expectDeprecation` was correctly evaluating the `test` param when it is
a function, but not pushing the correct result of that function into
`actuals`. This made using `expectDeprecate` fail for a deprecation that used
a test function.

Example:

```
// Ember code
function foo() {
  Ember.deprecate('message', function() { return false; });
}

// test code -- this test would erroneously fail because
// expectDeprecation pushes ['message', function() { return false; }]
// onto actuals instead of ['message', false]
expectDeprecation(function() {
  foo();
}, 'message');
```
@bantic bantic force-pushed the expect-deprecate-with-function-test branch from 4007c81 to 9b2cf9b Compare June 12, 2015 17:02
@bantic
Copy link
Member Author

bantic commented Jun 12, 2015

@mixonic updated. fixed the test that was erroneously passing before.

mixonic added a commit that referenced this pull request Jun 12, 2015
Properly `expectDeprecation` when `test` parameter is a function
@mixonic mixonic merged commit a064f0c into emberjs:master Jun 12, 2015
@bantic bantic deleted the expect-deprecate-with-function-test branch June 12, 2015 17:05
bantic added a commit to bantic/ember.js that referenced this pull request Jun 12, 2015
…lect"}}

Use a template-compiler plugin to detect `{{view "string"}}` at compile-time
and issue a deprecation with location information. Has a special case
deprecation when the string === "select".

Removes a test from the view helper tests that was checking for the
deprecation at runtime (and removes the associated code in
the ember-htmlbars package's `keywords/view`).

Note: This does not catch a deprecation when the path is not a string,
e.g., `{{view view.someProperty}}`, however emberjs#11401 would catch and issue
a deprecation message for that case (at runtime).

Also a few changes to deprecations:

  * document `id` param to `Ember.deprecate`
  * include deprecation id in log/error message
  * Use dot-namespaced deprecation ids (more similar to how `instrument` works and paves the way to in the future changing deprecation log levels by paths ie `"view.*"`)
  * globally silence view-related deprecations in tests to avoid overflowing travis ci's log
  * update ember-dev dep in bower (pr: emberjs/ember-dev#153) to `a064f0cd2f4c225ffd023b63d4cb31a79db04aaf`
  * change the view-and-controller-path template compiler plugin to always deprecate `{{controller}}`
  * change the view-and-controller-path template compiler plugin to skip deprecating `{{view}}` when `Ember.ENV._ENABLE_LEGACY_VIW_SUPPORT` is true

refs emberjs#11377
rwjblue pushed a commit to emberjs/ember.js that referenced this pull request Jun 13, 2015
…lect"}}

Use a template-compiler plugin to detect `{{view "string"}}` at compile-time
and issue a deprecation with location information. Has a special case
deprecation when the string === "select".

Removes a test from the view helper tests that was checking for the
deprecation at runtime (and removes the associated code in
the ember-htmlbars package's `keywords/view`).

Note: This does not catch a deprecation when the path is not a string,
e.g., `{{view view.someProperty}}`, however #11401 would catch and issue
a deprecation message for that case (at runtime).

Also a few changes to deprecations:

  * document `id` param to `Ember.deprecate`
  * include deprecation id in log/error message
  * Use dot-namespaced deprecation ids (more similar to how `instrument` works and paves the way to in the future changing deprecation log levels by paths ie `"view.*"`)
  * globally silence view-related deprecations in tests to avoid overflowing travis ci's log
  * update ember-dev dep in bower (pr: emberjs/ember-dev#153) to `a064f0cd2f4c225ffd023b63d4cb31a79db04aaf`
  * change the view-and-controller-path template compiler plugin to always deprecate `{{controller}}`
  * change the view-and-controller-path template compiler plugin to skip deprecating `{{view}}` when `Ember.ENV._ENABLE_LEGACY_VIW_SUPPORT` is true

refs #11377

(cherry picked from commit c2bcc86)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants