forked from emberjs/ember.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ENV.VIEW_STATE to warn or throw on ViewState usage.
Closes emberjs#6.
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Ember.ViewState | ||
|
||
In Ember 1.0, `Ember.ViewState` has been removed. This fork introduces a flag, `ENV.VIEW_STATE`, with three allowed values: | ||
|
||
* `null` (the default) -- `Ember.ViewState` works per 0.9.8.1 | ||
* `"warn"` -- Calling `extend` or `create` will warn | ||
* `"1.0"` -- Calling `extend` or `create` will throw | ||
|
||
See [issue #6](https://github.com/zendesk/ember.js/issues/6) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var originalFlag, originalWarn, warnings; | ||
|
||
module("Backported Ember.ViewState", { | ||
setup: function() { | ||
originalFlag = Ember.ENV.VIEW_STATE; | ||
originalWarn = Ember.Logger.warn; | ||
warnings = []; | ||
Ember.Logger.warn = function(msg) { | ||
warnings.push(msg.replace("WARNING: ", "")); | ||
}; | ||
}, | ||
teardown: function() { | ||
Ember.ENV.VIEW_STATE = originalFlag; | ||
Ember.Logger.warn = originalWarn; | ||
} | ||
}); | ||
|
||
test("doesn't warn on null level", function() { | ||
Ember.ENV.VIEW_STATE = null; | ||
|
||
Ember.ViewState.extend(); | ||
Ember.ViewState.create(); | ||
equal(warnings.length, 0); | ||
}); | ||
|
||
test("warns on warn level", function() { | ||
Ember.ENV.VIEW_STATE = 'warn'; | ||
|
||
Ember.ViewState.extend(); | ||
equal(warnings.length, 1); | ||
equal(warnings[0], "Ember.ViewState has been removed from Ember 1.0."); | ||
Ember.ViewState.create(); | ||
equal(warnings.length, 2); | ||
equal(warnings[1], "Ember.ViewState has been removed from Ember 1.0."); | ||
}); | ||
|
||
test("throws on error level", function() { | ||
Ember.ENV.VIEW_STATE = '1.0'; | ||
|
||
raises(function() { | ||
Ember.ViewState.extend(); | ||
}, /Ember\.ViewState has been removed from Ember 1\.0\./); | ||
|
||
raises(function() { | ||
Ember.ViewState.create(); | ||
}, /Ember\.ViewState has been removed from Ember 1\.0\./); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters