Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/deployment_spec.rb')
-rw-r--r--spec/models/deployment_spec.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index cb2c38c15e0..d260e75871d 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -56,6 +56,8 @@ RSpec.describe Deployment, feature_category: :continuous_delivery do
let(:scope_attrs) { { project: project } }
let(:usage) { :deployments }
end
+
+ it { is_expected.to include_module(EachBatch) }
end
describe '.stoppable' do
@@ -878,7 +880,7 @@ RSpec.describe Deployment, feature_category: :continuous_delivery do
context 'when the SHA for the deployment does not exist in the repo' do
it 'returns false' do
- deployment.update!(sha: Gitlab::Git::BLANK_SHA)
+ deployment.update!(sha: Gitlab::Git::SHA1_BLANK_SHA)
commit = project.commit
expect(deployment.includes_commit?(commit.id)).to be false
@@ -1537,6 +1539,18 @@ RSpec.describe Deployment, feature_category: :continuous_delivery do
expect(project.commit(deployment.ref_path)).not_to be_nil
end
end
+
+ it 'does not trigger N+1 queries' do
+ project = create(:project, :repository)
+ environment = create(:environment, project: project)
+ create(:deployment, environment: environment, project: project)
+
+ control = ActiveRecord::QueryRecorder.new { project.deployments.fast_destroy_all }
+
+ create_list(:deployment, 2, environment: environment, project: project)
+
+ expect { project.deployments.fast_destroy_all }.not_to exceed_query_limit(control)
+ end
end
describe '#update_merge_request_metrics!' do