clarify copy when editing a poll after the first 5 minutes

This commit is contained in:
Régis Hanol 2015-05-07 17:24:35 +02:00
parent 9b0ca60f52
commit c1bb7bc7cc
3 changed files with 10 additions and 8 deletions

View File

@ -24,8 +24,10 @@ en:
named_poll_must_have_different_options: "Poll named <strong>%{name}</strong> 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 <strong>%{name}</strong> associated with this post."

View File

@ -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

View File

@ -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