mirror of
https://github.com/discourse/discourse.git
synced 2025-03-25 05:35:37 +08:00
FIX: Copy old status to new poll. (#6788)
This commit is contained in:
parent
f5c4ab0573
commit
c928386c3e
plugins/poll
@ -37,6 +37,7 @@ module DiscoursePoll
|
|||||||
attributes = new_poll.slice(*POLL_ATTRIBUTES)
|
attributes = new_poll.slice(*POLL_ATTRIBUTES)
|
||||||
attributes["visibility"] = new_poll["public"] == "true" ? "everyone" : "secret"
|
attributes["visibility"] = new_poll["public"] == "true" ? "everyone" : "secret"
|
||||||
attributes["close_at"] = Time.zone.parse(new_poll["close"]) rescue nil
|
attributes["close_at"] = Time.zone.parse(new_poll["close"]) rescue nil
|
||||||
|
attributes["status"] = old_poll["status"]
|
||||||
poll = ::Poll.new(attributes)
|
poll = ::Poll.new(attributes)
|
||||||
|
|
||||||
if is_different?(old_poll, poll, new_poll_options)
|
if is_different?(old_poll, poll, new_poll_options)
|
||||||
|
@ -59,6 +59,34 @@ describe DiscoursePoll::PollsUpdater do
|
|||||||
expect(message).to be(nil)
|
expect(message).to be(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "when editing" do
|
||||||
|
|
||||||
|
let(:raw) do
|
||||||
|
<<~RAW
|
||||||
|
This is a new poll with three options.
|
||||||
|
|
||||||
|
[poll type=multiple results=always min=1 max=2]
|
||||||
|
* first
|
||||||
|
* second
|
||||||
|
* third
|
||||||
|
[/poll]
|
||||||
|
RAW
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:post) { Fabricate(:post, raw: raw) }
|
||||||
|
|
||||||
|
it "works if poll is closed and unmodified" do
|
||||||
|
DiscoursePoll::Poll.vote(post.id, "poll", ["e55de753c08b93d04d677ce05e942d3c"], post.user)
|
||||||
|
DiscoursePoll::Poll.toggle_status(post.id, "poll", "closed", post.user)
|
||||||
|
|
||||||
|
freeze_time (SiteSetting.poll_edit_window_mins + 1).minutes.from_now
|
||||||
|
update(post, DiscoursePoll::PollsValidator.new(post).validate_polls)
|
||||||
|
|
||||||
|
expect(post.errors[:base].size).to equal(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
describe "deletes polls" do
|
describe "deletes polls" do
|
||||||
|
|
||||||
it "that were removed" do
|
it "that were removed" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user