fix mentions at the end of a post

This commit is contained in:
Steffen van Bergerem 2013-05-16 17:51:48 +02:00
parent 477c9d2ef3
commit 63040bb8cc
5 changed files with 40 additions and 2 deletions

View file

@ -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

View file

@ -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();

View file

@ -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"

View file

@ -8,4 +8,8 @@ end
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
end
And /^I click on the first user in the mentions dropdown list$/ do
find('.mentions-autocomplete-list li:first').click
end

View file

@ -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();