FIX: make sure we can't vote on deleted polls

This commit is contained in:
Régis Hanol
2015-06-01 22:31:47 +02:00
parent 255402350f
commit c240a8bd80
3 changed files with 33 additions and 4 deletions

View File

@ -57,6 +57,14 @@ describe ::DiscoursePoll::PollsController do
expect(json["errors"][0]).to eq(I18n.t("poll.topic_must_be_open_to_vote"))
end
it "ensures post is not trashed" do
poll.trash!
xhr :put, :vote, { post_id: poll.id, poll_name: "poll", options: ["A"] }
expect(response).not_to be_success
json = ::JSON.parse(response.body)
expect(json["errors"][0]).to eq(I18n.t("poll.post_is_deleted"))
end
it "ensures polls are associated with the post" do
xhr :put, :vote, { post_id: Fabricate(:post).id, poll_name: "foobar", options: ["A"] }
expect(response).not_to be_success
@ -102,6 +110,14 @@ describe ::DiscoursePoll::PollsController do
expect(json["poll"]["status"]).to eq("closed")
end
it "ensures post is not trashed" do
poll.trash!
xhr :put, :toggle_status, { post_id: poll.id, poll_name: "poll", status: "closed" }
expect(response).not_to be_success
json = ::JSON.parse(response.body)
expect(json["errors"][0]).to eq(I18n.t("poll.post_is_deleted"))
end
end
end