Skip to content
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 packages/ember-runtime/lib/system/lazy_load.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@submodule ember-runtime
*/

var loadHooks = {};
var loadHooks = Ember.ENV.EMBER_LOAD_HOOKS || {};
var loaded = {};

/**
Expand Down
12 changes: 12 additions & 0 deletions packages/ember-runtime/tests/system/lazy_load_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,15 @@ test("if runLoadHooks was already run, it executes newly added hooks immediately

equal(count, 1, "the original object was passed into the load hook");
});

test("hooks in ENV.EMBER_LOAD_HOOKS['hookName'] get executed", function() {

// Note that the necessary code to perform this test is run before
// the Ember lib is loaded in tests/index.html

Ember.run(function() {
Ember.runLoadHooks("__before_ember_test_hook__", 1);
});

equal(window.ENV.__test_hook_count__, 1, "the object was passed into the load hook");
});
8 changes: 8 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@
}
window.ENV = window.ENV || {};

// Test for "hooks in ENV.EMBER_LOAD_HOOKS['hookName'] get executed"
ENV.EMBER_LOAD_HOOKS = ENV.EMBER_LOAD_HOOKS || {};
ENV.EMBER_LOAD_HOOKS.__before_ember_test_hook__ = ENV.EMBER_LOAD_HOOKS.__before_ember_test_hook__ || [];
ENV.__test_hook_count__ = 0;
ENV.EMBER_LOAD_HOOKS.__before_ember_test_hook__.push(function(object) {
ENV.__test_hook_count__ += object;
});

// Handle extending prototypes
QUnit.config.urlConfig.push('extendprototypes');

Expand Down