diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/finders/deployments_finder_spec.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/finders/deployments_finder_spec.rb')
-rw-r--r-- | spec/finders/deployments_finder_spec.rb | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/spec/finders/deployments_finder_spec.rb b/spec/finders/deployments_finder_spec.rb index 51c293bcfd1..efb739c3d2f 100644 --- a/spec/finders/deployments_finder_spec.rb +++ b/spec/finders/deployments_finder_spec.rb @@ -32,7 +32,17 @@ RSpec.describe DeploymentsFinder do it 'raises an error' do expect { subject }.to raise_error( described_class::InefficientQueryError, - '`finished_at` filter and `finished_at` sorting must be paired') + '`finished_at` filter requires `finished_at` sort.') + end + end + + context 'when running status filter and finished_at sorting' do + let(:params) { { status: :running, order_by: :finished_at } } + + it 'raises an error' do + expect { subject }.to raise_error( + described_class::InefficientQueryError, + '`finished_at` sort requires `finished_at` filter or a filter with at least one of the finished statuses.') end end @@ -52,7 +62,17 @@ RSpec.describe DeploymentsFinder do it 'raises an error' do expect { subject }.to raise_error( described_class::InefficientQueryError, - '`environment` filter must be combined with `project` scope.') + '`environment` name filter must be combined with `project` scope.') + end + end + + context 'when status filter with mixed finished and upcoming statuses' do + let(:params) { { status: [:success, :running] } } + + it 'raises an error' do + expect { subject }.to raise_error( + described_class::InefficientQueryError, + 'finished statuses and upcoming statuses must be separately queried.') end end end @@ -103,6 +123,24 @@ RSpec.describe DeploymentsFinder do end end + context 'when the environment ID is specified' do + let!(:environment1) { create(:environment, project: project) } + let!(:environment2) { create(:environment, project: project) } + let!(:deployment1) do + create(:deployment, project: project, environment: environment1) + end + + let!(:deployment2) do + create(:deployment, project: project, environment: environment2) + end + + let(:params) { { environment: environment1.id } } + + it 'returns deployments for the given environment' do + is_expected.to match_array([deployment1]) + end + end + context 'when the deployment status is specified' do let!(:deployment1) { create(:deployment, :success, project: project) } let!(:deployment2) { create(:deployment, :failed, project: project) } |