diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 06:06:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 06:06:28 +0300 |
commit | 0ecdcf59f4342de55a7d2c3ee4ac0d9c3b116aa5 (patch) | |
tree | 07b26906534f336e9dcd708afbeef8612d1c93f2 /spec | |
parent | 5a3f1ba53bf875a73f800909e8559d15dfab4339 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/ci/build_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/ci/persistent_ref_spec.rb | 12 | ||||
-rw-r--r-- | spec/models/merge_request_diff_spec.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/runner_spec.rb | 10 |
4 files changed, 41 insertions, 3 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 24fa3b9b1ea..cc713443a0a 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -3086,10 +3086,20 @@ describe Ci::Build do rescue StateMachines::InvalidTransition end - it 'ensures pipeline ref existence' do - expect(job.pipeline.persistent_ref).to receive(:create).once + context 'for pipeline ref existence' do + it 'ensures pipeline ref creation' do + expect(job.pipeline.persistent_ref).to receive(:create).once - run_job_without_exception + run_job_without_exception + end + + it 'ensures that it is not run in database transaction' do + expect(job.pipeline.persistent_ref).to receive(:create) do + expect(Gitlab::Database).not_to be_inside_transaction + end + + run_job_without_exception + end end shared_examples 'saves data on transition' do diff --git a/spec/models/ci/persistent_ref_spec.rb b/spec/models/ci/persistent_ref_spec.rb index be447476e2c..71e0b03dff9 100644 --- a/spec/models/ci/persistent_ref_spec.rb +++ b/spec/models/ci/persistent_ref_spec.rb @@ -45,6 +45,18 @@ describe Ci::PersistentRef do expect(pipeline.persistent_ref).to be_exist end + context 'when depend_on_persistent_pipeline_ref feature flag is disabled' do + before do + stub_feature_flags(depend_on_persistent_pipeline_ref: false) + end + + it 'does not create a persistent ref' do + expect(project.repository).not_to receive(:create_ref) + + subject + end + end + context 'when sha does not exist in the repository' do let(:sha) { 'not-exist' } diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index 0f7f68e0b38..b5404658a69 100644 --- a/spec/models/merge_request_diff_spec.rb +++ b/spec/models/merge_request_diff_spec.rb @@ -98,6 +98,12 @@ describe MergeRequestDiff do end it { is_expected.to contain_exactly(outdated.id, latest.id, closed.id, merged.id, closed_recently.id, merged_recently.id) } + + it 'ignores diffs with 0 files' do + MergeRequestDiffFile.where(merge_request_diff_id: [closed_recently.id, merged_recently.id]).delete_all + + is_expected.to contain_exactly(outdated.id, latest.id, closed.id, merged.id) + end end context 'external diffs are enabled for outdated diffs' do diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 6138036b0af..cc6cadb190a 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -513,6 +513,16 @@ describe API::Runner, :clean_gitlab_redis_shared_state do expect(json_response['features']).to eq(expected_features) end + it 'creates persistent ref' do + expect_any_instance_of(Ci::PersistentRef).to receive(:create_ref) + .with(job.sha, "refs/#{Repository::REF_PIPELINES}/#{job.commit_id}") + + request_job info: { platform: :darwin } + + expect(response).to have_gitlab_http_status(201) + expect(json_response['id']).to eq(job.id) + end + context 'when job is made for tag' do let!(:job) { create(:ci_build, :tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) } |