Skip to content
Snippets Groups Projects
Verified Commit 09155f39 authored by Terri Chu's avatar Terri Chu :nail_care: Committed by GitLab
Browse files

Merge branch 'tchu-fix-owner-not-set-for-project-indexing' into 'master'

Handle null owner when indexing projects

See merge request !147951



Merged-by: Terri Chu's avatarTerri Chu <tchu@gitlab.com>
parents 33c24fa6 059908f5
No related branches found
No related tags found
No related merge requests found
Pipeline #1229818361 passed
Pipeline: E2E Omnibus GitLab EE

#1229922992

    Pipeline: E2E GDK

    #1229832148

      Pipeline: GitLab

      #1229829477

        +1
        ......@@ -51,7 +51,7 @@ def as_indexed_json(_options = {})
        if ::Elastic::DataMigrationService.migration_has_finished?(:add_fields_to_projects_index)
        data['mirror'] = target.mirror?
        data['forked'] = target.forked? || false
        data['owner_id'] = target.owner.id
        data['owner_id'] = target.owner&.id
        data['repository_languages'] = target.repository_languages.map(&:name)
        end
        ......
        ......@@ -122,6 +122,16 @@
        repository_languages: project.repository_languages.map(&:name)
        )
        end
        context 'when project does not have an owner' do
        it 'does not throw an exception' do
        allow(project).to receive(:owner).and_return(nil)
        result = proxy.as_indexed_json.with_indifferent_access
        expect(result[:owner_id]).to be_nil
        end
        end
        end
        end
        ......@@ -176,10 +186,10 @@
        let_it_be(:group) { create(:group) }
        let_it_be(:target) { create(:project, group: group) }
        subject { described_class.new(target).es_parent }
        subject(:es_parent) { described_class.new(target).es_parent }
        it 'is the root namespace id' do
        expect(subject).to eq("n_#{group.id}")
        expect(es_parent).to eq("n_#{group.id}")
        end
        context 'if migration is not finished' do
        ......@@ -188,7 +198,7 @@
        end
        it 'is nil' do
        expect(subject).to be_nil
        expect(es_parent).to be_nil
        end
        end
        end
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment