summaryrefslogtreecommitdiff
path: root/spec/models/deployment_spec.rb
diff options
context:
space:
mode:
authorPeter Leitzen <pleitzen@gitlab.com>2018-10-12 14:10:34 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-10-12 14:10:34 +0000
commit4d9ede0be7ea4dae92d224454616f9e65da0a3e1 (patch)
treeb21808ddd85a2114bea1502a6ec06b16894e0ef2 /spec/models/deployment_spec.rb
parent0047869c27f0aede95f20de41c8498b7c23bf08d (diff)
downloadgitlab-ce-4d9ede0be7ea4dae92d224454616f9e65da0a3e1.tar.gz
Backport CE changes for Ops Dashboard in EE
Diffstat (limited to 'spec/models/deployment_spec.rb')
-rw-r--r--spec/models/deployment_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index b335e0fbeb3..182070781dd 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -39,6 +39,29 @@ describe Deployment do
end
end
+ describe 'scopes' do
+ describe 'last_for_environment' do
+ let(:production) { create(:environment) }
+ let(:staging) { create(:environment) }
+ let(:testing) { create(:environment) }
+
+ let!(:deployments) do
+ [
+ create(:deployment, environment: production),
+ create(:deployment, environment: staging),
+ create(:deployment, environment: production)
+ ]
+ end
+
+ it 'retrieves last deployments for environments' do
+ last_deployments = described_class.last_for_environment([staging, production, testing])
+
+ expect(last_deployments.size).to eq(2)
+ expect(last_deployments).to eq(deployments.last(2))
+ end
+ end
+ end
+
describe '#includes_commit?' do
let(:project) { create(:project, :repository) }
let(:environment) { create(:environment, project: project) }