From eb26e4073caa81d35ecddbb310e455f86c78aa44 Mon Sep 17 00:00:00 2001 From: vangberg Date: Tue, 30 Jun 2026 12:35:47 +0200 Subject: [PATCH] Fix regression on /names/user returning empty list `NamesController#user` sets `params[:status] = 'all'`. Before pull request #288 this was converted into `opts[:status] = nil`: ```ruby opts[:status] ||= case @status.to_s.downcase when 'public'; Name.public_status when 'automated'; 0 when 'seqcode'; 15 when 'icnp'; 20 when 'icnafp'; 25 when 'valid'; Name.valid_status end ``` The pull request changed that code to call `map_status_to_value`, which returns `'all'`. This in turn would be sent to `apply_name_filters` which would create the condition `WHERE status = 'all'`, returning nothing. By explicitly returning `nil` instead, no conditions on `status` are imposed. --- app/controllers/concerns/name_filterable.rb | 2 ++ test/controllers/names_controller_test.rb | 7 +++++++ test/fixtures/names.yml | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/app/controllers/concerns/name_filterable.rb b/app/controllers/concerns/name_filterable.rb index 0575d817..fde03c65 100644 --- a/app/controllers/concerns/name_filterable.rb +++ b/app/controllers/concerns/name_filterable.rb @@ -23,6 +23,8 @@ def name_status_filters # @return [Integer, Array] The status value(s). def map_status_to_value(status) status = status.to_s.downcase + return nil if status == 'all' + status = 'icnafp' if status == 'icn' name_status_filters[status] || status end diff --git a/test/controllers/names_controller_test.rb b/test/controllers/names_controller_test.rb index cf4f4fe3..62ec6fe8 100644 --- a/test/controllers/names_controller_test.rb +++ b/test/controllers/names_controller_test.rb @@ -21,4 +21,11 @@ class NamesControllerTest < ActionDispatch::IntegrationTest assert name.observing?(@user) assert_redirected_to name_url(name) end + + test 'user names includes draft names' do + get user_names_url + + assert_response :success + assert_includes @response.body, names(:draft_by_contributor).name + end end diff --git a/test/fixtures/names.yml b/test/fixtures/names.yml index 258c4d6c..3fe3ca98 100644 --- a/test/fixtures/names.yml +++ b/test/fixtures/names.yml @@ -2,3 +2,8 @@ unregistered: name: MyString + +draft_by_contributor: + name: Testimonas draftensis + status: 5 # draft + created_by: contributor