not showing the reshare button to the users on things they can't reshare
This commit is contained in:
parent
fa9269541f
commit
ce94779766
6 changed files with 42 additions and 6 deletions
|
|
@ -28,6 +28,7 @@ module SocketsHelper
|
||||||
post_hash = {:post => object,
|
post_hash = {:post => object,
|
||||||
:author => object.author,
|
:author => object.author,
|
||||||
:photos => object.photos,
|
:photos => object.photos,
|
||||||
|
:reshare => nil,
|
||||||
:comments => object.comments.map{|c|
|
:comments => object.comments.map{|c|
|
||||||
{:comment => c,
|
{:comment => c,
|
||||||
:author => c.author
|
:author => c.author
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
class Reshare < Post
|
class Reshare < Post
|
||||||
belongs_to :root, :class_name => 'Post'
|
belongs_to :root, :class_name => 'Post'
|
||||||
validate :root_must_be_public
|
validate :root_must_be_public
|
||||||
attr_accessible :root_id,
|
attr_accessible :root_id, :public
|
||||||
|
|
||||||
before_validation do
|
before_validation do
|
||||||
self.public = true
|
self.public = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
delegate :photos, :text, :comments, :to => :root
|
delegate :photos, :text, :comments, :to => :root
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,13 @@
|
||||||
- unless (defined?(@commenting_disabled) && @commenting_disabled)
|
- unless (defined?(@commenting_disabled) && @commenting_disabled)
|
||||||
%span.like_action
|
%span.like_action
|
||||||
= like_action(post, current_user)
|
= like_action(post, current_user)
|
||||||
|
|
||||||
|
- unless(post.author_id == current_user.person.id) || (!post.public?)
|
||||||
|
·
|
||||||
|
%span.reshare_action
|
||||||
|
= link_to "Reshare", reshares_path(:root_id => post.id), :method => :post, :remote => true, :confirm => "Reshare: #{post.author.name} - #{post.text}?"
|
||||||
·
|
·
|
||||||
%span.reshare_action
|
|
||||||
= link_to "Reshare", reshares_path(:root_id => post.id), :method => :post, :remote => true, :confirm => "Reshare: #{post.author.name} - #{post.text}?"
|
|
||||||
·
|
|
||||||
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
|
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
|
||||||
|
|
||||||
.likes.on_post
|
.likes.on_post
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
:author => @status_message.author,
|
:author => @status_message.author,
|
||||||
:photos => @status_message.photos,
|
:photos => @status_message.photos,
|
||||||
:comments => [],
|
:comments => [],
|
||||||
:all_aspects => current_user.aspects
|
:all_aspects => current_user.aspects,
|
||||||
|
:reshare => nil
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
:post_id => @status_message.guid}.to_json.html_safe%>
|
:post_id => @status_message.guid}.to_json.html_safe%>
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,30 @@ Feature: public repost
|
||||||
Given a user named "Bob Jones" with email "bob@bob.bob"
|
Given a user named "Bob Jones" with email "bob@bob.bob"
|
||||||
And a user named "Alice Smith" with email "alice@alice.alice"
|
And a user named "Alice Smith" with email "alice@alice.alice"
|
||||||
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
|
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: does not show the reshare button on my own posts
|
||||||
|
And "bob@bob.bob" has a non public post with text "reshare this!"
|
||||||
|
And I sign in as "bob@bob.bob"
|
||||||
|
Then I should not see "Reshare"
|
||||||
|
|
||||||
|
Scenario: does not show a reshare button on other private pots
|
||||||
|
And "bob@bob.bob" has a non public post with text "reshare this!"
|
||||||
|
And I sign in as "alice@alice.alice"
|
||||||
|
Then I should not see "Reshare"
|
||||||
|
|
||||||
|
Scenario: does shows the reshare button on my own posts
|
||||||
|
And "bob@bob.bob" has a public post with text "reshare this!"
|
||||||
|
And I sign in as "alice@alice.alice"
|
||||||
|
Then I should see "Reshare"
|
||||||
|
|
||||||
|
Scenario: shows up on the profile page
|
||||||
And "bob@bob.bob" has a public post with text "reshare this!"
|
And "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"
|
||||||
And I preemptively confirm the alert
|
And I preemptively confirm the alert
|
||||||
And I follow "Reshare"
|
And I follow "Reshare"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
|
|
||||||
Scenario: shows up on the profile page
|
|
||||||
Then I should see a ".reshared"
|
Then I should see a ".reshared"
|
||||||
And I am on "alice@alice.alice"'s page
|
And I am on "alice@alice.alice"'s page
|
||||||
Then I should see "reshare this!"
|
Then I should see "reshare this!"
|
||||||
|
|
@ -22,8 +39,15 @@ Feature: public repost
|
||||||
And I should see "Bob"
|
And I should see "Bob"
|
||||||
|
|
||||||
Scenario: shows up on the aspects page
|
Scenario: shows up on the aspects page
|
||||||
|
And "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
|
||||||
|
|
||||||
Then I should see a ".reshared"
|
Then I should see a ".reshared"
|
||||||
And I follow "All Aspects"
|
And I follow "All Aspects"
|
||||||
Then I should see "reshare this!"
|
Then I should see "reshare this!"
|
||||||
Then I should see a ".reshared"
|
Then I should see a ".reshared"
|
||||||
And I should see "Bob"
|
And I should see "Bob"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,3 +13,9 @@ Given /^"([^"]*)" has a public post with text "([^"]*)"$/ do |email, text|
|
||||||
user = User.find_by_email(email)
|
user = User.find_by_email(email)
|
||||||
user.post(:status_message, :text => text, :public => true, :to => user.aspects)
|
user.post(:status_message, :text => text, :public => true, :to => user.aspects)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given /^"([^"]*)" has a non public post with text "([^"]*)"$/ do |email, text|
|
||||||
|
user = User.find_by_email(email)
|
||||||
|
user.post(:status_message, :text => text, :public => false, :to => user.aspects)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue