| ... | @@ -90,11 +90,21 @@ describe PostReceive do |
... | @@ -90,11 +90,21 @@ describe PostReceive do |
|
|
end
|
|
end
|
|
|
|
|
|
|
|
context "gitlab-ci.yml" do
|
|
context "gitlab-ci.yml" do
|
|
|
let(:changes) { "123456 789012 refs/heads/feature\n654321 210987 refs/tags/tag" }
|
|
let(:changes) do
|
|
|
|
<<-EOF.strip_heredoc
|
|
|
|
123456 789012 refs/heads/feature
|
|
|
|
654321 210987 refs/tags/tag
|
|
|
|
123456 789012 refs/heads/feature2
|
|
|
|
123458 789013 refs/heads/feature3
|
|
|
|
123459 789015 refs/heads/feature4
|
|
|
|
EOF
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:changes_count) { changes.lines.count }
|
|
|
|
|
|
|
|
subject { described_class.new.perform(gl_repository, key_id, base64_changes) }
|
|
subject { described_class.new.perform(gl_repository, key_id, base64_changes) }
|
|
|
|
|
|
|
|
context "creates a Ci::Pipeline for every change" do
|
|
context "with valid .gitlab-ci.yml" do
|
|
|
before do
|
|
before do
|
|
|
stub_ci_pipeline_to_return_yaml_file
|
|
stub_ci_pipeline_to_return_yaml_file
|
|
|
|
|
|
| ... | @@ -107,7 +117,33 @@ describe PostReceive do |
... | @@ -107,7 +117,33 @@ describe PostReceive do |
|
|
.and_return(true)
|
|
.and_return(true)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
it { expect { subject }.to change { Ci::Pipeline.count }.by(2) }
|
|
context 'when git_push_create_all_pipelines is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(git_push_create_all_pipelines: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates pipeline for branches and tags" do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(Ci::Pipeline.pluck(:ref)).to contain_exactly("feature", "tag", "feature2", "feature3")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates exactly #{described_class::PIPELINE_PROCESS_LIMIT} pipelines" do
|
|
|
|
expect(changes_count).to be > described_class::PIPELINE_PROCESS_LIMIT
|
|
|
|
|
|
|
|
expect { subject }.to change { Ci::Pipeline.count }.by(described_class::PIPELINE_PROCESS_LIMIT)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when git_push_create_all_pipelines is enabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(git_push_create_all_pipelines: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates all pipelines" do
|
|
|
|
expect { subject }.to change { Ci::Pipeline.count }.by(changes_count)
|
|
|
|
end
|
|
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
context "does not create a Ci::Pipeline" do
|
|
context "does not create a Ci::Pipeline" do
|
| ... | |
... | |
| ... | | ... | |