Loading Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ * Remove Internet Explorer workarounds [#7557](https://github.com/diaspora/diaspora/pull/7557) * Sort notifications by last interaction [#7568](https://github.com/diaspora/diaspora/pull/7568) * Remove tiff support from photos [#7576](https://github.com/diaspora/diaspora/pull/7576) * Remove reference from reshares when original post is deleted [#7578](https://github.com/diaspora/diaspora/pull/7578) ## Bug fixes * Fix displaying polls with long answers [#7579](https://github.com/diaspora/diaspora/pull/7579) Loading app/models/post.rb +4 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ class Post < ApplicationRecord self.touch(:interacted_at) end before_destroy do reshares.update_all(root_guid: nil) # rubocop:disable Rails/SkipsModelValidations end #scopes scope :includes_for_a_stream, -> { includes(:o_embed_cache, Loading db/migrate/20170824202628_cleanup_root_guids_from_reshares.rb 0 → 100644 +9 −0 Original line number Diff line number Diff line class CleanupRootGuidsFromReshares < ActiveRecord::Migration[5.1] def up # rubocop:disable Rails/SkipsModelValidations Reshare.joins("LEFT OUTER JOIN posts as root ON root.guid = posts.root_guid") .where("root.id is NULL AND posts.root_guid is NOT NULL") .update_all(root_guid: nil) # rubocop:enable Rails/SkipsModelValidations end end spec/models/post_spec.rb +9 −0 Original line number Diff line number Diff line Loading @@ -387,4 +387,13 @@ describe Post, :type => :model do expect(post.interacted_at).not_to be_blank end end describe "#before_destroy" do it "removes root_guid from reshares" do post = FactoryGirl.create(:status_message, author: alice.person, public: true) reshare = FactoryGirl.create(:reshare, author: bob.person, root: post) post.destroy! expect(reshare.reload.root_guid).to be_nil end end end Loading
Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ * Remove Internet Explorer workarounds [#7557](https://github.com/diaspora/diaspora/pull/7557) * Sort notifications by last interaction [#7568](https://github.com/diaspora/diaspora/pull/7568) * Remove tiff support from photos [#7576](https://github.com/diaspora/diaspora/pull/7576) * Remove reference from reshares when original post is deleted [#7578](https://github.com/diaspora/diaspora/pull/7578) ## Bug fixes * Fix displaying polls with long answers [#7579](https://github.com/diaspora/diaspora/pull/7579) Loading
app/models/post.rb +4 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ class Post < ApplicationRecord self.touch(:interacted_at) end before_destroy do reshares.update_all(root_guid: nil) # rubocop:disable Rails/SkipsModelValidations end #scopes scope :includes_for_a_stream, -> { includes(:o_embed_cache, Loading
db/migrate/20170824202628_cleanup_root_guids_from_reshares.rb 0 → 100644 +9 −0 Original line number Diff line number Diff line class CleanupRootGuidsFromReshares < ActiveRecord::Migration[5.1] def up # rubocop:disable Rails/SkipsModelValidations Reshare.joins("LEFT OUTER JOIN posts as root ON root.guid = posts.root_guid") .where("root.id is NULL AND posts.root_guid is NOT NULL") .update_all(root_guid: nil) # rubocop:enable Rails/SkipsModelValidations end end
spec/models/post_spec.rb +9 −0 Original line number Diff line number Diff line Loading @@ -387,4 +387,13 @@ describe Post, :type => :model do expect(post.interacted_at).not_to be_blank end end describe "#before_destroy" do it "removes root_guid from reshares" do post = FactoryGirl.create(:status_message, author: alice.person, public: true) reshare = FactoryGirl.create(:reshare, author: bob.person, root: post) post.destroy! expect(reshare.reload.root_guid).to be_nil end end end