From d1b58fb20e90913a6caffca7f5857527cc26bec4 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sun, 7 Jan 2024 19:19:57 +0300 Subject: [PATCH 1/1] Show blocked api response when reopening notes --- app/assets/javascripts/index/note.js | 2 +- app/views/notes/show.html.erb | 2 ++ test/system/note_comments_test.rb | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index 0c0be716b..15fedb1d1 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -83,7 +83,7 @@ OSM.Note = function (map) { } function updateButtons(form) { - $(form.close).prop("disabled", false); + $(form).find("input[type=submit]").prop("disabled", false); if ($(form.text).val() === "") { $(form.close).val($(form.close).data("defaultActionText")); $(form.comment).prop("disabled", true); diff --git a/app/views/notes/show.html.erb b/app/views/notes/show.html.erb index 3a1224676..a7baccf85 100644 --- a/app/views/notes/show.html.erb +++ b/app/views/notes/show.html.erb @@ -75,6 +75,8 @@ <% else %>
+
<% if @note.status != "hidden" and current_user and current_user.moderator? -%> " class="btn btn-light" data-method="DELETE" data-url="<%= api_note_url(@note, "json") %>"> diff --git a/test/system/note_comments_test.rb b/test/system/note_comments_test.rb index a629dfce3..7c830cc37 100644 --- a/test/system/note_comments_test.rb +++ b/test/system/note_comments_test.rb @@ -103,4 +103,26 @@ class NoteCommentsTest < ApplicationSystemTestCase assert_button "Comment", :disabled => true end end + + test "can't reactivate a note when blocked" do + note = create(:note_with_comments, :closed) + user = create(:user) + sign_in_as(user) + visit note_path(note) + create(:user_block, :user => user) + + within_sidebar do + assert_no_text "Unresolved note" + assert_text "Resolved note" + assert_no_text "Your access to the API has been blocked" + assert_button "Reactivate", :disabled => false + + click_on "Reactivate" + + assert_no_text "Unresolved note" + assert_text "Resolved note" + assert_text "Your access to the API has been blocked" + assert_button "Reactivate", :disabled => false + end + end end -- 2.39.5