diff options
-rw-r--r-- | lib/gitlab/hook_data/project_builder.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/hook_data/project_builder_spec.rb | 26 |
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/gitlab/hook_data/project_builder.rb b/lib/gitlab/hook_data/project_builder.rb index 56b8b842a78..1f7459e57af 100644 --- a/lib/gitlab/hook_data/project_builder.rb +++ b/lib/gitlab/hook_data/project_builder.rb @@ -54,7 +54,7 @@ module Gitlab # Can be consolidate again once https://gitlab.com/gitlab-org/gitlab/-/issues/432606 is addressed if project.group project.group.all_owner_members.select(:id, :user_id) - .preload_user.find_each.map { |member| owner_data(member.user) } + .preload_user.find_each.map { |member| owner_data(member.user) if member.user } else data = [] project.project_authorizations.owners.preload_user.each_batch(column: :user_id) do |relation| diff --git a/spec/lib/gitlab/hook_data/project_builder_spec.rb b/spec/lib/gitlab/hook_data/project_builder_spec.rb index 9d5eaf0608c..77ab55f3e26 100644 --- a/spec/lib/gitlab/hook_data/project_builder_spec.rb +++ b/spec/lib/gitlab/hook_data/project_builder_spec.rb @@ -12,8 +12,17 @@ RSpec.describe Gitlab::HookData::ProjectBuilder do let(:event_name) { data[:event_name] } let(:attributes) do [ - :event_name, :created_at, :updated_at, :name, :path, :path_with_namespace, :project_id, - :owners, :owner_name, :owner_email, :project_visibility + :created_at, + :event_name, + :name, + :owner_email, + :owner_name, + :owners, + :path, + :path_with_namespace, + :project_id, + :project_visibility, + :updated_at ] end @@ -118,6 +127,19 @@ RSpec.describe Gitlab::HookData::ProjectBuilder do it_behaves_like 'includes the required attributes' it_behaves_like 'does not include `old_path_with_namespace` attribute' + + context 'group has pending owner invitation' do + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, :internal, name: 'group project', namespace: group) } + + let(:owners_data) { [] } + + before do + create(:group_member, :invited, group: group) + end + + it { expect(event_name).to eq('project_create') } + end end context 'on destroy' do |