From f240ef707725f375f6cd2678e54c17e0b0d8d861 Mon Sep 17 00:00:00 2001 From: Kabiru Mwenja Date: Wed, 4 Sep 2024 18:16:55 +0300 Subject: [PATCH] chore[Op#57515]: Redefine filter as `Filters::AvailableCustomFieldsProjectsFilter` clarify that we're querying against `CustomFieldsProject` which is the join table for all custom field types, except "ProjectCustomField" aka "Project Attributes" which uses a special join table `ProjectCustomFieldsProjectMapping` --- .../custom_fields/custom_field_projects_controller.rb | 4 ++-- app/models/queries/projects.rb | 2 +- ...lter.rb => available_custom_fields_projects_filter.rb} | 6 +++--- .../custom_fields/custom_field_projects/index.html.erb | 2 +- config/locales/en.yml | 2 +- ...rb => available_custom_fields_projects_filter_spec.rb} | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) rename app/models/queries/projects/filters/{available_project_custom_fields_filter.rb => available_custom_fields_projects_filter.rb} (90%) rename spec/models/queries/projects/filters/{available_project_custom_fields_filter_spec.rb => available_custom_fields_projects_filter_spec.rb} (93%) diff --git a/app/controllers/admin/custom_fields/custom_field_projects_controller.rb b/app/controllers/admin/custom_fields/custom_field_projects_controller.rb index d392aedde22d..6f40ea7e6a7f 100644 --- a/app/controllers/admin/custom_fields/custom_field_projects_controller.rb +++ b/app/controllers/admin/custom_fields/custom_field_projects_controller.rb @@ -39,10 +39,10 @@ class Admin::CustomFields::CustomFieldProjectsController < ApplicationController menu_item :custom_fields def index - @available_project_custom_fields_query = ProjectQuery.new( + @available_custom_fields_projects_query = ProjectQuery.new( name: "custom-fields-projects-#{@custom_field.id}" ) do |query| - query.where(:available_project_custom_fields, "=", [@custom_field.id]) + query.where(:available_custom_fields_projects, "=", [@custom_field.id]) query.select(:name) query.order("lft" => "asc") end diff --git a/app/models/queries/projects.rb b/app/models/queries/projects.rb index 4cf3c4f501c7..bb25098c5322 100644 --- a/app/models/queries/projects.rb +++ b/app/models/queries/projects.rb @@ -30,7 +30,7 @@ module Queries::Projects ::Queries::Register.register(ProjectQuery) do filter Filters::AncestorFilter filter Filters::AvailableProjectAttributesFilter - filter Filters::AvailableProjectCustomFieldsFilter + filter Filters::AvailableCustomFieldsProjectsFilter filter Filters::TypeFilter filter Filters::ActiveFilter filter Filters::TemplatedFilter diff --git a/app/models/queries/projects/filters/available_project_custom_fields_filter.rb b/app/models/queries/projects/filters/available_custom_fields_projects_filter.rb similarity index 90% rename from app/models/queries/projects/filters/available_project_custom_fields_filter.rb rename to app/models/queries/projects/filters/available_custom_fields_projects_filter.rb index 459e52686571..0aa5a0d9531d 100644 --- a/app/models/queries/projects/filters/available_project_custom_fields_filter.rb +++ b/app/models/queries/projects/filters/available_custom_fields_projects_filter.rb @@ -29,9 +29,9 @@ # ++ # -class Queries::Projects::Filters::AvailableProjectCustomFieldsFilter < Queries::Projects::Filters::Base +class Queries::Projects::Filters::AvailableCustomFieldsProjectsFilter < Queries::Projects::Filters::Base def self.key - :available_project_custom_fields + :available_custom_fields_projects end def type @@ -65,6 +65,6 @@ def where end def human_name - I18n.t(:label_available_project_custom_fields) + I18n.t(:label_available_custom_fields_projects) end end diff --git a/app/views/admin/custom_fields/custom_field_projects/index.html.erb b/app/views/admin/custom_fields/custom_field_projects/index.html.erb index 7bf383a31848..4aeae6bedc0a 100644 --- a/app/views/admin/custom_fields/custom_field_projects/index.html.erb +++ b/app/views/admin/custom_fields/custom_field_projects/index.html.erb @@ -43,7 +43,7 @@ See COPYRIGHT and LICENSE files for more details. end else render(Admin::CustomFields::CustomFieldProjects::TableComponent.new( - query: @available_project_custom_fields_query, + query: @available_custom_fields_projects_query, params: params.merge({ custom_field: @custom_field })) ) end diff --git a/config/locales/en.yml b/config/locales/en.yml index b69c3b9919b4..16bb1555c318 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2070,9 +2070,9 @@ en: label_attribute_expand_text: "The complete text for '%{attribute}'" label_authentication: "Authentication" label_authentication_settings: "Authentication settings" + label_available_custom_fields_projects: "Available custom fields projects" label_available_global_roles: "Available global roles" label_available_project_attributes: "Available project attributes" - label_available_project_custom_fields: "Available project custom fields" label_available_project_forums: "Available forums" label_available_project_repositories: "Available repositories" label_available_project_versions: "Available versions" diff --git a/spec/models/queries/projects/filters/available_project_custom_fields_filter_spec.rb b/spec/models/queries/projects/filters/available_custom_fields_projects_filter_spec.rb similarity index 93% rename from spec/models/queries/projects/filters/available_project_custom_fields_filter_spec.rb rename to spec/models/queries/projects/filters/available_custom_fields_projects_filter_spec.rb index ec484664b73e..fa0df067fa84 100644 --- a/spec/models/queries/projects/filters/available_project_custom_fields_filter_spec.rb +++ b/spec/models/queries/projects/filters/available_custom_fields_projects_filter_spec.rb @@ -28,11 +28,11 @@ require "spec_helper" -RSpec.describe Queries::Projects::Filters::AvailableProjectCustomFieldsFilter do +RSpec.describe Queries::Projects::Filters::AvailableCustomFieldsProjectsFilter do it_behaves_like "basic query filter" do - let(:class_key) { :available_project_custom_fields } + let(:class_key) { :available_custom_fields_projects } let(:type) { :list } - let(:human_name) { "Available project custom fields" } + let(:human_name) { "Available custom fields projects" } end it_behaves_like "list query filter", scope: false do @@ -44,7 +44,7 @@ let(:valid_values) do [custom_field_project1.custom_field_id.to_s, custom_field_project2.custom_field_id.to_s] end - let(:name) { "Available project attributes" } + let(:name) { "Available custom fields projects" } describe "#apply_to" do let(:values) { valid_values }