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
fixed and enriched project csv export specs
Jonas Jabari0f578f8b5cf9
diff --git a/spec/models/projects/exporter/csv_integration_spec.rb b/spec/models/projects/exporter/csv_integration_spec.rbindex 8f72518e42b..d8a03f2d4a7 100644--- a/spec/models/projects/exporter/csv_integration_spec.rb+++ b/spec/models/projects/exporter/csv_integration_spec.rb@@ -62,22 +62,31 @@ RSpec.describe Projects::Exports::CSV, 'integration' dodescribe 'custom field columns selected' dobefore do- Setting.enabled_projects_columns += custom_fields.map(&:column_name)+ Setting.enabled_projects_columns += global_project_custom_fields.map(&:column_name)endcontext 'when ee enabled', with_ee: %i[custom_fields_in_projects_list] do- it 'renders all those columns' do+ it 'renders all globally available project custom fields in the header' doexpect(parsed.size).to eq 2- cf_names = custom_fields.map(&:name)+ cf_names = global_project_custom_fields.map(&:name)++ expect(cf_names).to include(not_used_string_cf.name)+expect(header).to eq ['id', 'Identifier', 'Name', 'Description', 'Status', 'Public', *cf_names]+ end- custom_values = custom_fields.map do |cf|+ it 'renders the custom field values in the rows if enabled for a project' do+ expect(parsed.size).to eq 2++ custom_values = global_project_custom_fields.map do |cf|case cfwhen bool_cf'true'when text_cfproject.typed_custom_value_for(cf)+ when not_used_string_cf+ ''elseproject.formatted_custom_value_for(cf)end@@ -85,6 +94,9 @@ RSpec.describe Projects::Exports::CSV, 'integration' doexpect(rows.first).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(rows.first[header.index(not_used_string_cf.name)]).to eq ''endenddiff --git a/spec/models/projects/exporter/exportable_project_context.rb b/spec/models/projects/exporter/exportable_project_context.rbindex 25c97c615e4..b62b5b24c18 100644--- a/spec/models/projects/exporter/exportable_project_context.rb+++ b/spec/models/projects/exporter/exportable_project_context.rb@@ -36,6 +36,8 @@ RSpec.shared_context 'with a project with an arrangement of custom fields' doshared_let(:string_cf) { create(:string_project_custom_field, position: 7) }shared_let(:date_cf) { create(:date_project_custom_field, position: 8) }+ let!(:not_used_string_cf) { create(:string_project_custom_field, position: 9) }+shared_let(:system_version) { create(:version, sharing: 'system') }shared_let(:role) do@@ -49,22 +51,24 @@ RSpec.shared_context 'with a project with an arrangement of custom fields' doendshared_let(:project) do- create(:project,- status_code: 'off_track',- status_explanation: 'some explanation',- members: { other_user => role }).tap do |p|- p.description = "The description of the project"- p.send(int_cf.attribute_setter, 5)- p.send(bool_cf.attribute_setter, true)- p.send(version_cf.attribute_setter, system_version)- p.send(float_cf.attribute_setter, 4.5)- p.send(text_cf.attribute_setter, 'Some **long** text')- p.send(string_cf.attribute_setter, 'Some small text')- p.send(date_cf.attribute_setter, Time.zone.today)- p.send(user_cf.attribute_setter, other_user)+ project = build(:project,+ status_code: 'off_track',+ status_explanation: 'some explanation',+ members: { other_user => role },+ description: "The description of the project",+ custom_field_values: {+ int_cf.id => 5,+ bool_cf.id => true,+ version_cf.id => system_version,+ float_cf.id => 4.5,+ text_cf.id => 'Some **long** text',+ string_cf.id => 'Some small text',+ date_cf.id => Time.zone.today,+ user_cf.id => other_user.id+ })+ project.save!(validate: false)- p.save!(validate: false)- end+ projectendend@@ -82,7 +86,8 @@ RSpec.shared_context 'with an instance of the described exporter' dodescribed_class.new(query)end- let(:custom_fields) { project.available_custom_fields }+ let(:global_project_custom_fields) { ProjectCustomField.all }+ let(:custom_fields_of_project) { project.available_custom_fields }let(:output) doinstance.export!.content