Don't allow to reshare someone else's rehare of your post. Fixes #2214.
This commit is contained in:
parent
11a59b933f
commit
63f0dac922
3 changed files with 42 additions and 5 deletions
|
|
@ -7,6 +7,15 @@ module ResharesHelper
|
||||||
end
|
end
|
||||||
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)
|
def reshare_link(post)
|
||||||
if reshare?(post)
|
if reshare?(post)
|
||||||
return unless post.root
|
return unless post.root
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
%span.like_action
|
%span.like_action
|
||||||
= like_action(post, current_user)
|
= like_action(post, current_user)
|
||||||
|
|
||||||
- if (post.author_id != current_user.person.id) && (post.public?)
|
- if resharable?(post)
|
||||||
·
|
·
|
||||||
%span.reshare_action
|
%span.reshare_action
|
||||||
= reshare_link(post)
|
= reshare_link(post)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,38 @@ Feature: public repost
|
||||||
Scenario: I see the reshare button on my contact's public posts
|
Scenario: I see the reshare button on my contact's public posts
|
||||||
Given "bob@bob.bob" has a public post with text "reshare this!"
|
Given "bob@bob.bob" has a public post with text "reshare this!"
|
||||||
And I sign in as "alice@alice.alice"
|
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
|
Scenario: When I reshare, it shows up on my profile page
|
||||||
Given "bob@bob.bob" has a public post with text "reshare this!"
|
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
|
And I wait for the ajax to finish
|
||||||
Then I should see a ".reshare"
|
Then I should see a ".reshare"
|
||||||
And I should see "reshare this!"
|
And I should see "reshare this!"
|
||||||
And I should see a ".reshare"
|
|
||||||
And I should see "Bob"
|
And I should see "Bob"
|
||||||
|
|
||||||
Scenario: I can delete a post that has been reshared
|
Scenario: I can delete a post that has been reshared
|
||||||
|
|
@ -63,7 +93,6 @@ Feature: public repost
|
||||||
And I go to the home page
|
And I go to the home page
|
||||||
Then I should see a ".reshare"
|
Then I should see a ".reshare"
|
||||||
And I should see "reshare this!"
|
And I should see "reshare this!"
|
||||||
And I should see a ".reshare"
|
|
||||||
And I should see "Bob"
|
And I should see "Bob"
|
||||||
|
|
||||||
When I go to the destroy user session page
|
When I go to the destroy user session page
|
||||||
|
|
@ -86,7 +115,6 @@ Feature: public repost
|
||||||
When I go to the home page
|
When I go to the home page
|
||||||
Then I should see a ".reshare"
|
Then I should see a ".reshare"
|
||||||
And I should see "reshare this!"
|
And I should see "reshare this!"
|
||||||
And I should see a ".reshare"
|
|
||||||
And I should see "Bob"
|
And I should see "Bob"
|
||||||
|
|
||||||
When I go to the home page
|
When I go to the home page
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue