discourse/spec/models/moved_post_spec.rb
Mark VanLandingham 9b8af0ea9f
DEV: Create permanent version of moved_posts table from PostMover class (#29664)
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.
2024-11-12 14:35:20 -06:00

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