Skip to content

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

Fix/nil parent rendering (#9339)

ulferts4cd75489ffbc
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f5c9f2ae4d2..311319175e6 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2787,9 +2787,6 @@ en:
total_progress: "Total progress"
- undisclosed:
- parent: Undisclosed - The selected parent is invisible because of lacking permissions.
-
user:
all: "all"
active: "active"
@@ -2934,6 +2931,9 @@ en:
resources:
schema: 'Schema'
+ undisclosed:
+ parent: Undisclosed - The selected parent is invisible because of lacking permissions.
+
doorkeeper:
pre_authorization:
status: 'Pre-authorization'
diff --git a/lib/api/decorators/linked_resource.rb b/lib/api/decorators/linked_resource.rb
index 5128d7ff30f..7fa2cdf08f1 100644
--- a/lib/api/decorators/linked_resource.rb
+++ b/lib/api/decorators/linked_resource.rb
@@ -186,7 +186,7 @@ module API
if undisclosed && instance_exec(&skip_link)
{
href: API::V3::URN_UNDISCLOSED,
- title: I18n.t(:"undisclosed.#{name}")
+ title: I18n.t(:"api_v3.undisclosed.#{name}")
}
elsif !instance_exec(&skip_link)
::API::Decorators::LinkObject
diff --git a/lib/api/v3/projects/project_representer.rb b/lib/api/v3/projects/project_representer.rb
index fb93abbc3ac..33daac614d0 100644
--- a/lib/api/v3/projects/project_representer.rb
+++ b/lib/api/v3/projects/project_representer.rb
@@ -158,7 +158,7 @@ module API
representer: ::API::V3::Projects::ProjectRepresenter,
uncacheable_link: true,
undisclosed: true,
- skip_render: ->(*) { !represented.parent&.visible? }
+ skip_render: ->(*) { represented.parent && !represented.parent.visible? }
property :id
property :identifier,
diff --git a/spec/features/projects/edit_settings_spec.rb b/spec/features/projects/edit_settings_spec.rb
index 2d4baa086cd..c2ae1bb24b9 100644
--- a/spec/features/projects/edit_settings_spec.rb
+++ b/spec/features/projects/edit_settings_spec.rb
@@ -192,7 +192,7 @@ describe 'Projects', 'editing settings', type: :feature, js: true do
fill_in 'Name', with: 'New project name'
- parent_field.expect_selected I18n.t(:'undisclosed.parent')
+ parent_field.expect_selected I18n.t(:'api_v3.undisclosed.parent')
click_on 'Save'
diff --git a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb b/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
index 08bcd692949..7a07b75f27e 100644
--- a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
@@ -215,7 +215,16 @@ describe ::API::V3::Projects::ProjectRepresenter, 'rendering' do
it_behaves_like 'has a titled link' do
let(:link) { 'parent' }
let(:href) { API::V3::URN_UNDISCLOSED }
- let(:title) { I18n.t(:'undisclosed.parent') }
+ let(:title) { I18n.t(:'api_v3.undisclosed.parent') }
+ end
+ end
+
+ context 'without a parent' do
+ let(:parent_project) { nil }
+
+ it_behaves_like 'has an untitled link' do
+ let(:link) { 'parent' }
+ let(:href) { nil }
end
end
end