diff --git a/lib/helper.js b/lib/helper.js
index ea74743..61ec4c0 100644
--- a/lib/helper.js
+++ b/lib/helper.js
@@ -15,7 +15,7 @@ Ember.Handlebars.registerHelper('flashMessage', function(options) {
}
this.set('currentView', view);
- }.observes('controller.currentMessage')
+ }.observes('controller.currentMessage').on('init')
});
options.hash.controller = controller;
diff --git a/tests/integration/flash_message_test.js b/tests/integration/flash_message_test.js
index a6bcbf9..6946a6e 100644
--- a/tests/integration/flash_message_test.js
+++ b/tests/integration/flash_message_test.js
@@ -35,7 +35,9 @@ App.FromControllerController = Ember.Controller.extend({
}
});
-Ember.TEMPLATES.application = Ember.Handlebars.compile('{{#flashMessage}}{{message}}{{/flashMessage}}');
+var ApplicationTemplate = Ember.Handlebars.compile('{{#flashMessage}}{{message}}{{/flashMessage}}');
+
+Ember.TEMPLATES.application = ApplicationTemplate;
var findMessage = function() {
return $('#qunit-fixture .message');
@@ -172,3 +174,35 @@ test("should be able to use the flash messenger from a controller", function() {
assertMessage();
});
});
+
+module("child template contains flash message template", {
+ setup: function() {
+ App.reset();
+ App.injectTestHelpers();
+ Ember.TEMPLATES.application = Ember.Handlebars.compile('{{outlet}}');
+ Ember.TEMPLATES.posts = ApplicationTemplate;
+ },
+
+ teardown: function() {
+ Ember.TEMPLATES.application = ApplicationTemplate;
+ Ember.TEMPLATES.posts = undefined;
+ }
+});
+
+test("it shows flash messages on child route", function() {
+ expect(2);
+
+ visit("/");
+
+ andThen(function() {
+ router().flashMessage('test');
+ });
+
+ visit("/posts");
+
+ andThen(assertMessage);
+
+ andThen(function() {
+ equal(findMessage().text().trim(), 'test');
+ });
+});