diff --git a/Changelog.md b/Changelog.md index 83d4678f5..2cdf4d6bb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -57,6 +57,7 @@ The keys will still be available in the root level within the 0.5 release. The o * Updated Weekly User Stats admin page to show data for the most recent week including reversing the order of the weeks in the drop down to show the most recent. [#5331](https://github.com/diaspora/diaspora/pull/5331) * Convert some cukes to rspec tests [#5289](https://github.com/diaspora/diaspora/pull/5289) * Hidden overflow for long names on tag pages [#5279](https://github.com/diaspora/diaspora/pull/5279) +* Always reshare absolute root of a post [#5276](https://github.com/diaspora/diaspora/pull/5276) ## Bug fixes * orca cannot see 'Add Contact' button [#5158](https://github.com/diaspora/diaspora/pull/5158) diff --git a/app/controllers/reshares_controller.rb b/app/controllers/reshares_controller.rb index 7fc4e815f..1e49a5aa0 100644 --- a/app/controllers/reshares_controller.rb +++ b/app/controllers/reshares_controller.rb @@ -3,7 +3,13 @@ class ResharesController < ApplicationController respond_to :json def create - @reshare = current_user.build_post(:reshare, :root_guid => params[:root_guid]) + post = Post.where(:guid => params[:root_guid]).first + if post.is_a? Reshare + @reshare = current_user.build_post(:reshare, :root_guid => post.absolute_root.guid) + else + @reshare = current_user.build_post(:reshare, :root_guid => params[:root_guid]) + end + if @reshare.save current_user.add_to_streams(@reshare, current_user.aspects) current_user.dispatch_post(@reshare, :url => post_url(@reshare), :additional_subscribers => @reshare.root_author) diff --git a/spec/controllers/reshares_controller_spec.rb b/spec/controllers/reshares_controller_spec.rb index aa21badae..8f9090784 100644 --- a/spec/controllers/reshares_controller_spec.rb +++ b/spec/controllers/reshares_controller_spec.rb @@ -54,6 +54,19 @@ describe ResharesController, :type => :controller do expect(response.body.strip).to be_empty end end + + context 'resharing another user\'s reshare' do + before do + @root = @post + @post = FactoryGirl.create(:reshare, :root => @root, :author => alice.person) + end + + it 'reshares the absolute root' do + post_request! + expect(@post.reshares.count).to eq(0) + expect(@root.reshares.count).to eq(2) + end + end end end end