diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-11-27 22:59:01 +0100 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-11-28 00:36:50 +0100 |
commit | 13a902a9a42c0909ad8c6790c040447a9e12211f (patch) | |
tree | 6eb605aae6e13b77905e1df87b2d32842dffc07d /spec/finders | |
parent | 9d27ce1630004e37cd0615830857a3135dc8d5fe (diff) | |
download | gitlab-ce-13a902a9a42c0909ad8c6790c040447a9e12211f.tar.gz |
Refactorize jobs finding logic
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/runner_jobs_finder_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/finders/runner_jobs_finder_spec.rb b/spec/finders/runner_jobs_finder_spec.rb new file mode 100644 index 00000000000..4275b1a7ff1 --- /dev/null +++ b/spec/finders/runner_jobs_finder_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe RunnerJobsFinder do + let(:project) { create(:project) } + let(:runner) { create(:ci_runner, :shared) } + + subject { described_class.new(runner, params).execute } + + describe '#execute' do + context 'when params is empty' do + let(:params) { {} } + let!(:job) { create(:ci_build, runner: runner, project: project) } + let!(:job1) { create(:ci_build, project: project) } + + it 'returns all jobs assigned to Runner' do + is_expected.to match_array(job) + is_expected.not_to match_array(job1) + end + end + + context 'when params contains status' do + HasStatus::AVAILABLE_STATUSES.each do |target_status| + context "when status is #{target_status}" do + let(:params) { { status: target_status } } + let!(:job) { create(:ci_build, runner: runner, project: project, status: target_status) } + + before do + exception_status = HasStatus::AVAILABLE_STATUSES - [target_status] + create(:ci_build, runner: runner, project: project, status: exception_status.first) + end + + it 'returns matched job' do + is_expected.to eq([job]) + end + end + end + end + end +end |