From 514291101234b5a9cc23269a70f16f7f3f0bd5df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 23 Nov 2018 17:42:57 +0100 Subject: [PATCH] FIX: auto-closing poll wasn't working --- plugins/poll/jobs/regular/close_poll.rb | 2 +- plugins/poll/spec/jobs/regular/close_poll_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 plugins/poll/spec/jobs/regular/close_poll_spec.rb diff --git a/plugins/poll/jobs/regular/close_poll.rb b/plugins/poll/jobs/regular/close_poll.rb index b4b25bc3e4e..ccfac109314 100644 --- a/plugins/poll/jobs/regular/close_poll.rb +++ b/plugins/poll/jobs/regular/close_poll.rb @@ -3,7 +3,7 @@ module Jobs class ClosePoll < Jobs::Base def execute(args) - DiscoursePoll::Poll.toggle_status(args[:post_id], args[:poll_name], "closed", -1) + DiscoursePoll::Poll.toggle_status(args[:post_id], args[:poll_name], "closed", Discourse.system_user) end end diff --git a/plugins/poll/spec/jobs/regular/close_poll_spec.rb b/plugins/poll/spec/jobs/regular/close_poll_spec.rb new file mode 100644 index 00000000000..3dfe2188967 --- /dev/null +++ b/plugins/poll/spec/jobs/regular/close_poll_spec.rb @@ -0,0 +1,15 @@ +require "rails_helper" + +describe Jobs::ClosePoll do + + it "automatically closes a poll" do + post = Fabricate(:post, raw: "[poll]\n- A\n- B\n[/poll]") + + expect(post.polls.first.closed?).to eq(false) + + Jobs::ClosePoll.new.execute(post_id: post.id, poll_name: "poll") + + expect(post.polls.first.closed?).to eq(true) + end + +end