mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 09:43:48 +08:00
9b8af0ea9f
This is a very simple change, which creates a permanent table in the DB, rather than generating a temporary table when moving posts. This change is about capturing data and any usage will appear in a follow-up. I did include a new column created_new_topic in the new table, so that it can be easily audited without having to compare destination topic created_at with moved_post records.
42 lines
1.2 KiB
Ruby
42 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe MovedPost do
|
|
fab!(:new_topic) { Fabricate(:topic) }
|
|
fab!(:new_post) { Fabricate(:post, topic: new_topic) }
|
|
|
|
fab!(:old_topic) { Fabricate(:topic) }
|
|
fab!(:old_post) { Fabricate(:post, topic: old_topic) }
|
|
|
|
fab!(:moved_post) do
|
|
Fabricate(
|
|
:moved_post,
|
|
new_topic: new_topic,
|
|
new_post: new_post,
|
|
old_topic: old_topic,
|
|
old_post: old_post,
|
|
)
|
|
end
|
|
|
|
describe "Topic & Post associations" do
|
|
it "deletes the MovePost record when new_topic is deleted" do
|
|
new_topic.destroy
|
|
expect { moved_post.reload }.to raise_exception(ActiveRecord::RecordNotFound)
|
|
end
|
|
|
|
it "deletes the MovePost record when old_topic is deleted" do
|
|
old_topic.destroy
|
|
expect { moved_post.reload }.to raise_exception(ActiveRecord::RecordNotFound)
|
|
end
|
|
|
|
it "deletes the MovePost record when new_post is deleted" do
|
|
new_post.destroy
|
|
expect { moved_post.reload }.to raise_exception(ActiveRecord::RecordNotFound)
|
|
end
|
|
|
|
it "deletes the MovePost record when old_post is deleted" do
|
|
old_post.destroy
|
|
expect { moved_post.reload }.to raise_exception(ActiveRecord::RecordNotFound)
|
|
end
|
|
end
|
|
end
|