Skip to content

Commit

Permalink
fix mentions at the end of a post
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen van Bergerem committed May 17, 2013
1 parent 477c9d2 commit 63040bb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/app/views/publisher_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
19 changes: 19 additions & 0 deletions features/mentions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]" is connected with "[email protected]"
When I sign in as "[email protected]"
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"


6 changes: 5 additions & 1 deletion features/step_definitions/mention_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
And /^I mention Alice in the publisher$/ do
alice = User.find_by_email '[email protected]'
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
10 changes: 9 additions & 1 deletion spec/javascripts/app/views/publisher_view_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 63040bb

Please sign in to comment.