diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/finders/ci | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/finders/ci')
-rw-r--r-- | spec/finders/ci/runners_finder_spec.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/finders/ci/runners_finder_spec.rb b/spec/finders/ci/runners_finder_spec.rb index e7ec4f01995..aeab5a51766 100644 --- a/spec/finders/ci/runners_finder_spec.rb +++ b/spec/finders/ci/runners_finder_spec.rb @@ -49,6 +49,67 @@ RSpec.describe Ci::RunnersFinder do end end + context 'by upgrade status' do + let(:upgrade_status) {} + + let_it_be(:runner1) { create(:ci_runner, version: 'a') } + let_it_be(:runner2) { create(:ci_runner, version: 'b') } + let_it_be(:runner3) { create(:ci_runner, version: 'c') } + let_it_be(:runner_version_recommended) do + create(:ci_runner_version, version: 'a', status: :recommended) + end + + let_it_be(:runner_version_not_available) do + create(:ci_runner_version, version: 'b', status: :not_available) + end + + let_it_be(:runner_version_available) do + create(:ci_runner_version, version: 'c', status: :available) + end + + def execute + described_class.new(current_user: admin, params: { upgrade_status: upgrade_status }).execute + end + + Ci::RunnerVersion.statuses.keys.map(&:to_sym).each do |status| + context "set to :#{status}" do + let(:upgrade_status) { status } + + it "calls with_upgrade_status scope with corresponding :#{status} status" do + if [:available, :not_available, :recommended].include?(status) + expected_result = Ci::Runner.with_upgrade_status(status) + end + + expect(Ci::Runner).to receive(:with_upgrade_status).with(status).and_call_original + + result = execute + + expect(result).to match_array(expected_result) if expected_result + end + end + end + + context 'set to an invalid value' do + let(:upgrade_status) { :some_invalid_status } + + it 'does not call with_upgrade_status' do + expect(Ci::Runner).not_to receive(:with_upgrade_status) + + expect(execute).to match_array(Ci::Runner.all) + end + end + + context 'set to nil' do + let(:upgrade_status) { nil } + + it 'does not call with_upgrade_status' do + expect(Ci::Runner).not_to receive(:with_upgrade_status) + + expect(execute).to match_array(Ci::Runner.all) + end + end + end + context 'by status' do Ci::Runner::AVAILABLE_STATUSES.each do |status| it "calls the corresponding :#{status} scope on Ci::Runner" do |