discourse/plugins/poll/spec/jobs/regular/close_poll_spec.rb
Guo Xiang Tan 71ce9ced47 FIX: Incorrect arguments were being passed to Jobs::ClosePoll.
Also fix spec that wasn't testing anything.
2018-12-13 16:46:00 +08:00

27 lines
706 B
Ruby

require "rails_helper"
describe Jobs::ClosePoll do
let(:post) { Fabricate(:post, raw: "[poll]\n- A\n- B\n[/poll]") }
describe 'missing arguments' do
it 'should raise the right error' do
expect do
Jobs::ClosePoll.new.execute(post_id: post.id)
end.to raise_error(Discourse::InvalidParameters, "poll_name")
expect do
Jobs::ClosePoll.new.execute(poll_name: "poll")
end.to raise_error(Discourse::InvalidParameters, "post_id")
end
end
it "automatically closes a poll" do
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