diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-14 21:10:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-14 21:10:34 +0300 |
commit | 7d4b2ed7bf75d316577b718c71a9fdef19184539 (patch) | |
tree | d709e00c4f2ab60901749883f324f9069343037c /spec/finders | |
parent | 7172fb10313a9a7790f8e033b347e77df4987154 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/analytics/cycle_analytics/stage_finder_spec.rb | 24 | ||||
-rw-r--r-- | spec/finders/ci/runners_finder_spec.rb | 43 |
2 files changed, 24 insertions, 43 deletions
diff --git a/spec/finders/analytics/cycle_analytics/stage_finder_spec.rb b/spec/finders/analytics/cycle_analytics/stage_finder_spec.rb new file mode 100644 index 00000000000..0275205028a --- /dev/null +++ b/spec/finders/analytics/cycle_analytics/stage_finder_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Analytics::CycleAnalytics::StageFinder do + let(:project) { build(:project) } + + let(:stage_id) { { id: Gitlab::Analytics::CycleAnalytics::DefaultStages.names.first } } + + subject { described_class.new(parent: project, stage_id: stage_id[:id]).execute } + + context 'when looking up in-memory default stage by name exists' do + it { expect(subject).not_to be_persisted } + it { expect(subject.name).to eq(stage_id[:id]) } + end + + context 'when in-memory default stage cannot be found' do + before do + stage_id[:id] = 'unknown_default_stage' + end + + it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } + end +end diff --git a/spec/finders/ci/runners_finder_spec.rb b/spec/finders/ci/runners_finder_spec.rb index 34639f9b7bd..4df026f2f5f 100644 --- a/spec/finders/ci/runners_finder_spec.rb +++ b/spec/finders/ci/runners_finder_spec.rb @@ -72,17 +72,6 @@ RSpec.describe Ci::RunnersFinder do end end - context 'paginate' do - it 'returns the runners for the specified page' do - stub_const('Ci::RunnersFinder::NUMBER_OF_RUNNERS_PER_PAGE', 1) - runner1 = create :ci_runner, created_at: '2018-07-12 07:00' - runner2 = create :ci_runner, created_at: '2018-07-12 08:00' - - expect(described_class.new(current_user: admin, params: { page: 1 }).execute).to eq [runner2] - expect(described_class.new(current_user: admin, params: { page: 2 }).execute).to eq [runner1] - end - end - context 'non admin user' do it 'returns no runners' do user = create :user @@ -172,38 +161,6 @@ RSpec.describe Ci::RunnersFinder do end end - context 'paginate' do - using RSpec::Parameterized::TableSyntax - - let(:runners) do - [[runner_project_7, runner_project_6, runner_project_5], - [runner_project_4, runner_project_3, runner_project_2], - [runner_project_1, runner_sub_group_4, runner_sub_group_3], - [runner_sub_group_2, runner_sub_group_1, runner_group]] - end - - where(:page, :index) do - 1 | 0 - 2 | 1 - 3 | 2 - 4 | 3 - end - - before do - stub_const('Ci::RunnersFinder::NUMBER_OF_RUNNERS_PER_PAGE', 3) - - group.add_owner(user) - end - - with_them do - let(:params) { { page: page } } - - it 'returns the runners for the specified page' do - expect(subject).to eq(runners[index]) - end - end - end - context 'filter by search term' do let(:params) { { search: 'runner_project_search' } } |