mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: polls are always editable until the first vote
This commit is contained in:
@@ -126,26 +126,30 @@ describe PostsController do
|
||||
end
|
||||
end
|
||||
|
||||
it "OP cannot change the options" do
|
||||
xhr :put, :update, { id: post_id, post: { raw: new_option } }
|
||||
expect(response).not_to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.op_cannot_edit_options_after_5_minutes"))
|
||||
end
|
||||
describe "with no vote" do
|
||||
|
||||
it "staff can change the options" do
|
||||
log_in_user(Fabricate(:moderator))
|
||||
xhr :put, :update, { id: post_id, post: { raw: new_option } }
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json["post"]["polls"]["poll"]["options"][1]["html"]).to eq("C")
|
||||
end
|
||||
it "OP can change the options" do
|
||||
xhr :put, :update, { id: post_id, post: { raw: new_option } }
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json["post"]["polls"]["poll"]["options"][1]["html"]).to eq("C")
|
||||
end
|
||||
|
||||
it "staff can change the options" do
|
||||
log_in_user(Fabricate(:moderator))
|
||||
xhr :put, :update, { id: post_id, post: { raw: new_option } }
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json["post"]["polls"]["poll"]["options"][1]["html"]).to eq("C")
|
||||
end
|
||||
|
||||
it "support changes on the post" do
|
||||
xhr :put, :update, { id: post_id, post: { raw: updated } }
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json["post"]["cooked"]).to match("before")
|
||||
end
|
||||
|
||||
it "support changes on the post" do
|
||||
xhr :put, :update, { id: post_id, post: { raw: updated } }
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json["post"]["cooked"]).to match("before")
|
||||
end
|
||||
|
||||
describe "with at least one vote" do
|
||||
@@ -154,6 +158,21 @@ describe PostsController do
|
||||
DiscoursePoll::Poll.vote(post_id, "poll", ["5c24fc1df56d764b550ceae1b9319125"], user.id)
|
||||
end
|
||||
|
||||
it "OP cannot change the options" do
|
||||
xhr :put, :update, { id: post_id, post: { raw: new_option } }
|
||||
expect(response).not_to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.op_cannot_edit_options_after_5_minutes"))
|
||||
end
|
||||
|
||||
it "staff can change the options" do
|
||||
log_in_user(Fabricate(:moderator))
|
||||
xhr :put, :update, { id: post_id, post: { raw: new_option } }
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json["post"]["polls"]["poll"]["options"][1]["html"]).to eq("C")
|
||||
end
|
||||
|
||||
it "support changes on the post" do
|
||||
xhr :put, :update, { id: post_id, post: { raw: updated } }
|
||||
expect(response).to be_success
|
||||
|
||||
Reference in New Issue
Block a user