Skip to content

Commit

Permalink
Allow libraries loaded before ember to tie into ember load hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
machty committed Jan 24, 2013
1 parent 600d38a commit c727dfe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-runtime/lib/system/lazy_load.js
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
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
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

0 comments on commit c727dfe

Please sign in to comment.