diff --git a/app/helpers/reshares_helper.rb b/app/helpers/reshares_helper.rb index 5b97adc39..f5131814f 100644 --- a/app/helpers/reshares_helper.rb +++ b/app/helpers/reshares_helper.rb @@ -7,6 +7,15 @@ module ResharesHelper end end + def resharable?(post) + if reshare?(post) + # Reshare post is resharable if you're not the original author nor the resharer + post.root.present? && post.root.author_id != current_user.person.id && post.author_id != current_user.person.id + else + post.author_id != current_user.person.id && post.public? + end + end + def reshare_link(post) if reshare?(post) return unless post.root diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 86961fc31..970793f3a 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -74,7 +74,7 @@ %span.like_action = like_action(post, current_user) - - if (post.author_id != current_user.person.id) && (post.public?) + - if resharable?(post) ยท %span.reshare_action = reshare_link(post) diff --git a/features/reshare.feature b/features/reshare.feature index 4e527dd9c..980a70348 100644 --- a/features/reshare.feature +++ b/features/reshare.feature @@ -23,7 +23,38 @@ Feature: public repost Scenario: I see the reshare button on my contact's public posts Given "bob@bob.bob" has a public post with text "reshare this!" And I sign in as "alice@alice.alice" - Then I should see "Reshare" + Then I should see "Reshare" + + Scenario: I don't see the reshare button on other people's reshare of my post + Given "bob@bob.bob" has a public post with text "reshare this!" + And I sign in as "alice@alice.alice" + And I preemptively confirm the alert + And I follow "Reshare" + And I wait for the ajax to finish + + And I go to the home page + Then I should see a ".reshare" + And I should see "reshare this!" + And I should see "Bob" + + When I go to the destroy user session page + And I sign in as "bob@bob.bob" + And I go to the home page + Then I should see "reshare this!" + And I should not see "Reshare original" + + Scenario: I don't see the reshare button on my reshare post + Given "bob@bob.bob" has a public post with text "reshare this!" + And I sign in as "alice@alice.alice" + And I preemptively confirm the alert + And I follow "Reshare" + And I wait for the ajax to finish + + And I go to the home page + Then I should see a ".reshare" + And I should see "reshare this!" + And I should see "Bob" + And I should not see "Reshare original" Scenario: When I reshare, it shows up on my profile page Given "bob@bob.bob" has a public post with text "reshare this!" @@ -50,7 +81,6 @@ Feature: public repost And I wait for the ajax to finish Then I should see a ".reshare" And I should see "reshare this!" - And I should see a ".reshare" And I should see "Bob" Scenario: I can delete a post that has been reshared @@ -63,7 +93,6 @@ Feature: public repost And I go to the home page Then I should see a ".reshare" And I should see "reshare this!" - And I should see a ".reshare" And I should see "Bob" When I go to the destroy user session page @@ -86,7 +115,6 @@ Feature: public repost When I go to the home page Then I should see a ".reshare" And I should see "reshare this!" - And I should see a ".reshare" And I should see "Bob" When I go to the home page