Move tag prefill to Backbone, add tests

This commit is contained in:
Steffen van Bergerem 2014-11-30 14:15:35 +01:00
parent b01026f9b8
commit f6fbbbb5f6
9 changed files with 61 additions and 8 deletions

View file

@ -106,6 +106,7 @@ app.Router = Backbone.Router.extend({
{tagText: decodeURIComponent(name).toLowerCase()}
);
$("#author_info").prepend(followedTagsAction.render().el)
app.tags = new app.views.Tags({tagName: name});
}
this._hideInactiveStreamLists();
},

View file

@ -149,6 +149,7 @@ app.views.Publisher = Backbone.View.extend({
setText: function(txt) {
this.el_input.val(txt);
this.el_hiddenInput.val(txt);
this.prefillText = txt;
this.el_input.trigger('input');
this.handleTextchange();
@ -482,7 +483,7 @@ app.views.Publisher = Backbone.View.extend({
},
_beforeUnload: function(e) {
if(this._submittable()){
if(this._submittable() && this.el_input.val() != this.prefillText){
var confirmationMessage = Diaspora.I18n.t("confirm_unload");
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome, etc.

View file

@ -0,0 +1,10 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
app.views.Tags = Backbone.View.extend({
initialize: function(opts) {
app.publisher.setText("#"+ this.tagName + " ");
}
});
// @license-end

View file

@ -25,7 +25,7 @@
%br
%h4
= t('invitaitons.new.language')
= t('invitations.new.language')
= select_tag('email_inviter[locale]', options_from_collection_for_select(available_language_options, "second", "first", :selected => current_user.language))
%br

View file

@ -1240,7 +1240,6 @@ en:
tags:
title: "Posts tagged: %{tags}"
contacts_title: "People who dig this tag"
tag_prefill_text: "%{tag_name} "
public:
title: "Public Activity"

View file

@ -13,6 +13,7 @@ Feature: invitation acceptance
And I follow "awesome_button"
And I confirm the alert
Then I should be on the stream page
And I close the publisher
Scenario: accept invitation from user
Given I have been invited by bob
@ -27,6 +28,7 @@ Feature: invitation acceptance
And I follow "awesome_button"
And I confirm the alert
Then I should be on the stream page
And I close the publisher
And I log out
And I sign in as "bob@bob.bob"
And I follow "By email"

View file

@ -0,0 +1,24 @@
@javascript
Feature: Posting from the tag page
In order to share my opinion on cats
I want to post from the tag page
Background:
Given I am on the home page
And a user with username "alice"
When I sign in as "alice@alice.alice"
And I am on the tag page for "cats"
Scenario: posting some text
Given I expand the publisher
And I have turned off jQuery effects
And I append "I like cats." to the publisher
And I press "Share"
Then "#cats I like cats." should be post 1
When I am on the home page
Then "#cats I like cats." should be post 1
When I am on the tag page for "cats"
Then "#cats I like cats." should be post 1

View file

@ -14,6 +14,7 @@ Feature: new user registration
And I follow "awesome_button"
And I confirm the alert
Then I should be on the stream page
And I close the publisher
And I should not see "awesome_button"
Scenario: new user tries to XSS itself
@ -36,6 +37,24 @@ Feature: new user registration
When I follow "awesome_button"
And I confirm the alert
Then I should be on the stream page
And I close the publisher
Scenario: new user without any tags posts first status message
When I follow "awesome_button"
And I confirm the alert
Then I should be on the stream page
When I submit the publisher
Then "Hey everyone, I'm #NewHere." should be post 1
Scenario: new user with some tags posts first status message
When I fill in the following:
| profile_first_name | some name |
And I fill in "tags" with "#rockstar"
And I press the first ".as-result-item" within "#as-results-tags"
And I follow "awesome_button"
Then I should be on the stream page
When I submit the publisher
Then "Hey everyone, I'm #NewHere. I'm interested in #rockstar." should be post 1
Scenario: closing a popover clears getting started
When I follow "awesome_button"
@ -44,6 +63,7 @@ Feature: new user registration
And I have turned off jQuery effects
And I wait for the popovers to appear
And I click close on all the popovers
And I close the publisher
Then I should not see "Welcome to diaspora*"
Scenario: user fills in bogus data - client side validation

View file

@ -38,13 +38,9 @@ class Stream::Tag < Stream::Base
private
def tag_prefill_text
I18n.translate('streams.tags.tag_prefill_text', :tag_name => display_tag_name)
end
# @return [Hash]
def publisher_opts
{:prefill => "#{tag_prefill_text}", :open => true}
{:open => true}
end
def construct_post_query