DEV: Do not attempt to update polls if there are no polls before and after (#26573)

This commit is contained in:
Natalie Tay
2024-04-12 13:16:10 +08:00
committed by GitHub
parent 973a0028b4
commit 18bb6b0871
2 changed files with 25 additions and 0 deletions

View File

@ -186,5 +186,27 @@ RSpec.describe DiscoursePoll::PollsUpdater do
end
end
end
context "when no polls" do
it "does not attempt to update polls" do
DiscoursePoll::PollsUpdater.stubs(:update).raises(StandardError)
no_poll_post = Fabricate(:post)
raw = <<~RAW
no poll here, moving on
RAW
no_poll_post.raw = raw
expect(no_poll_post.valid?).to eq(true)
end
it "does not need to validate post" do
DiscoursePoll::PostValidator.stubs(:validate_post).raises(StandardError)
no_poll_post =
Post.new(user: user, topic: Fabricate(:topic), raw: "no poll here, meoving on")
expect(no_poll_post.valid?).to eq(true)
end
end
end
end