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
Add helper to aid with generating the urls to archived projects
Aaron Contreras6cbc318f282b
diff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rbindex 22c4246e3ba..f66e57b27df 100644--- a/app/helpers/types_helper.rb+++ b/app/helpers/types_helper.rb@@ -113,6 +113,17 @@ module ::TypesHelper::API::V3::Queries::QueryParamsRepresenter.new(query).to_jsonend+ def archived_projects_urls_for(projects)+ urls = projects.map do |project|+ link_to project.name,+ projects_path(filters: archived_project_filters_for(project)),+ target: '_blank',+ rel: 'noopener'+ end++ safe_join(urls, ', ')+ end+private##@@ -140,4 +151,11 @@ module ::TypesHelpertranslation: Type.translated_attribute_name(key, represented)}end++ def archived_project_filters_for(project)+ [+ { active: { operator: '=', values: ['f'] } },+ { name_and_identifier: { operator: '=', values: [html_escape(project.name)] } }+ ].to_json+ endenddiff --git a/spec/helpers/types_helper_spec.rb b/spec/helpers/types_helper_spec.rbindex ae55cd63332..e0f52decb07 100644--- a/spec/helpers/types_helper_spec.rb+++ b/spec/helpers/types_helper_spec.rb@@ -78,4 +78,31 @@ RSpec.describe TypesHelper doendendend++ describe '#archived_projects_urls_for' do+ subject { helper.archived_projects_urls_for([archived_project, other_archived_project]) }++ shared_let(:archived_project) { create(:project, :archived) }+ shared_let(:other_archived_project) { create(:project, :archived) }+ shared_let(:archived_project_filters) do+ "[{\"active\":{\"operator\":\"=\",\"values\":[\"f\"]}}," \+ "{\"name_and_identifier\":{\"operator\":\"=\",\"values\":[\"#{archived_project.name}\"]}}]"+ end+ shared_let(:other_archived_project_filters) do+ "[{\"active\":{\"operator\":\"=\",\"values\":[\"f\"]}}," \+ "{\"name_and_identifier\":{\"operator\":\"=\",\"values\":[\"#{other_archived_project.name}\"]}}]"+ end++ it 'returns a comma-separated list of anchor tags for each archived project' do+ expect(subject)+ .to eq(+ "<a target=\"_blank\" rel=\"noopener\" href=\"#{projects_path(filters: archived_project_filters)}\">" \+ "#{archived_project.name}" \+ "</a>, " \+ "<a target=\"_blank\" rel=\"noopener\" href=\"#{projects_path(filters: other_archived_project_filters)}\">" \+ "#{other_archived_project.name}" \+ "</a>"+ )+ end+ endend