Extract polls edit window to a site settings.

This commit is contained in:
Guo Xiang Tan
2016-08-10 15:15:29 +08:00
parent 2b0268e74a
commit 8213da20f2
5 changed files with 47 additions and 16 deletions

View File

@ -114,7 +114,7 @@ describe PostsController do
end
describe "after the first 5 minutes" do
describe "after the poll edit window has expired" do
let(:poll) { "[poll]\n- A\n- B[/poll]" }
let(:new_option) { "[poll]\n- A\n- C[/poll]" }
@ -127,6 +127,12 @@ describe PostsController do
end
end
let(:poll_edit_window_mins) { 6 }
before do
SiteSetting.poll_edit_window_mins = poll_edit_window_mins
end
describe "with no vote" do
it "OP can change the options" do
@ -163,7 +169,10 @@ describe PostsController 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"))
expect(json["errors"][0]).to eq(I18n.t(
"poll.edit_window_expired.op_cannot_edit_options",
minutes: poll_edit_window_mins
))
end
it "staff can change the options and votes are merged" do