From 0cf37693fab10d8e6e5dce5efb10a00f7d4082ac Mon Sep 17 00:00:00 2001 From: charlie ablett Date: Tue, 18 Jan 2022 22:47:59 +1300 Subject: [PATCH 1/2] Modifies a settings page call - removes project.owner Update tests --- app/helpers/avatars_helper.rb | 4 ++-- app/models/project.rb | 3 +++ .../views/projects/settings/subscriptions/_project.html.haml | 4 ++-- .../features/projects/settings/pipeline_subscriptions_spec.rb | 2 +- spec/helpers/avatars_helper_spec.rb | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index dd852a68682dff..2d754bd99e900a 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -103,8 +103,8 @@ def user_avatar(options = {}) end def avatar_without_link(resource, options = {}) - if resource.is_a?(User) - user_avatar_without_link(options.merge(user: resource)) + if resource.is_a?(Namespaces::UserNamespace) + user_avatar_without_link(options.merge(user: resource.first_owner)) elsif resource.is_a?(Group) group_icon(resource, options.merge(class: 'avatar')) end diff --git a/app/models/project.rb b/app/models/project.rb index f2b3db684ae8ad..5adeb60f7c7051 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1513,6 +1513,9 @@ def send_move_instructions(old_path_with_namespace) # rubocop: enable CodeReuse/ServiceClass def owner + # This will be phased out and replaced with `owners` relationship + # backed by memberships with direct/inherited Owner access roles + # See https://gitlab.com/gitlab-org/gitlab/-/issues/241503 group || namespace.try(:owner) end diff --git a/ee/app/views/projects/settings/subscriptions/_project.html.haml b/ee/app/views/projects/settings/subscriptions/_project.html.haml index 676967615311a4..d42913d116b8f2 100644 --- a/ee/app/views/projects/settings/subscriptions/_project.html.haml +++ b/ee/app/views/projects/settings/subscriptions/_project.html.haml @@ -5,8 +5,8 @@ = link_to project.name, project_path(project) %td .gl-display-flex.gl-align-items-center - = avatar_without_link(project.owner, size: 32) - = project.owner.name + = avatar_without_link(project.namespace, size: 32) + = project.namespace.name - if is_upstream_mode %td.gl-text-right = link_to project_subscription_path(@project, subscription.id), method: :delete, data: { toggle: 'tooltip', title: tooltip, container: 'body', testid: 'delete-subscription' }, class: "gl-button btn btn-danger" do diff --git a/ee/spec/features/projects/settings/pipeline_subscriptions_spec.rb b/ee/spec/features/projects/settings/pipeline_subscriptions_spec.rb index fe90126eadfaa1..aab144997c07d0 100644 --- a/ee/spec/features/projects/settings/pipeline_subscriptions_spec.rb +++ b/ee/spec/features/projects/settings/pipeline_subscriptions_spec.rb @@ -55,7 +55,7 @@ end expect(page).to have_content(upstream_project.name) - expect(page).to have_content(upstream_project.owner.name) + expect(page).to have_content(upstream_project.namespace.name) end expect(page).to have_content('Subscription successfully created.') diff --git a/spec/helpers/avatars_helper_spec.rb b/spec/helpers/avatars_helper_spec.rb index 7190f2fcd4afc6..a6195e47c30336 100644 --- a/spec/helpers/avatars_helper_spec.rb +++ b/spec/helpers/avatars_helper_spec.rb @@ -428,7 +428,7 @@ subject { helper.avatar_without_link(resource, options) } context 'with users' do - let(:resource) { user } + let(:resource) { user.namespace } it 'displays user avatar' do is_expected.to eq tag( -- GitLab From c4289ef6e01350e3fb75ab2b95600d98699fccba Mon Sep 17 00:00:00 2001 From: Anna Vovchenko Date: Fri, 21 Jan 2022 09:53:37 +0000 Subject: [PATCH 2/2] Use promoted epic link in the comment --- app/models/project.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index 5adeb60f7c7051..649ad9000806a5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1515,7 +1515,7 @@ def send_move_instructions(old_path_with_namespace) def owner # This will be phased out and replaced with `owners` relationship # backed by memberships with direct/inherited Owner access roles - # See https://gitlab.com/gitlab-org/gitlab/-/issues/241503 + # See https://gitlab.com/groups/gitlab-org/-/epics/7405 group || namespace.try(:owner) end -- GitLab