diff options
Diffstat (limited to 'spec/models/ci/runner_spec.rb')
-rw-r--r-- | spec/models/ci/runner_spec.rb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index 953af2c4710..b545e036aa1 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -223,7 +223,7 @@ describe Ci::Runner do subject { described_class.online } before do - @runner1 = create(:ci_runner, :instance, contacted_at: 1.year.ago) + @runner1 = create(:ci_runner, :instance, contacted_at: 1.hour.ago) @runner2 = create(:ci_runner, :instance, contacted_at: 1.second.ago) end @@ -300,6 +300,17 @@ describe Ci::Runner do end end + describe '.offline' do + subject { described_class.offline } + + before do + @runner1 = create(:ci_runner, :instance, contacted_at: 1.hour.ago) + @runner2 = create(:ci_runner, :instance, contacted_at: 1.second.ago) + end + + it { is_expected.to eq([@runner1])} + end + describe '#can_pick?' do set(:pipeline) { create(:ci_pipeline) } let(:build) { create(:ci_build, pipeline: pipeline) } @@ -786,4 +797,22 @@ describe Ci::Runner do expect { subject.destroy }.to change { described_class.count }.by(-1) end end + + describe '.order_by' do + it 'supports ordering by the contact date' do + runner1 = create(:ci_runner, contacted_at: 1.year.ago) + runner2 = create(:ci_runner, contacted_at: 1.month.ago) + runners = described_class.order_by('contacted_asc') + + expect(runners).to eq([runner1, runner2]) + end + + it 'supports ordering by the creation date' do + runner1 = create(:ci_runner, created_at: 1.year.ago) + runner2 = create(:ci_runner, created_at: 1.month.ago) + runners = described_class.order_by('created_asc') + + expect(runners).to eq([runner2, runner1]) + end + end end |