]> git.openstreetmap.org Git - rails.git/commitdiff
Make select all checkbox on users list work with turbo
authorTom Hughes <tom@compton.nu>
Thu, 12 Sep 2024 18:09:47 +0000 (19:09 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 12 Sep 2024 18:10:26 +0000 (19:10 +0100)
.rubocop_todo.yml
app/assets/javascripts/user.js
test/system/users_test.rb [new file with mode: 0644]

index dc10923603bf422cd8cdff017f488fc4a40e3e29..7384a8d95fee5c43c197b7abebd7767f95779702 100644 (file)
@@ -26,6 +26,7 @@ FactoryBot/ExcessiveCreateList:
     - 'test/controllers/notes_controller_test.rb'
     - 'test/controllers/traces_controller_test.rb'
     - 'test/controllers/user_blocks_controller_test.rb'
+    - 'test/system/users_test.rb'
 
 # Offense count: 635
 # This cop supports safe autocorrection (--autocorrect).
index 495470f2fd10ea35281b5f0377d9d19130bc8099..681ec3ace82470b0caa52b7fd87562dbefa17f6a 100644 (file)
@@ -1,5 +1,11 @@
 //= require leaflet.locatecontrol/src/L.Control.Locate
 
+(function () {
+  $(document).on("change", "#user_all", function () {
+    $("#user_list input[type=checkbox]").prop("checked", $("#user_all").prop("checked"));
+  });
+}());
+
 $(document).ready(function () {
   var defaultHomeZoom = 12;
   var map, marker, deleted_lat, deleted_lon;
@@ -200,10 +206,6 @@ $(document).ready(function () {
     enableAuth();
   }
 
-  $("#user_all").change(function () {
-    $("#user_list input[type=checkbox]").prop("checked", $("#user_all").prop("checked"));
-  });
-
   $("#content.user_confirm").each(function () {
     $(this).hide();
     $(this).find("#confirm").submit();
diff --git a/test/system/users_test.rb b/test/system/users_test.rb
new file mode 100644 (file)
index 0000000..5d5bf56
--- /dev/null
@@ -0,0 +1,28 @@
+require "application_system_test_case"
+
+class UsersTest < ApplicationSystemTestCase
+  def setup
+    admin = create(:administrator_user)
+    sign_in_as(admin)
+  end
+
+  test "all users can be selected" do
+    create_list(:user, 100)
+
+    visit users_path
+
+    assert_css "tbody input[type=checkbox]:checked", :count => 0
+    assert_css "tbody input[type=checkbox]:not(:checked)", :count => 50
+    check "user_all"
+    assert_css "tbody input[type=checkbox]:checked", :count => 50
+    assert_css "tbody input[type=checkbox]:not(:checked)", :count => 0
+
+    click_on "Older Users", :match => :first
+
+    assert_css "tbody input[type=checkbox]:checked", :count => 0
+    assert_css "tbody input[type=checkbox]:not(:checked)", :count => 50
+    check "user_all"
+    assert_css "tbody input[type=checkbox]:checked", :count => 50
+    assert_css "tbody input[type=checkbox]:not(:checked)", :count => 0
+  end
+end