diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index eaa246585..799d7f36d 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -28,6 +28,7 @@ module SocketsHelper post_hash = {:post => object, :author => object.author, :photos => object.photos, + :reshare => nil, :comments => object.comments.map{|c| {:comment => c, :author => c.author diff --git a/app/models/reshare.rb b/app/models/reshare.rb index 2b0366518..05f29367f 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -1,12 +1,13 @@ class Reshare < Post belongs_to :root, :class_name => 'Post' validate :root_must_be_public - attr_accessible :root_id, + attr_accessible :root_id, :public before_validation do self.public = true end + delegate :photos, :text, :comments, :to => :root private diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 0a2049f31..6f83771c8 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -59,10 +59,13 @@ - unless (defined?(@commenting_disabled) && @commenting_disabled) %span.like_action = 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' .likes.on_post diff --git a/app/views/status_messages/create.js.erb b/app/views/status_messages/create.js.erb index 02965ff00..7d2d2a0eb 100644 --- a/app/views/status_messages/create.js.erb +++ b/app/views/status_messages/create.js.erb @@ -5,7 +5,8 @@ :author => @status_message.author, :photos => @status_message.photos, :comments => [], - :all_aspects => current_user.aspects + :all_aspects => current_user.aspects, + :reshare => nil } ), :post_id => @status_message.guid}.to_json.html_safe%> diff --git a/features/repost.feature b/features/repost.feature index 1be45daaf..a54e1e798 100644 --- a/features/repost.feature +++ b/features/repost.feature @@ -8,13 +8,30 @@ Feature: public repost 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 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 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 - Scenario: shows up on the profile page Then I should see a ".reshared" And I am on "alice@alice.alice"'s page Then I should see "reshare this!" @@ -22,8 +39,15 @@ Feature: public repost And I should see "Bob" 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" And I follow "All Aspects" Then I should see "reshare this!" Then I should see a ".reshared" And I should see "Bob" + diff --git a/features/step_definitions/posts_steps.rb b/features/step_definitions/posts_steps.rb index 6e3661333..d9879e72a 100644 --- a/features/step_definitions/posts_steps.rb +++ b/features/step_definitions/posts_steps.rb @@ -13,3 +13,9 @@ Given /^"([^"]*)" has a public post with text "([^"]*)"$/ do |email, text| user = User.find_by_email(email) user.post(:status_message, :text => text, :public => true, :to => user.aspects) 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 +