From: Anton Khorev Date: Wed, 11 Sep 2024 14:43:37 +0000 (+0300) Subject: Replace 'remove this redaction' confirmation and request with Turbo X-Git-Tag: live~139^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/138988860cbb0fef579dc2db624281c33c16bcf8 Replace 'remove this redaction' confirmation and request with Turbo --- diff --git a/app/views/redactions/show.html.erb b/app/views/redactions/show.html.erb index 5b9749a51..fe073d123 100644 --- a/app/views/redactions/show.html.erb +++ b/app/views/redactions/show.html.erb @@ -18,7 +18,7 @@ <%= link_to t(".edit"), edit_redaction_path(@redaction), :class => "btn btn-outline-primary" %> <% end %> <% if can?(:destroy, Redaction) %> - <%= link_to t(".destroy"), @redaction, :method => "delete", :class => "btn btn-outline-danger", :remote => true, :data => { :confirm => t(".confirm") } %> + <%= link_to t(".destroy"), @redaction, :class => "btn btn-outline-danger", :data => { :turbo => true, :turbo_method => "DELETE", :turbo_confirm => t(".confirm") } %> <% end %> <% end %> diff --git a/test/system/redaction_destroy_test.rb b/test/system/redaction_destroy_test.rb new file mode 100644 index 000000000..db0b016a4 --- /dev/null +++ b/test/system/redaction_destroy_test.rb @@ -0,0 +1,33 @@ +require "application_system_test_case" + +class RedactionDestroyTest < ApplicationSystemTestCase + test "fails to delete nonempty redaction" do + redaction = create(:redaction, :title => "Some-unwanted-data-redaction") + create(:old_node, :redaction => redaction) + + sign_in_as create(:moderator_user) + visit redaction_path(redaction) + assert_text "Some-unwanted-data-redaction" + + accept_alert do + click_on "Remove this redaction" + end + assert_text "Redaction is not empty" + assert_text "Some-unwanted-data-redaction" + end + + test "deletes empty redaction" do + redaction = create(:redaction, :title => "No-unwanted-data-redaction") + + sign_in_as create(:moderator_user) + visit redaction_path(redaction) + assert_text "No-unwanted-data-redaction" + + accept_alert do + click_on "Remove this redaction" + end + assert_text "Redaction destroyed" + assert_text "List of Redactions" + assert_no_text "No-unwanted-data-redaction" + end +end