diff --git a/Changelog.md b/Changelog.md index fa44e79ee76d4347174880e58da46c6efeaea169..36a68d14f579824eb2b087e9cbea94305960fc21 100644 --- a/Changelog.md +++ b/Changelog.md @@ -44,6 +44,7 @@ The default for including jQuery from a CDN has changed. If you want to continue * Pull punycode.js from rails-assets.org [#5263](https://github.com/diaspora/diaspora/pull/5263) * Redesign profile page and port to Bootstrap [#4657](https://github.com/diaspora/diaspora/pull/4657) * Unify stream selection links in the left sidebar [#5271](https://github.com/diaspora/diaspora/pull/5271) +* 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 7fc4e815f09da2fb7e2a3db0b9b2eb072c0eb045..1e49a5aa005294980e1bbccc0b39ed59c4c3a681 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 aa21badaeaf9c2e418a7c9900ec5254529d09a71..8f90907844ad5609399b089c95d23ed6e3f31edc 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