From: Tom Hughes Date: Tue, 11 Mar 2025 22:45:08 +0000 (+0000) Subject: Preserve username and edit filters over bulk user updates X-Git-Tag: live~13^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/6d8545bd3c8f0b76836622b9c983fce916b6e2d3?hp=-c Preserve username and edit filters over bulk user updates --- 6d8545bd3c8f0b76836622b9c983fce916b6e2d3 diff --git a/app/controllers/users/lists_controller.rb b/app/controllers/users/lists_controller.rb index 2f4c4f5fb..5a0ff205b 100644 --- a/app/controllers/users/lists_controller.rb +++ b/app/controllers/users/lists_controller.rb @@ -38,7 +38,7 @@ module Users User.where(:id => ids).update_all(:status => "confirmed") if params[:confirm] User.where(:id => ids).update_all(:status => "deleted") if params[:hide] - redirect_to url_for(params.permit(:status, :ip, :before, :after)) + redirect_to url_for(params.permit(:status, :username, :ip, :edits, :before, :after)) end end end diff --git a/app/views/users/lists/_page.html.erb b/app/views/users/lists/_page.html.erb index 2c06f0237..b3dfcc604 100644 --- a/app/views/users/lists/_page.html.erb +++ b/app/views/users/lists/_page.html.erb @@ -14,7 +14,9 @@
<%= hidden_field_tag :status, params[:status] if params[:status] %> + <%= hidden_field_tag :username, params[:username] if params[:username] %> <%= hidden_field_tag :ip, params[:ip] if params[:ip] %> + <%= hidden_field_tag :edits, params[:edits] if params[:edits] %> <%= hidden_field_tag :page, params[:page] if params[:page] %> diff --git a/test/controllers/users/lists_controller_test.rb b/test/controllers/users/lists_controller_test.rb index 2471b34b3..6326bdb18 100644 --- a/test/controllers/users/lists_controller_test.rb +++ b/test/controllers/users/lists_controller_test.rb @@ -67,64 +67,88 @@ module Users get users_list_path, :params => { :status => "suspended" } assert_response :success assert_template :show - assert_select "table#user_list tbody tr", :count => 1 do - assert_select "a[href='#{user_path(suspended_user)}']", :count => 1 + assert_select "turbo-frame#pagination", :count => 1 do + assert_select "input[type='hidden'][name='status'][value='suspended']", :count => 1 + assert_select "table#user_list tbody tr", :count => 1 do + assert_select "a[href='#{user_path(suspended_user)}']", :count => 1 + end end # Should be able to limit by name get users_list_path, :params => { :username => "Test User" } assert_response :success assert_template :show - assert_select "table#user_list tbody tr", :count => 1 do - assert_select "a[href='#{user_path(name_user)}']", :count => 1 + assert_select "turbo-frame#pagination", :count => 1 do + assert_select "input[type='hidden'][name='username'][value='Test User']", :count => 1 + assert_select "table#user_list tbody tr", :count => 1 do + assert_select "a[href='#{user_path(name_user)}']", :count => 1 + end end # Should be able to limit by name ignoring case get users_list_path, :params => { :username => "test user" } assert_response :success assert_template :show - assert_select "table#user_list tbody tr", :count => 1 do - assert_select "a[href='#{user_path(name_user)}']", :count => 1 + assert_select "turbo-frame#pagination", :count => 1 do + assert_select "input[type='hidden'][name='username'][value='test user']", :count => 1 + assert_select "table#user_list tbody tr", :count => 1 do + assert_select "a[href='#{user_path(name_user)}']", :count => 1 + end end # Should be able to limit by email get users_list_path, :params => { :username => "test@example.com" } assert_response :success assert_template :show - assert_select "table#user_list tbody tr", :count => 1 do - assert_select "a[href='#{user_path(email_user)}']", :count => 1 + assert_select "turbo-frame#pagination", :count => 1 do + assert_select "input[type='hidden'][name='username'][value='test@example.com']", :count => 1 + assert_select "table#user_list tbody tr", :count => 1 do + assert_select "a[href='#{user_path(email_user)}']", :count => 1 + end end # Should be able to limit by email ignoring case get users_list_path, :params => { :username => "TEST@example.com" } assert_response :success assert_template :show - assert_select "table#user_list tbody tr", :count => 1 do - assert_select "a[href='#{user_path(email_user)}']", :count => 1 + assert_select "turbo-frame#pagination", :count => 1 do + assert_select "input[type='hidden'][name='username'][value='TEST@example.com']", :count => 1 + assert_select "table#user_list tbody tr", :count => 1 do + assert_select "a[href='#{user_path(email_user)}']", :count => 1 + end end # Should be able to limit by IP address get users_list_path, :params => { :ip => "1.2.3.4" } assert_response :success assert_template :show - assert_select "table#user_list tbody tr", :count => 1 do - assert_select "a[href='#{user_path(ip_user)}']", :count => 1 + assert_select "turbo-frame#pagination", :count => 1 do + assert_select "input[type='hidden'][name='ip'][value='1.2.3.4']", :count => 1 + assert_select "table#user_list tbody tr", :count => 1 do + assert_select "a[href='#{user_path(ip_user)}']", :count => 1 + end end # Should be able to limit to users with edits get users_list_path, :params => { :edits => "yes" } assert_response :success assert_template :show - assert_select "table#user_list tbody tr", :count => 1 do - assert_select "a[href='#{user_path(edits_user)}']", :count => 1 + assert_select "turbo-frame#pagination", :count => 1 do + assert_select "input[type='hidden'][name='edits'][value='yes']", :count => 1 + assert_select "table#user_list tbody tr", :count => 1 do + assert_select "a[href='#{user_path(edits_user)}']", :count => 1 + end end # Should be able to limit to users with no edits get users_list_path, :params => { :edits => "no" } assert_response :success assert_template :show - assert_select "table#user_list tbody tr", :count => 9 do - assert_select "a[href='#{user_path(edits_user)}']", :count => 0 + assert_select "turbo-frame#pagination", :count => 1 do + assert_select "input[type='hidden'][name='edits'][value='no']", :count => 1 + assert_select "table#user_list tbody tr", :count => 9 do + assert_select "a[href='#{user_path(edits_user)}']", :count => 0 + end end end