regression polls could not be closed properly

This commit is contained in:
Sam 2017-07-18 14:52:58 -04:00
parent 660d5e0a35
commit b7f58fe880
2 changed files with 6 additions and 3 deletions

View File

@ -113,7 +113,10 @@ const rule = {
// default poll attributes
const attributes = [["class", "poll"]];
attributes.push([DATA_PREFIX + "status", "open"]);
if (!attrs['status']) {
attributes.push([DATA_PREFIX + "status", "open"]);
}
WHITELISTED_ATTRIBUTES.forEach(name => {
if (attrs[name]) {

View File

@ -79,8 +79,8 @@ describe ::DiscoursePoll::PollsController do
end
it "ensures poll is open" do
closed_poll = Fabricate(:post, raw: "[poll status=closed]\n- A\n- B\n[/poll]")
xhr :put, :vote, { post_id: closed_poll.id, poll_name: "poll", options: ["A"] }
closed_poll = create_post(raw: "[poll status=closed]\n- A\n- B\n[/poll]")
xhr :put, :vote, { post_id: closed_poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"] }
expect(response).not_to be_success
json = ::JSON.parse(response.body)
expect(json["errors"][0]).to eq(I18n.t("poll.poll_must_be_open_to_vote"))