diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 609c29c4c3381ad190e22125487621b41b2014b1..dfe5273543d01d83e1d8e5683f41de6ce7eaf5b2 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -135,6 +135,10 @@ app.views.Publisher = Backbone.View.extend({ }); this.viewPollCreator.on("change", this.checkSubmitAvailability, this); this.viewPollCreator.render(); + + if (this.prefillMention) { + this.handleTextchange(); + } }, // set the selected aspects in the dropdown by their ids diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index 5bed30580e95bd75a8be98dc3f5acd052a5cab6f..1356abbc25c63710d6d316452506e627a2fcc3cd 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -47,6 +47,21 @@ describe("app.views.Publisher", function() { this.view = new app.views.Publisher(); }); + describe("#initSubviews", function() { + it("calls handleTextchange if the publisher is prefilled with mentions", function() { + spyOn(this.view, "handleTextchange"); + this.view.prefillMention = "user@example.org"; + this.view.initSubviews(); + expect(this.view.handleTextchange).toHaveBeenCalled(); + }); + + it("doesn't call handleTextchange if there are no prefilled mentions", function() { + spyOn(this.view, "handleTextchange"); + this.view.initSubviews(); + expect(this.view.handleTextchange).not.toHaveBeenCalled(); + }); + }); + describe("#open", function() { it("removes the 'closed' class from the publisher element", function() { expect($(this.view.el)).toHaveClass("closed");