Refacor files namespaces
This commit is contained in:
parent
9b19be18f2
commit
67f8ba5d57
11 changed files with 89 additions and 9 deletions
|
|
@ -20,7 +20,7 @@ app.collections.Comments = Backbone.Collection.extend({
|
||||||
comment.set({author: app.currentUser.toJSON(), parent: self.post });
|
comment.set({author: app.currentUser.toJSON(), parent: self.post });
|
||||||
|
|
||||||
// Need interactions after make
|
// Need interactions after make
|
||||||
comment.interactions = new app.models.Post.LikeInteractions(
|
comment.interactions = new app.models.LikeInteractions(
|
||||||
_.extend({comment: comment, post: self.post}, comment.get("interactions"))
|
_.extend({comment: comment, post: self.post}, comment.get("interactions"))
|
||||||
);
|
);
|
||||||
self.add(comment);
|
self.add(comment);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ app.models.Comment = Backbone.Model.extend({
|
||||||
initialize: function(model, options) {
|
initialize: function(model, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.post = model.post || options.post || this.collection.post;
|
this.post = model.post || options.post || this.collection.post;
|
||||||
this.interactions = new app.models.Post.LikeInteractions(
|
this.interactions = new app.models.LikeInteractions(
|
||||||
_.extend({comment: this, post: this.post}, this.get("interactions"))
|
_.extend({comment: this, post: this.post}, this.get("interactions"))
|
||||||
);
|
);
|
||||||
this.likes = this.interactions.likes;
|
this.likes = this.interactions.likes;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// This class contains code extracted from interactions.js to factorize likes management between posts and comments
|
// This class contains code extracted from interactions.js to factorize likes management between posts and comments
|
||||||
|
|
||||||
app.models.Post.LikeInteractions = Backbone.Model.extend({
|
app.models.LikeInteractions = Backbone.Model.extend({
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.likes = new app.collections.Likes(this.get("likes"), options);
|
this.likes = new app.collections.Likes(this.get("likes"), options);
|
||||||
|
|
@ -4,7 +4,7 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin,
|
||||||
urlRoot : "/posts",
|
urlRoot : "/posts",
|
||||||
|
|
||||||
initialize : function() {
|
initialize : function() {
|
||||||
this.interactions = new app.models.Post.Interactions(_.extend({post : this}, this.get("interactions")));
|
this.interactions = new app.models.PostInteractions(_.extend({post: this}, this.get("interactions")));
|
||||||
this.delegateToInteractions();
|
this.delegateToInteractions();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
|
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
|
||||||
|
|
||||||
//= require ./like_interactions
|
app.models.PostInteractions = app.models.LikeInteractions.extend({
|
||||||
|
|
||||||
app.models.Post.Interactions = app.models.Post.LikeInteractions.extend({
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
app.models.Post.LikeInteractions.prototype.initialize.apply(this, arguments);
|
app.models.LikeInteractions.prototype.initialize.apply(this, arguments);
|
||||||
this.post = options.post;
|
this.post = options.post;
|
||||||
this.comments = new app.collections.Comments(this.get("comments"), {post: this.post});
|
this.comments = new app.collections.Comments(this.get("comments"), {post: this.post});
|
||||||
this.reshares = new app.collections.Reshares(this.get("reshares"), {post: this.post});
|
this.reshares = new app.collections.Reshares(this.get("reshares"), {post: this.post});
|
||||||
|
|
@ -52,6 +52,8 @@
|
||||||
|
|
||||||
$.post(form.attr("action") + "?format=mobile", form.serialize(), function(data){
|
$.post(form.attr("action") + "?format=mobile", form.serialize(), function(data){
|
||||||
Diaspora.Mobile.Comments.updateStream(form, data);
|
Diaspora.Mobile.Comments.updateStream(form, data);
|
||||||
|
// Register new comments
|
||||||
|
$(".stream").trigger("comments.loaded");
|
||||||
}, "html").fail(function(response) {
|
}, "html").fail(function(response) {
|
||||||
Diaspora.Mobile.Alert.handleAjaxError(response);
|
Diaspora.Mobile.Alert.handleAjaxError(response);
|
||||||
Diaspora.Mobile.Comments.resetCommentBox(form);
|
Diaspora.Mobile.Comments.resetCommentBox(form);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class CommentPresenter < BasePresenter
|
||||||
author: PersonPresenter.new(author).as_api_json,
|
author: PersonPresenter.new(author).as_api_json,
|
||||||
created_at: created_at,
|
created_at: created_at,
|
||||||
mentioned_people: build_mentioned_people_json,
|
mentioned_people: build_mentioned_people_json,
|
||||||
reported: current_user.present? && reports.where(user: current_user).exists?,
|
reported: current_user.present? && reports.exists?(user: current_user),
|
||||||
interactions: build_interactions_json
|
interactions: build_interactions_json
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -86,3 +86,14 @@ Feature: commenting
|
||||||
|
|
||||||
When I click on selector ".toggle_post_comments"
|
When I click on selector ".toggle_post_comments"
|
||||||
Then I should see "Comment 2"
|
Then I should see "Comment 2"
|
||||||
|
|
||||||
|
Scenario: Like a comment in stream view
|
||||||
|
When "alice@alice.alice" has commented "That's cool" on "Look at this dog"
|
||||||
|
And I am on "alice@alice.alice"'s page
|
||||||
|
And I like the comment "That's cool"
|
||||||
|
Then I should see a heart within comment "That's cool"
|
||||||
|
|
||||||
|
When I expand likes within comment "That's cool"
|
||||||
|
Then I should see a micro avatar within comment "That's cool"
|
||||||
|
When I unlike comment "That's cool"
|
||||||
|
Then I should not see a micro avatar within comment "That's cool"
|
||||||
|
|
|
||||||
|
|
@ -43,3 +43,14 @@ Feature: reactions mobile post
|
||||||
And I click on selector "a.comment-action"
|
And I click on selector "a.comment-action"
|
||||||
And I confirm the alert after I click on selector "a.remove"
|
And I confirm the alert after I click on selector "a.remove"
|
||||||
Then I should see "0 comments" within ".show-comments"
|
Then I should see "0 comments" within ".show-comments"
|
||||||
|
|
||||||
|
Scenario: liking and unliking a comment
|
||||||
|
When I click on selector "a.comment-action.inactive"
|
||||||
|
And I fill in the following:
|
||||||
|
| text | is that a poodle? |
|
||||||
|
And I press "Comment"
|
||||||
|
Then I should see "is that a poodle?" within ".comment-container"
|
||||||
|
When I toggle like on comment with text "is that a poodle?"
|
||||||
|
Then I should see a like on comment with text "is that a poodle?"
|
||||||
|
When I toggle like on comment with text "is that a poodle?"
|
||||||
|
Then I should see an unliked comment with text "is that a poodle?"
|
||||||
|
|
|
||||||
|
|
@ -44,3 +44,38 @@ end
|
||||||
When /^I enter "([^"]*)" in the comment field$/ do |comment_text|
|
When /^I enter "([^"]*)" in the comment field$/ do |comment_text|
|
||||||
find("textarea.comment-box.mention-textarea").native.send_keys(comment_text)
|
find("textarea.comment-box.mention-textarea").native.send_keys(comment_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^I like the comment "([^"]*)"$/ do |comment_text|
|
||||||
|
comment_guid = Comment.find_by(text: comment_text).guid
|
||||||
|
# Find like like-link within comment-block
|
||||||
|
find(id: comment_guid).click_link("Like")
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should see a heart within comment "([^"]*)"$/ do |comment_text|
|
||||||
|
comment_guid = Comment.find_by(text: comment_text).guid
|
||||||
|
block = find(id: comment_guid)
|
||||||
|
expect(block).to have_css(".entypo-heart")
|
||||||
|
end
|
||||||
|
|
||||||
|
When /^I expand likes within comment "([^"]*)"$/ do |comment_text|
|
||||||
|
comment_guid = Comment.find_by(text: comment_text).guid
|
||||||
|
find(id: comment_guid).click_link("1 Like")
|
||||||
|
find(id: comment_guid).find(".entypo-heart").hover # unfocus avatar to get rid of tooltip
|
||||||
|
end
|
||||||
|
|
||||||
|
When /^I unlike comment "([^"]*)"$/ do |comment_text|
|
||||||
|
comment_guid = Comment.find_by(text: comment_text).guid
|
||||||
|
find(id: comment_guid).click_link("Unlike")
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should see a micro avatar within comment "([^"]*)"$/ do |comment_text|
|
||||||
|
comment_guid = Comment.find_by(text: comment_text).guid
|
||||||
|
block = find(id: comment_guid)
|
||||||
|
expect(block).to have_css(".micro.avatar")
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should not see a micro avatar within comment "([^"]*)"$/ do |comment_text|
|
||||||
|
comment_guid = Comment.find_by(text: comment_text).guid
|
||||||
|
block = find(id: comment_guid)
|
||||||
|
expect(block).not_to have_css(".micro.avatar")
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,26 @@ Then /^the aspect dropdown within "([^"]*)" should be labeled "([^"]*)"/ do |sel
|
||||||
current_scope.should have_css("option.list_cover", text: label)
|
current_scope.should have_css("option.list_cover", text: label)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I toggle like on comment with text "([^"]*)"$/ do |comment_text|
|
||||||
|
comment_guid = Comment.find_by(text: comment_text).guid
|
||||||
|
within(id: comment_guid) do
|
||||||
|
find(".entypo-heart.like-action").click
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should see a like on comment with text "([^"]*)"$/ do |comment_text|
|
||||||
|
comment_guid = Comment.find_by(text: comment_text).guid
|
||||||
|
within(id: comment_guid) do
|
||||||
|
find(".entypo-heart.like-action.active")
|
||||||
|
expect(find(".count.like-count")).to have_text "1"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^I should see an unliked comment with text "([^"]*)"$/ do |comment_text|
|
||||||
|
comment_guid = Comment.find_by(text: comment_text).guid
|
||||||
|
within(id: comment_guid) do
|
||||||
|
find(".entypo-heart.like-action.inactive")
|
||||||
|
expect(find(".count.like-count")).to have_text "0"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue