diff --git a/plugins/poll/config/locales/server.en.yml b/plugins/poll/config/locales/server.en.yml index 1590536af..b1d5582c2 100644 --- a/plugins/poll/config/locales/server.en.yml +++ b/plugins/poll/config/locales/server.en.yml @@ -24,8 +24,10 @@ en: named_poll_must_have_different_options: "Poll named %{name} must have different options." requires_at_least_1_valid_option: "You must select at least 1 valid option." - cannot_change_polls_after_5_minutes: "Polls cannot be changed after the first 5 minutes. Contact a moderator if you need to change them." - staff_cannot_add_or_remove_options_after_5_minutes: "After the first 5 minutes, poll options can only be edited, not added or removed. If you need to add or remove options, you should close this topic and create a new one." + + cannot_change_polls_after_5_minutes: "You cannot add, remove or rename polls after the first 5 minutes." + op_cannot_edit_options_after_5_minutes: "You cannot add or remove poll options after the first 5 minutes. Please contact a moderator if you need to edit a poll option." + staff_cannot_add_or_remove_options_after_5_minutes: "You cannot add or remove poll options after the first 5 minutes. You should close this topic and create a new one instead." no_polls_associated_with_this_post: "No polls are associated with this post." no_poll_with_this_name: "No poll named %{name} associated with this post." diff --git a/plugins/poll/plugin.rb b/plugins/poll/plugin.rb index e623fdb37..ebf12d7ad 100644 --- a/plugins/poll/plugin.rb +++ b/plugins/poll/plugin.rb @@ -260,10 +260,10 @@ after_initialize do if polls.keys != previous_polls.keys || polls.values.map { |p| p["options"] } != previous_polls.values.map { |p| p["options"] } - # outside the 5-minute edit window? + # outside of the 5-minute edit window? if post.created_at < 5.minutes.ago - # cannot add/remove/change/re-order polls - if polls.keys != previous_polls.keys + # cannot add/remove/rename polls + if polls.keys.sort != previous_polls.keys.sort post.errors.add(:base, I18n.t("poll.cannot_change_polls_after_5_minutes")) return end @@ -278,8 +278,8 @@ after_initialize do end end else - # OP cannot change polls - post.errors.add(:base, I18n.t("poll.cannot_change_polls_after_5_minutes")) + # OP cannot edit poll options + post.errors.add(:base, I18n.t("poll.op_cannot_edit_options_after_5_minutes")) return end end diff --git a/plugins/poll/spec/controllers/posts_controller_spec.rb b/plugins/poll/spec/controllers/posts_controller_spec.rb index 7c5263bfc..780789129 100644 --- a/plugins/poll/spec/controllers/posts_controller_spec.rb +++ b/plugins/poll/spec/controllers/posts_controller_spec.rb @@ -92,7 +92,7 @@ describe PostsController do xhr :put, :update, { id: post_id, post: { raw: new_raw } } expect(response).not_to be_success json = ::JSON.parse(response.body) - expect(json["errors"][0]).to eq(I18n.t("poll.cannot_change_polls_after_5_minutes")) + expect(json["errors"][0]).to eq(I18n.t("poll.op_cannot_edit_options_after_5_minutes")) end it "can be edited by staff" do