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
[#55021] project list export drops the `id` and `identifier` default
Tobias Dillmanna8d365ec4007
diff --git a/app/models/projects/exports/query_exporter.rb b/app/models/projects/exports/query_exporter.rbindex a26d2ec7e69..e4a110afd9b 100644--- a/app/models/projects/exports/query_exporter.rb+++ b/app/models/projects/exports/query_exporter.rb@@ -32,7 +32,7 @@ module Projects::Exportsalias :query :objectdef columns- @columns ||= (forced_columns + selected_columns)+ @columns ||= selected_columnsenddef page@@ -51,13 +51,6 @@ module Projects::Exportsprivate- def forced_columns- [- { name: :id, caption: Project.human_attribute_name(:id) },- { name: :identifier, caption: Project.human_attribute_name(:identifier) }- ]- end-def selected_columnsquery.selectsdiff --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 bddf083e139..69081bee1c3 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@@ -27,8 +27,7 @@ RSpec.describe XlsExport::Project::Exporter::XLS doit "performs a successful export" doexpect(rows.count).to eq(1)- expect(sheet.row(1)).to eq [project.id.to_s, project.identifier,- project.name, project.description, "Off track", "false"]+ expect(sheet.row(1)).to eq [project.name, project.description, "Off track", "false"]endcontext "with project description containing html" do@@ -38,8 +37,7 @@ RSpec.describe XlsExport::Project::Exporter::XLS doit "performs a successful export" doexpect(rows.count).to eq(1)- expect(sheet.row(1)).to eq [project.id.to_s, project.identifier, project.name,- "This is an html description.", "Off track", "false"]+ expect(sheet.row(1)).to eq [project.name, "This is an html description.", "Off track", "false"]endend@@ -48,12 +46,21 @@ RSpec.describe XlsExport::Project::Exporter::XLS doit "performs a successful export" doexpect(rows.count).to eq(1)- expect(sheet.row(1)).to eq [project.id.to_s, project.identifier,- project.name, project.description,+ expect(sheet.row(1)).to eq [project.name, project.description,"Off track", project.status_explanation, "false"]endend+ context "with id and identifier enabled" do+ let(:query_columns) { %w[name description project_status public id identifier] }++ it "performs a successful export" do+ expect(rows.count).to eq(1)+ expect(sheet.row(1)).to eq [project.name, project.description, "Off track",+ "false", project.id.to_s, project.identifier]+ end+ end+describe "custom field columns selected" dolet(:query_columns) { %w[name description project_status public] + global_project_custom_fields.map(&:column_name) }@@ -66,7 +73,7 @@ RSpec.describe XlsExport::Project::Exporter::XLS doit "renders all those columns" docf_names = global_project_custom_fields.map(&:name)- expect(header).to eq ["ID", "Identifier", "Name", "Description", "Status", "Public", *cf_names]+ expect(header).to eq ["Name", "Description", "Status", "Public", *cf_names]expect(header).to include not_used_string_cf.nameexpect(header).to include hidden_cf.name@@ -85,8 +92,7 @@ RSpec.describe XlsExport::Project::Exporter::XLS doendexpect(sheet.row(1))- .to eq [project.id.to_s, project.identifier, project.name, project.description, "Off track", "false",- *custom_values]+ .to eq [project.name, project.description, "Off track", "false", *custom_values]# The column for the project-level-disabled custom field is blankexpect(sheet.row(1)[header.index(not_used_string_cf.name)]).to be_nil@@ -97,7 +103,7 @@ RSpec.describe XlsExport::Project::Exporter::XLS doit "renders available project custom fields in the header if enabled in any project" docf_names = global_project_custom_fields.map(&:name)- expect(header).to eq ["ID", "Identifier", "Name", "Description", "Status", "Public", *cf_names]+ expect(header).to eq ["Name", "Description", "Status", "Public", *cf_names]expect(header).not_to include not_used_string_cf.nameexpect(header).not_to include hidden_cf.name@@ -116,8 +122,7 @@ RSpec.describe XlsExport::Project::Exporter::XLS doendexpect(sheet.row(1))- .to eq [project.id.to_s, project.identifier, project.name, project.description, "Off track", "false",- *custom_values]+ .to eq [project.name, project.description, "Off track", "false", *custom_values]endend@@ -125,10 +130,10 @@ RSpec.describe XlsExport::Project::Exporter::XLS dolet(: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(header).to eq %w[Name Description Status Public]expect(sheet.row(1))- .to eq [project.id.to_s, project.identifier, project.name, project.description, "Off track", "false"]+ .to eq [project.name, project.description, "Off track", "false"]endendenddiff --git a/spec/models/projects/exporter/csv_integration_spec.rb b/spec/models/projects/exporter/csv_integration_spec.rbindex 11dcb17aa1d..77d5e362d2c 100644--- a/spec/models/projects/exporter/csv_integration_spec.rb+++ b/spec/models/projects/exporter/csv_integration_spec.rb@@ -43,8 +43,7 @@ RSpec.describe Projects::Exports::CSV, "integration" doit "performs a successful export" doexpect(parsed.size).to eq(2)- expect(parsed.last).to eq [project.id.to_s, project.identifier,- project.name, project.description, "Off track", "false"]+ expect(parsed.last).to eq [project.name, project.description, "Off track", "false"]endcontext "with status_explanation enabled" do@@ -52,12 +51,21 @@ RSpec.describe Projects::Exports::CSV, "integration" doit "performs a successful export" doexpect(parsed.size).to eq(2)- expect(parsed.last).to eq [project.id.to_s, project.identifier,- project.name, project.description,+ expect(parsed.last).to eq [project.name, project.description,"Off track", "some explanation", "false"]endend+ context "with id and identifier selected" do+ let(:query_columns) { %w[name description id identifier project_status public] }++ it "performs a successful export" do+ expect(parsed.size).to eq(2)+ expect(parsed.last).to eq [project.name, project.description, project.id.to_s,+ project.identifier, "Off track", "false"]+ end+ end+describe "custom field columns selected" dolet(:query_columns) do%w[name description project_status public] + global_project_custom_fields.map(&:column_name)@@ -74,13 +82,12 @@ RSpec.describe Projects::Exports::CSV, "integration" doit "does not render project custom fields in the header" doexpect(parsed.size).to eq 2- expect(header).to eq ["\xEF\xBB\xBFid", "Identifier", "Name", "Description", "Status", "Public"]+ expect(header).to eq ["\xEF\xBB\xBFName", "Description", "Status", "Public"]endit "does not render the custom field values in the rows if enabled for a project" doexpect(rows.first)- .to eq [project.id.to_s, project.identifier, project.name,- project.description, "Off track", "false"]+ .to eq [project.name, project.description, "Off track", "false"]endend@@ -93,7 +100,7 @@ RSpec.describe Projects::Exports::CSV, "integration" doexpect(cf_names).not_to include(not_used_string_cf.name)expect(cf_names).not_to include(hidden_cf.name)- expect(header).to eq ["\xEF\xBB\xBFid", "Identifier", "Name", "Description", "Status", "Public", *cf_names]+ expect(header).to eq ["\xEF\xBB\xBFName", "Description", "Status", "Public", *cf_names]endit "renders the custom field values in the rows if enabled for a project" do@@ -110,8 +117,7 @@ RSpec.describe Projects::Exports::CSV, "integration" doendendexpect(rows.first)- .to eq [project.id.to_s, project.identifier, project.name,- project.description, "Off track", "false", *custom_values]+ .to eq [project.name, project.description, "Off track", "false", *custom_values]endend@@ -126,7 +132,7 @@ RSpec.describe Projects::Exports::CSV, "integration" doexpect(cf_names).to include(not_used_string_cf.name)expect(cf_names).to include(hidden_cf.name)- expect(header).to eq ["\xEF\xBB\xBFid", "Identifier", "Name", "Description", "Status", "Public", *cf_names]+ expect(header).to eq ["\xEF\xBB\xBFName", "Description", "Status", "Public", *cf_names]endit "renders the custom field values in the rows if enabled for a project" do@@ -145,8 +151,7 @@ RSpec.describe Projects::Exports::CSV, "integration" doendendexpect(rows.first)- .to eq [project.id.to_s, project.identifier, project.name,- project.description, "Off track", "false", *custom_values]+ .to eq [project.name, project.description, "Off track", "false", *custom_values]endendend