discourse/plugins/poll/spec/jobs/regular/close_poll_spec.rb

27 lines
706 B
Ruby
Raw Normal View History

2018-11-23 11:42:57 -05:00
require "rails_helper"
describe Jobs::ClosePoll do
let(:post) { Fabricate(:post, raw: "[poll]\n- A\n- B\n[/poll]") }
2018-11-23 11:42:57 -05:00
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
2018-11-23 11:42:57 -05:00
it "automatically closes a poll" do
2018-11-23 11:42:57 -05:00
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