diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /spec/finders/ci | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'spec/finders/ci')
-rw-r--r-- | spec/finders/ci/daily_build_group_report_results_finder_spec.rb | 2 | ||||
-rw-r--r-- | spec/finders/ci/jobs_finder_spec.rb | 37 | ||||
-rw-r--r-- | spec/finders/ci/runners_finder_spec.rb | 32 |
3 files changed, 57 insertions, 14 deletions
diff --git a/spec/finders/ci/daily_build_group_report_results_finder_spec.rb b/spec/finders/ci/daily_build_group_report_results_finder_spec.rb index cf15a00323b..5352cfe5238 100644 --- a/spec/finders/ci/daily_build_group_report_results_finder_spec.rb +++ b/spec/finders/ci/daily_build_group_report_results_finder_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultsFinder do describe '#execute' do let_it_be(:project) { create(:project, :private) } let(:user_without_permission) { create(:user) } - let_it_be(:user_with_permission) { project.owner } + let_it_be(:user_with_permission) { project.first_owner } let_it_be(:ref_path) { 'refs/heads/master' } let(:limit) { nil } let_it_be(:default_branch) { false } diff --git a/spec/finders/ci/jobs_finder_spec.rb b/spec/finders/ci/jobs_finder_spec.rb index ab056dd26e8..959716b1fd3 100644 --- a/spec/finders/ci/jobs_finder_spec.rb +++ b/spec/finders/ci/jobs_finder_spec.rb @@ -126,4 +126,41 @@ RSpec.describe Ci::JobsFinder, '#execute' do end end end + + context 'a runner is present' do + let_it_be(:runner) { create(:ci_runner, :project, projects: [project]) } + let_it_be(:job_4) { create(:ci_build, :success, runner: runner) } + + subject { described_class.new(current_user: user, runner: runner, params: params).execute } + + context 'user has access to the runner', :enable_admin_mode do + let(:user) { admin } + + it 'returns jobs for the specified project' do + expect(subject).to match_array([job_4]) + end + end + + context 'user has no access to project builds' do + let_it_be(:guest) { create(:user) } + + let(:user) { guest } + + before do + project.add_guest(guest) + end + + it 'returns no jobs' do + expect(subject).to be_empty + end + end + + context 'without user' do + let(:user) { nil } + + it 'returns no jobs' do + expect(subject).to be_empty + end + end + end end diff --git a/spec/finders/ci/runners_finder_spec.rb b/spec/finders/ci/runners_finder_spec.rb index dac244e4300..e7ec4f01995 100644 --- a/spec/finders/ci/runners_finder_spec.rb +++ b/spec/finders/ci/runners_finder_spec.rb @@ -91,8 +91,8 @@ RSpec.describe Ci::RunnersFinder do end context 'sorting' do - let_it_be(:runner1) { create :ci_runner, created_at: '2018-07-12 07:00', contacted_at: 1.minute.ago } - let_it_be(:runner2) { create :ci_runner, created_at: '2018-07-12 08:00', contacted_at: 3.minutes.ago } + let_it_be(:runner1) { create :ci_runner, created_at: '2018-07-12 07:00', contacted_at: 1.minute.ago, token_expires_at: '2022-02-15 07:00' } + let_it_be(:runner2) { create :ci_runner, created_at: '2018-07-12 08:00', contacted_at: 3.minutes.ago, token_expires_at: '2022-02-15 06:00' } let_it_be(:runner3) { create :ci_runner, created_at: '2018-07-12 09:00', contacted_at: 2.minutes.ago } subject do @@ -142,6 +142,22 @@ RSpec.describe Ci::RunnersFinder do is_expected.to eq [runner1, runner3, runner2] end end + + context 'with sort param equal to token_expires_at_asc' do + let(:params) { { sort: 'token_expires_at_asc' } } + + it 'sorts by contacted_at ascending' do + is_expected.to eq [runner2, runner1, runner3] + end + end + + context 'with sort param equal to token_expires_at_desc' do + let(:params) { { sort: 'token_expires_at_desc' } } + + it 'sorts by contacted_at descending' do + is_expected.to eq [runner3, runner1, runner2] + end + end end context 'by non admin user' do @@ -206,7 +222,7 @@ RSpec.describe Ci::RunnersFinder do sub_group_4.runners << runner_sub_group_4 end - shared_examples '#execute' do + describe '#execute' do subject { described_class.new(current_user: user, params: params).execute } shared_examples 'membership equal to :descendants' do @@ -349,16 +365,6 @@ RSpec.describe Ci::RunnersFinder do end end - it_behaves_like '#execute' - - context 'when the FF ci_find_runners_by_ci_mirrors is disabled' do - before do - stub_feature_flags(ci_find_runners_by_ci_mirrors: false) - end - - it_behaves_like '#execute' - end - describe '#sort_key' do subject { described_class.new(current_user: user, params: params.merge(group: group)).sort_key } |