OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
updating specs due to removal of custom_fields_in_projects_list
Ivan Kuchinea0218b43209
diff --git a/modules/xls_export/spec/models/xls_export/project/exporter/xls_integration_spec.rb b/modules/xls_export/spec/models/xls_export/project/exporter/xls_integration_spec.rbindex 37aca09cf86..bddf083e139 100644--- a/modules/xls_export/spec/models/xls_export/project/exporter/xls_integration_spec.rb+++ b/modules/xls_export/spec/models/xls_export/project/exporter/xls_integration_spec.rb@@ -57,86 +57,78 @@ RSpec.describe XlsExport::Project::Exporter::XLS dodescribe "custom field columns selected" dolet(:query_columns) { %w[name description project_status public] + global_project_custom_fields.map(&:column_name) }- context "when ee enabled", with_ee: %i[custom_fields_in_projects_list] do- before do- project # re-evaluate project to ensure it is created within the desired user context- end+ before do+ project # re-evaluate project to ensure it is created within the desired user context+ end- context "with admin permission" do- let(:current_user) { build_stubbed(:admin) }-- it "renders all those columns" do- cf_names = global_project_custom_fields.map(&:name)- expect(header).to eq ["ID", "Identifier", "Name", "Description", "Status", "Public", *cf_names]-- expect(header).to include not_used_string_cf.name- expect(header).to include hidden_cf.name-- custom_values = global_project_custom_fields.map do |cf|- case cf- when bool_cf- "true"- when text_cf- project.typed_custom_value_for(cf)- when not_used_string_cf- nil- else- project.formatted_custom_value_for(cf)- end+ context "with admin permission" do+ let(:current_user) { build_stubbed(:admin) }++ it "renders all those columns" do+ cf_names = global_project_custom_fields.map(&:name)+ expect(header).to eq ["ID", "Identifier", "Name", "Description", "Status", "Public", *cf_names]++ expect(header).to include not_used_string_cf.name+ expect(header).to include hidden_cf.name++ custom_values = global_project_custom_fields.map do |cf|+ case cf+ when bool_cf+ "true"+ when text_cf+ project.typed_custom_value_for(cf)+ when not_used_string_cf+ nil+ else+ project.formatted_custom_value_for(cf)end+ end- expect(sheet.row(1))- .to eq [project.id.to_s, project.identifier, project.name, project.description, "Off track", "false",- *custom_values]+ expect(sheet.row(1))+ .to eq [project.id.to_s, project.identifier, project.name, project.description, "Off track", "false",+ *custom_values]- # The column for the project-level-disabled custom field is blank- expect(sheet.row(1)[header.index(not_used_string_cf.name)]).to be_nil- end+ # The column for the project-level-disabled custom field is blank+ expect(sheet.row(1)[header.index(not_used_string_cf.name)]).to be_nilend+ end- context "with view_project_attributes permission" do- it "renders available project custom fields in the header if enabled in any project" do- cf_names = global_project_custom_fields.map(&:name)-- expect(header).to eq ["ID", "Identifier", "Name", "Description", "Status", "Public", *cf_names]-- expect(header).not_to include not_used_string_cf.name- expect(header).not_to include hidden_cf.name-- custom_values = global_project_custom_fields.map do |cf|- case cf- when bool_cf- "true"- when text_cf- project.typed_custom_value_for(cf)- when not_used_string_cf- nil- else- project.formatted_custom_value_for(cf)- end+ context "with view_project_attributes permission" do+ it "renders available project custom fields in the header if enabled in any project" do+ cf_names = global_project_custom_fields.map(&:name)++ expect(header).to eq ["ID", "Identifier", "Name", "Description", "Status", "Public", *cf_names]++ expect(header).not_to include not_used_string_cf.name+ expect(header).not_to include hidden_cf.name++ custom_values = global_project_custom_fields.map do |cf|+ case cf+ when bool_cf+ "true"+ when text_cf+ project.typed_custom_value_for(cf)+ when not_used_string_cf+ nil+ else+ project.formatted_custom_value_for(cf)end-- expect(sheet.row(1))- .to eq [project.id.to_s, project.identifier, project.name, project.description, "Off track", "false",- *custom_values]end- end-- context "without view_project_attributes permission" do- let(:permissions) { %i(view_projects) }-- it "does not render project custom fields in the header" do- expect(header).to eq ["ID", "Identifier", "Name", "Description", "Status", "Public"]- expect(sheet.row(1))- .to eq [project.id.to_s, project.identifier, project.name, project.description, "Off track", "false"]- end+ expect(sheet.row(1))+ .to eq [project.id.to_s, project.identifier, project.name, project.description, "Off track", "false",+ *custom_values]endend- context "when ee not enabled" do- it "renders only the default columns" do- expect(header).to eq %w[ID Identifier Name Description Status Public]+ context "without view_project_attributes permission" do+ let(:permissions) { %i(view_projects) }++ it "does not render project custom fields in the header" do+ expect(header).to eq ["ID", "Identifier", "Name", "Description", "Status", "Public"]++ expect(sheet.row(1))+ .to eq [project.id.to_s, project.identifier, project.name, project.description, "Off track", "false"]endendenddiff --git a/spec/features/projects/projects_portfolio_spec.rb b/spec/features/projects/projects_portfolio_spec.rbindex 87fe58057f4..d5f805c233a 100644--- a/spec/features/projects/projects_portfolio_spec.rb+++ b/spec/features/projects/projects_portfolio_spec.rb@@ -28,8 +28,7 @@require "spec_helper"-RSpec.describe "Projects index page", :js, :with_cuprite,- with_ee: %i[custom_fields_in_projects_list], with_settings: { login_required?: false } do+RSpec.describe "Projects index page", :js, :with_cuprite, with_settings: { login_required?: false } doinclude Components::Autocompleter::NgSelectAutocompleteHelpersshared_let(:admin) { create(:admin) }diff --git a/spec/models/projects/exporter/csv_integration_spec.rb b/spec/models/projects/exporter/csv_integration_spec.rbindex 3f6b37b6160..e578ab18bc6 100644--- a/spec/models/projects/exporter/csv_integration_spec.rb+++ b/spec/models/projects/exporter/csv_integration_spec.rb@@ -63,98 +63,90 @@ RSpec.describe Projects::Exports::CSV, "integration" do%w[name description project_status public] + global_project_custom_fields.map(&:column_name)end- context "when ee enabled", with_ee: %i[custom_fields_in_projects_list] do- before do- project # re-evaluate project to ensure it is created within the desired user context- parsed- end+ before do+ project # re-evaluate project to ensure it is created within the desired user context+ parsed+ end- context "without view_project_attributes permission" do- let(:permissions) { %i(view_projects) }+ context "without view_project_attributes permission" do+ let(:permissions) { %i(view_projects) }- it "does not render project custom fields in the header" do- expect(parsed.size).to eq 2+ it "does not render project custom fields in the header" do+ expect(parsed.size).to eq 2- expect(header).to eq ["id", "Identifier", "Name", "Description", "Status", "Public"]- end+ expect(header).to eq ["id", "Identifier", "Name", "Description", "Status", "Public"]+ end- it "does not render the custom field values in the rows if enabled for a project" do- expect(rows.first)- .to eq [project.id.to_s, project.identifier, project.name,- project.description, "Off track", "false"]- end+ it "does not render the custom field values in the rows if enabled for a project" do+ expect(rows.first)+ .to eq [project.id.to_s, project.identifier, project.name,+ project.description, "Off track", "false"]end+ end- context "with view_project_attributes permission" do- it "renders available project custom fields in the header if enabled in any project" do- expect(parsed.size).to eq 2+ context "with view_project_attributes permission" do+ it "renders available project custom fields in the header if enabled in any project" do+ expect(parsed.size).to eq 2- cf_names = global_project_custom_fields.map(&:name)+ cf_names = global_project_custom_fields.map(&:name)- expect(cf_names).not_to include(not_used_string_cf.name)- expect(cf_names).not_to include(hidden_cf.name)+ expect(cf_names).not_to include(not_used_string_cf.name)+ expect(cf_names).not_to include(hidden_cf.name)- expect(header).to eq ["id", "Identifier", "Name", "Description", "Status", "Public", *cf_names]- end+ expect(header).to eq ["id", "Identifier", "Name", "Description", "Status", "Public", *cf_names]+ end- it "renders the custom field values in the rows if enabled for a project" do- custom_values = global_project_custom_fields.map do |cf|- case cf- when bool_cf- "true"- when text_cf- project.typed_custom_value_for(cf)- when not_used_string_cf- ""- else- project.formatted_custom_value_for(cf)- end+ it "renders the custom field values in the rows if enabled for a project" do+ custom_values = global_project_custom_fields.map do |cf|+ case cf+ when bool_cf+ "true"+ when text_cf+ project.typed_custom_value_for(cf)+ when not_used_string_cf+ ""+ else+ project.formatted_custom_value_for(cf)end- expect(rows.first)- .to eq [project.id.to_s, project.identifier, project.name,- project.description, "Off track", "false", *custom_values]end+ expect(rows.first)+ .to eq [project.id.to_s, project.identifier, project.name,+ project.description, "Off track", "false", *custom_values]end+ end- context "with admin permission" do- let(:current_user) { create(:admin) }+ context "with admin permission" do+ let(:current_user) { create(:admin) }- it "renders all globally available project custom fields including hidden ones in the header" do- expect(parsed.size).to eq 3+ it "renders all globally available project custom fields including hidden ones in the header" do+ expect(parsed.size).to eq 3- cf_names = global_project_custom_fields.map(&:name)+ cf_names = global_project_custom_fields.map(&:name)- expect(cf_names).to include(not_used_string_cf.name)- expect(cf_names).to include(hidden_cf.name)+ expect(cf_names).to include(not_used_string_cf.name)+ expect(cf_names).to include(hidden_cf.name)- expect(header).to eq ["id", "Identifier", "Name", "Description", "Status", "Public", *cf_names]- end+ expect(header).to eq ["id", "Identifier", "Name", "Description", "Status", "Public", *cf_names]+ end- it "renders the custom field values in the rows if enabled for a project" do- custom_values = global_project_custom_fields.map do |cf|- case cf- when bool_cf- "true"- when hidden_cf- "hidden"- when not_used_string_cf- ""- when text_cf- project.typed_custom_value_for(cf)- else- project.formatted_custom_value_for(cf)- end+ it "renders the custom field values in the rows if enabled for a project" do+ custom_values = global_project_custom_fields.map do |cf|+ case cf+ when bool_cf+ "true"+ when hidden_cf+ "hidden"+ when not_used_string_cf+ ""+ when text_cf+ project.typed_custom_value_for(cf)+ else+ project.formatted_custom_value_for(cf)end- expect(rows.first)- .to eq [project.id.to_s, project.identifier, project.name,- project.description, "Off track", "false", *custom_values]end- end- end-- context "when ee not enabled" do- it "renders only the default columns" do- expect(header).to eq %w[id Identifier Name Description Status Public]+ expect(rows.first)+ .to eq [project.id.to_s, project.identifier, project.name,+ project.description, "Off track", "false", *custom_values]endendenddiff --git a/spec/models/queries/projects/factory_spec.rb b/spec/models/queries/projects/factory_spec.rbindex 6bfd1b94d30..9e531ba3d67 100644--- a/spec/models/queries/projects/factory_spec.rb+++ b/spec/models/queries/projects/factory_spec.rb@@ -114,7 +114,6 @@ RSpec.describe Queries::Projects::Factory,endcontext "without id and with ee and admin privileges",- with_ee: %i[custom_fields_in_projects_list],with_settings: { enabled_projects_columns: %w[name created_at cf_1] } docurrent_user { build_stubbed(:admin) }@@ -810,7 +809,6 @@ RSpec.describe Queries::Projects::Factory,endcontext "without id, as non admin and with a non existing custom field id",- with_ee: %i[custom_fields_in_projects_list],with_settings: { enabled_projects_columns: %w[name created_at cf_1 cf_42] } dobefore docustom_fielddiff --git a/spec/models/queries/projects/project_query_spec.rb b/spec/models/queries/projects/project_query_spec.rbindex 0147762557b..ea79563c931 100644--- a/spec/models/queries/projects/project_query_spec.rb+++ b/spec/models/queries/projects/project_query_spec.rb@@ -113,8 +113,6 @@ RSpec.describe ProjectQuery doenddescribe ".available_selects" do- current_user { user }-before doscope = instance_double(ActiveRecord::Relation)@@ -127,52 +125,48 @@ RSpec.describe ProjectQuery do.and_return([23, 42])end- it "lists registered selects" do- expect(instance.available_selects.map(&:attribute))- .to contain_exactly(:name,- :favored,- :public,- :description,- :hierarchy,- :project_status,- :status_explanation)- end-- context "with the user being admin" do- current_user { admin }+ # rubocop:disable Naming/VariableNumber+ context "for non admin user" do+ current_user { user }- it "includes admin columns" do+ it "lists registered selects" doexpect(instance.available_selects.map(&:attribute))- .to contain_exactly(:name,- :public,- :favored,- :description,- :hierarchy,- :project_status,- :status_explanation,- :created_at,- :latest_activity_at,- :required_disk_space)+ .to match_array(%i[+ name+ favored+ public+ description+ hierarchy+ project_status+ status_explanation+ cf_23+ cf_42+ ])endend- context "with an enterprise token",- with_ee: %i[custom_fields_in_projects_list] do- # rubocop:disable Naming/VariableNumber- it "includes custom field columns" do+ context "for admin user" do+ current_user { admin }++ it "includes admin columns" doexpect(instance.available_selects.map(&:attribute))- .to contain_exactly(:name,- :public,- :favored,- :description,- :hierarchy,- :project_status,- :status_explanation,- :cf_23,- :cf_42)+ .to match_array(%i[+ name+ favored+ public+ description+ hierarchy+ project_status+ status_explanation+ created_at+ latest_activity_at+ required_disk_space+ cf_23+ cf_42+ ])end- # rubocop:enable Naming/VariableNumberend+ # rubocop:enable Naming/VariableNumberenddescribe "#valid_subset!" dodiff --git a/spec/services/custom_fields/create_service_spec.rb b/spec/services/custom_fields/create_service_spec.rbindex 63042b4ff78..e3f4f5cefb8 100644--- a/spec/services/custom_fields/create_service_spec.rb+++ b/spec/services/custom_fields/create_service_spec.rb@@ -31,8 +31,7 @@ require "services/base_services/behaves_like_create_service"RSpec.describe CustomFields::CreateService, type: :model doit_behaves_like "BaseServices create service" do- context "when creating a project cf",- with_ee: %i[custom_fields_in_projects_list] do+ context "when creating a project cf" dolet(:model_instance) { build_stubbed(:project_custom_field) }it "modifies the settings on successful call" dodiff --git a/spec/services/queries/projects/project_queries/set_attributes_service_spec.rb b/spec/services/queries/projects/project_queries/set_attributes_service_spec.rbindex 77f8c954adb..5a6fa1101e6 100644--- a/spec/services/queries/projects/project_queries/set_attributes_service_spec.rb+++ b/spec/services/queries/projects/project_queries/set_attributes_service_spec.rb@@ -167,26 +167,27 @@ RSpec.describe Queries::Projects::ProjectQueries::SetAttributesService, type: :m.to eql [[:active, "=", %w[t]]]end- it "assigns default selects including those for admin and ee if allowed",- with_ee: %i[custom_fields_in_projects_list],+ # rubocop:disable Naming/VariableNumber+ it "assigns default selects for non admin",with_settings: { enabled_projects_columns: %w[name created_at cf_1] } do- allow(User.current)- .to receive(:admin?)- .and_return(true)-subjectexpect(model_instance.selects.map(&:attribute))- .to eql %i[favored] + Setting.enabled_projects_columns.map(&:to_sym)+ .to eql %i[favored name cf_1]end- it "assigns default selects excluding those for admin and ee if not allowed",+ it "assigns default selects for admin",with_settings: { enabled_projects_columns: %w[name created_at cf_1] } do+ allow(User.current)+ .to receive(:admin?)+ .and_return(true)+subjectexpect(model_instance.selects.map(&:attribute))- .to eql %i[favored name]+ .to eql %i[favored name created_at cf_1]end+ # rubocop:enable Naming/VariableNumberendcontext "with the query already having order and with order params" do