diff --git a/Changelog.md b/Changelog.md index 66147347088..44aba5be2e4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ * Do not fail on receiving a SignedRetraction via the public route * Pass the real values to stderr_path and stdout_path in unicorn.rb since it runs a case statement on them. * Decode tag name before passing it into a TagFollowingAction [#4027](https://github.com/diaspora/diaspora/issues/4027) +* Fix reshares in single post-view [#4056](https://github.com/diaspora/diaspora/issues/4056) ## Refactor diff --git a/app/assets/javascripts/app/models/post/interactions.js b/app/assets/javascripts/app/models/post/interactions.js index d510ca8b5e6..1d78da1c910 100644 --- a/app/assets/javascripts/app/models/post/interactions.js +++ b/app/assets/javascripts/app/models/post/interactions.js @@ -125,7 +125,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ , publicPost = this.post.get("public") , userIsNotAuthor = this.post.get("author").diaspora_id != app.currentUser.get("diaspora_id") , userIsNotRootAuthor = rootExists && (isReshare ? this.post.get("root").author.diaspora_id != app.currentUser.get("diaspora_id") : true) - , notReshared = this.reshares.length === 0; + , notReshared = !this.userReshare(); return publicPost && app.currentUser.authenticated() && userIsNotAuthor && userIsNotRootAuthor && notReshared; } diff --git a/features/reshare.feature b/features/reshare.feature index aed7cb7119b..9a361f10d65 100644 --- a/features/reshare.feature +++ b/features/reshare.feature @@ -9,6 +9,7 @@ Feature: public repost | username | email | | Bob Jones | bob@bob.bob | | Alice Smith | alice@alice.alice | + | Eve Doe | eve@eve.eve | And a user with email "bob@bob.bob" is connected with "alice@alice.alice" Scenario: Resharing a post from a single post page @@ -23,6 +24,19 @@ Feature: public repost Then I should see a flash message indicating success And I should see a flash message containing "successfully" + Scenario: Resharing a post from a single post page that is reshared + Given "bob@bob.bob" has a public post with text "reshare this!" + And the post with text "reshare this!" is reshared by "eve@eve.eve" + And I sign in as "alice@alice.alice" + And I am on "bob@bob.bob"'s page + And I follow "Last Post" + + And I preemptively confirm the alert + And I click on selector "a.reshare" + And I wait for the ajax to finish + Then I should see a flash message indicating success + And I should see a flash message containing "successfully" + # should be covered in rspec, so testing that the post is added to # app.stream in jasmine should be enough coverage Scenario: When I reshare, it shows up on my profile page diff --git a/features/step_definitions/posts_steps.rb b/features/step_definitions/posts_steps.rb index 8282b09e513..764944cde01 100644 --- a/features/step_definitions/posts_steps.rb +++ b/features/step_definitions/posts_steps.rb @@ -32,6 +32,11 @@ user.post(:status_message, :text => text, :public => false, :to => user.aspects) end +And /^the post with text "([^"]*)" is reshared by "([^"]*)"$/ do |text, email| + user = User.find_by_email(email) + root = Post.find_by_text(text) + user.post(:reshare, :root_guid => root.guid, :public => true, :to => user.aspects) +end When /^The user deletes their first post$/ do @me.posts.first.destroy