mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: PostRevisor helper methods to track topic title and raw revisions (#21918)
Not all revisions involve changes to the actual post/topic content. We may want to know if a revisions includes the topic title or post raw. Specifically introducing these for use in the Akismet plugin to conditionally queue checks.
This commit is contained in:
@@ -322,6 +322,7 @@ RSpec.describe PostRevisor do
|
||||
subject.revise!(admin, raw: "new post body", tags: ["new-tag"])
|
||||
expect(post.topic.reload.tags.map(&:name)).to contain_exactly("new-tag")
|
||||
expect(post.post_revisions.reload.size).to eq(1)
|
||||
expect(subject.raw_changed?).to eq(true)
|
||||
|
||||
subject.revise!(admin, raw: old_raw, tags: [])
|
||||
expect(post.topic.reload.tags.map(&:name)).to be_empty
|
||||
@@ -968,6 +969,8 @@ RSpec.describe PostRevisor do
|
||||
post.reload
|
||||
expect(post.topic.title).to eq(new_title)
|
||||
expect(post.revisions.first.modifications["title"][1]).to eq(new_title)
|
||||
expect(subject.topic_title_changed?).to eq(true)
|
||||
expect(subject.raw_changed?).to eq(false)
|
||||
end
|
||||
|
||||
it "revises and tracks changes of topic archetypes" do
|
||||
@@ -983,17 +986,21 @@ RSpec.describe PostRevisor do
|
||||
post.reload
|
||||
expect(post.topic.archetype).to eq(new_archetype)
|
||||
expect(post.revisions.first.modifications["archetype"][1]).to eq(new_archetype)
|
||||
expect(subject.raw_changed?).to eq(false)
|
||||
end
|
||||
|
||||
it "revises and tracks changes of topic tags" do
|
||||
subject.revise!(admin, tags: ["new-tag"])
|
||||
expect(post.post_revisions.last.modifications).to eq("tags" => [[], ["new-tag"]])
|
||||
expect(subject.raw_changed?).to eq(false)
|
||||
|
||||
subject.revise!(admin, tags: %w[new-tag new-tag-2])
|
||||
expect(post.post_revisions.last.modifications).to eq("tags" => [[], %w[new-tag new-tag-2]])
|
||||
expect(subject.raw_changed?).to eq(false)
|
||||
|
||||
subject.revise!(admin, tags: ["new-tag-3"])
|
||||
expect(post.post_revisions.last.modifications).to eq("tags" => [[], ["new-tag-3"]])
|
||||
expect(subject.raw_changed?).to eq(false)
|
||||
end
|
||||
|
||||
describe "#publish_changes" do
|
||||
|
||||
Reference in New Issue
Block a user