mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 07:34:18 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
29 lines
737 B
Ruby
29 lines
737 B
Ruby
# frozen_string_literal: true
|
|
|
|
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
|