diff --git a/Changelog.md b/Changelog.md index 4d006575f33..5717ff99975 100644 --- a/Changelog.md +++ b/Changelog.md @@ -138,6 +138,7 @@ everything is set up. * Fix broken reactions link on mobile page [#4125](https://github.com/diaspora/diaspora/pull/4125) * Missing translation "Back to top". [#4138](https://github.com/diaspora/diaspora/pull/4138) * Fix preview with locator feature. [#4147](https://github.com/diaspora/diaspora/pull/4147) +* Fix mentions at end of post. [#3746](https://github.com/diaspora/diaspora/issues/3746) ## Features diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 28df68dbd13..28368ec513d 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -71,6 +71,9 @@ app.views.Publisher = Backbone.View.extend(_.extend( createStatusMessage : function(evt) { if(evt){ evt.preventDefault(); } + //add missing mentions at end of post: + this.handleTextchange(); + var serializedForm = $(evt.target).closest("form").serializeObject(); // lulz this code should be killed. @@ -128,6 +131,9 @@ app.views.Publisher = Backbone.View.extend(_.extend( createPostPreview : function(evt) { if(evt){ evt.preventDefault(); } + //add missing mentions at end of post: + this.handleTextchange(); + var serializedForm = $(evt.target).closest("form").serializeObject(); var photos = new Array(); diff --git a/features/mentions.feature b/features/mentions.feature index ca9311915ac..2b794cb3ce4 100644 --- a/features/mentions.feature +++ b/features/mentions.feature @@ -15,3 +15,22 @@ Feature: Mentions And I am on the home page And I follow "Bob Jones" Then I should see "Bob Jones" + + Scenario: A user mentions another user at the end of a post + Given following users exist: + | username | email | + | Bob Jones | bob@bob.bob | + | Alice Smith | alice@alice.alice | + And a user with email "bob@bob.bob" is connected with "alice@alice.alice" + When I sign in as "alice@alice.alice" + And I am on the home page + And I expand the publisher + When I fill in the following: + | status_message_fake_text | @Bo | + And I click on the first user in the mentions dropdown list + And I press "Share" + And I wait for the ajax to finish + And I follow "Bob Jones" + Then I should see "Bob Jones" + + diff --git a/features/step_definitions/mention_steps.rb b/features/step_definitions/mention_steps.rb index c57af492968..ece64aba5b5 100644 --- a/features/step_definitions/mention_steps.rb +++ b/features/step_definitions/mention_steps.rb @@ -8,4 +8,8 @@ And /^I mention Alice in the publisher$/ do alice = User.find_by_email 'alice@alice.alice' fill_in 'status_message_fake_text', :with => "@{Alice Smith ; #{alice.person.diaspora_handle}}" -end \ No newline at end of file +end + +And /^I click on the first user in the mentions dropdown list$/ do + find('.mentions-autocomplete-list li:first').click +end diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index a8fad7b6628..8f6ddb0c5bf 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -106,7 +106,15 @@ describe("app.views.Publisher", function() { expect(this.view.$("input[name='photos[]']").length).toBe(0); }) }); - + + describe("createStatusMessage", function(){ + it("calls handleTextchange to complete missing mentions", function(){ + spyOn(this.view, "handleTextchange"); + this.view.createStatusMessage($.Event()); + expect(this.view.handleTextchange).toHaveBeenCalled(); + }) + }); + describe("publishing a post with keyboard", function(){ it("should submit the form when shift+enter is pressed", function(){ this.view.render();