Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider 9a2cb151 rédigé par Steffen van Bergerem's avatar Steffen van Bergerem Validation de Dennis Schubert
Parcourir les fichiers

Set participations client side when changing post interactions

closes #7040
parent 02742a4a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -6,10 +6,11 @@
* Make the session cookies HttpOnly again [#7041](https://github.com/diaspora/diaspora/pull/7041)
## Bug fixes
* Post comments no longer get collapsed when interacting with a post [#7045](https://github.com/diaspora/diaspora/pull/7045)
* Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
## Features
* The "subscribe" indicator on a post now gets toggled when you like or rehsare a post [#7045](https://github.com/diaspora/diaspora/pull/7045)
* Deleted comments will be removed when loading more comments [#7045](https://github.com/diaspora/diaspora/pull/7045)
* The "subscribe" indicator on a post now gets toggled when you like or rehsare a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
# 0.6.0.0
......
......@@ -67,6 +67,7 @@ app.models.Post.Interactions = Backbone.Model.extend({
var self = this;
this.likes.create({}, {
success: function() {
self.post.set({participation: true});
self.trigger("change");
self.set({"likes_count" : self.get("likes_count") + 1});
},
......@@ -94,6 +95,7 @@ app.models.Post.Interactions = Backbone.Model.extend({
this.comments.make(text).fail(function () {
app.flashMessages.error(Diaspora.I18n.t("failed_to_comment"));
}).done(function() {
self.post.set({participation: true});
self.trigger('change'); //updates after sync
});
......@@ -109,6 +111,7 @@ app.models.Post.Interactions = Backbone.Model.extend({
.done(function(reshare) {
app.flashMessages.success(Diaspora.I18n.t("reshares.successful"));
interactions.reshares.add(reshare);
interactions.post.set({participation: true});
if (app.stream && /^\/(?:stream|activity|aspects)/.test(app.stream.basePath())) {
app.stream.addNow(reshare);
}
......
......@@ -14,9 +14,11 @@ Feature: Liking posts
And I sign in as "alice@alice.alice"
Scenario: Liking and unliking a post from the stream
Then I should not have activated notifications for the post
When I like the post "I like unicorns" in the stream
Then I should see "Unlike" within ".stream_element .feedback"
And I should see a ".likes .media" within "#main_stream .stream_element"
And I should have activated notifications for the post
When I unlike the post "I like unicorns" in the stream
Then I should see "Like" within ".stream_element .feedback"
......@@ -25,8 +27,10 @@ Feature: Liking posts
Scenario: Liking and unliking a post from a single post page
When I open the show page of the "I like unicorns" post
And I click to like the post
Then I should not have activated notifications for the post in the single post view
When I click to like the post
Then I should see a ".count" within "#single-post-interactions"
And I should have activated notifications for the post in the single post view
When I click to unlike the post
Then I should not see a ".count" within "#single-post-interactions"
......
......@@ -5,3 +5,14 @@ end
When /^I filter notifications by mentions$/ do
step %(I follow "Mentioned" within "#notifications_container .list-group")
end
Then /^I should( not)? have activated notifications for the post( in the single post view)?$/ do |negate, spv|
selector = spv ? "#single-post-moderation" : "#main_stream .stream_element"
if negate
expect(find(selector, match: :first)).to have_no_css(".destroy_participation", visible: false)
expect(find(selector, match: :first)).to have_css(".create_participation", visible: false)
else
expect(find(selector, match: :first)).to have_css(".destroy_participation", visible: false)
expect(find(selector, match: :first)).to have_no_css(".create_participation", visible: false)
end
end
describe("app.models.Post.Interactions", function(){
var ajaxSuccess = {status: 200, responseText: "{\"id\": 1}"};
beforeEach(function(){
this.interactions = factory.post().interactions;
this.post = factory.post();
this.interactions = this.post.interactions;
this.author = factory.author({guid: "loggedInAsARockstar"});
loginAs({guid: "loggedInAsARockstar"});
......@@ -30,6 +33,13 @@ describe("app.models.Post.Interactions", function(){
this.interactions.like();
expect(this.interactions.likes.length).toEqual(1);
});
it("sets the participation flag for the post", function() {
expect(this.post.get("participation")).toBeFalsy();
this.interactions.like();
jasmine.Ajax.requests.mostRecent().respondWith(ajaxSuccess);
expect(this.post.get("participation")).toBeTruthy();
});
});
describe("unlike", function(){
......@@ -42,8 +52,6 @@ describe("app.models.Post.Interactions", function(){
});
describe("reshare", function() {
var ajaxSuccess = { status: 200, responseText: "{\"id\": 1}" };
beforeEach(function(){
this.reshare = this.interactions.post.reshare();
});
......@@ -81,6 +89,13 @@ describe("app.models.Post.Interactions", function(){
expect(app.stream.addNow).not.toHaveBeenCalled();
});
});
it("sets the participation flag for the post", function() {
expect(this.post.get("participation")).toBeFalsy();
this.interactions.reshare();
jasmine.Ajax.requests.mostRecent().respondWith(ajaxSuccess);
expect(this.post.get("participation")).toBeTruthy();
});
});
describe("userLike", function(){
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter