diff options
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r-- | spec/models/project_spec.rb | 77 |
1 files changed, 45 insertions, 32 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 5e63f14b720..a01f76a5bab 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -145,25 +145,10 @@ describe Project do end describe 'ci_pipelines association' do - context 'when feature flag pipeline_ci_sources_only is enabled' do - it 'returns only pipelines from ci_sources' do - stub_feature_flags(pipeline_ci_sources_only: true) + it 'returns only pipelines from ci_sources' do + expect(Ci::Pipeline).to receive(:ci_sources).and_call_original - expect(Ci::Pipeline).to receive(:ci_sources).and_call_original - - subject.ci_pipelines - end - end - - context 'when feature flag pipeline_ci_sources_only is disabled' do - it 'returns all pipelines' do - stub_feature_flags(pipeline_ci_sources_only: false) - - expect(Ci::Pipeline).not_to receive(:ci_sources).and_call_original - expect(Ci::Pipeline).to receive(:all).and_call_original.at_least(:once) - - subject.ci_pipelines - end + subject.ci_pipelines end end end @@ -1666,26 +1651,54 @@ describe Project do end describe '#track_project_repository' do - let(:project) { create(:project, :repository) } + shared_examples 'tracks storage location' do + context 'when a project repository entry does not exist' do + it 'creates a new entry' do + expect { project.track_project_repository }.to change(project, :project_repository) + end + + it 'tracks the project storage location' do + project.track_project_repository + + expect(project.project_repository).to have_attributes( + disk_path: project.disk_path, + shard_name: project.repository_storage + ) + end + end + + context 'when a tracking entry exists' do + let!(:project_repository) { create(:project_repository, project: project) } + let!(:shard) { create(:shard, name: 'foo') } + + it 'does not create a new entry in the database' do + expect { project.track_project_repository }.not_to change(project, :project_repository) + end + + it 'updates the project storage location' do + allow(project).to receive(:disk_path).and_return('fancy/new/path') + allow(project).to receive(:repository_storage).and_return('foo') - it 'creates a project_repository' do - project.track_project_repository + project.track_project_repository - expect(project.reload.project_repository).to be_present - expect(project.project_repository.disk_path).to eq(project.disk_path) - expect(project.project_repository.shard_name).to eq(project.repository_storage) + expect(project.project_repository).to have_attributes( + disk_path: 'fancy/new/path', + shard_name: 'foo' + ) + end + end end - it 'updates the project_repository' do - project.track_project_repository + context 'with projects on legacy storage' do + let(:project) { create(:project, :repository, :legacy_storage) } - allow(project).to receive(:disk_path).and_return('@fancy/new/path') + it_behaves_like 'tracks storage location' + end - expect do - project.track_project_repository - end.not_to change(ProjectRepository, :count) + context 'with projects on hashed storage' do + let(:project) { create(:project, :repository) } - expect(project.reload.project_repository.disk_path).to eq(project.disk_path) + it_behaves_like 'tracks storage location' end end @@ -3690,7 +3703,7 @@ describe Project do expect(project.badges.count).to eq 3 end - if Group.supports_nested_groups? + if Group.supports_nested_objects? context 'with nested_groups' do let(:parent_group) { create(:group) } |