diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/finders/ci | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/finders/ci')
-rw-r--r-- | spec/finders/ci/jobs_finder_spec.rb | 140 |
1 files changed, 111 insertions, 29 deletions
diff --git a/spec/finders/ci/jobs_finder_spec.rb b/spec/finders/ci/jobs_finder_spec.rb index e6680afa15c..a6a41c36489 100644 --- a/spec/finders/ci/jobs_finder_spec.rb +++ b/spec/finders/ci/jobs_finder_spec.rb @@ -36,53 +36,135 @@ RSpec.describe Ci::JobsFinder, '#execute' do end end - context 'scope is present' do - let(:jobs) { [job_1, job_2, job_3] } - - where(:scope, :index) do - [ - ['pending', 0], - ['running', 1], - ['finished', 2] - ] + context 'with ci_jobs_finder_refactor ff enabled' do + before do + stub_feature_flags(ci_jobs_finder_refactor: true) end - with_them do - let(:params) { { scope: scope } } + context 'scope is present' do + let(:jobs) { [job_1, job_2, job_3] } + + where(:scope, :index) do + [ + ['pending', 0], + ['running', 1], + ['finished', 2] + ] + end + + with_them do + let(:params) { { scope: scope } } - it { expect(subject).to match_array([jobs[index]]) } + it { expect(subject).to match_array([jobs[index]]) } + end end - end - end - context 'a project is present' do - subject { described_class.new(current_user: user, project: project, params: params).execute } + context 'scope is an array' do + let(:jobs) { [job_1, job_2, job_3] } + let(:params) {{ scope: ['running'] }} - context 'user has access to the project' do + it 'filters by the job statuses in the scope' do + expect(subject).to match_array([job_2]) + end + end + end + + context 'with ci_jobs_finder_refactor ff disabled' do before do - project.add_maintainer(user) + stub_feature_flags(ci_jobs_finder_refactor: false) end - it 'returns jobs for the specified project' do - expect(subject).to match_array([job_3]) + context 'scope is present' do + let(:jobs) { [job_1, job_2, job_3] } + + where(:scope, :index) do + [ + ['pending', 0], + ['running', 1], + ['finished', 2] + ] + end + + with_them do + let(:params) { { scope: scope } } + + it { expect(subject).to match_array([jobs[index]]) } + end end end + end - context 'user has no access to project builds' do - before do - project.add_guest(user) + context 'with ci_jobs_finder_refactor ff enabled' do + before do + stub_feature_flags(ci_jobs_finder_refactor: true) + end + + context 'a project is present' do + subject { described_class.new(current_user: user, project: project, params: params).execute } + + context 'user has access to the project' do + before do + project.add_maintainer(user) + end + + it 'returns jobs for the specified project' do + expect(subject).to match_array([job_3]) + end end - it 'returns no jobs' do - expect(subject).to be_empty + context 'user has no access to project builds' do + before do + project.add_guest(user) + 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 - context 'without user' do - let(:user) { nil } + context 'with ci_jobs_finder_refactor ff disabled' do + before do + stub_feature_flags(ci_jobs_finder_refactor: false) + end + context 'a project is present' do + subject { described_class.new(current_user: user, project: project, params: params).execute } - it 'returns no jobs' do - expect(subject).to be_empty + context 'user has access to the project' do + before do + project.add_maintainer(user) + end + + it 'returns jobs for the specified project' do + expect(subject).to match_array([job_3]) + end + end + + context 'user has no access to project builds' do + before do + project.add_guest(user) + 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 |