diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /spec/graphql/resolvers/ci/runners_resolver_spec.rb | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'spec/graphql/resolvers/ci/runners_resolver_spec.rb')
-rw-r--r-- | spec/graphql/resolvers/ci/runners_resolver_spec.rb | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/spec/graphql/resolvers/ci/runners_resolver_spec.rb b/spec/graphql/resolvers/ci/runners_resolver_spec.rb index 02fc7d28255..35831579799 100644 --- a/spec/graphql/resolvers/ci/runners_resolver_spec.rb +++ b/spec/graphql/resolvers/ci/runners_resolver_spec.rb @@ -20,8 +20,10 @@ RSpec.describe Resolvers::Ci::RunnersResolver, feature_category: :runner_fleet d context 'when user cannot see runners' do let(:user) { build(:user) } - it 'returns no runners' do - expect(subject.items.to_a).to eq([]) + it 'returns Gitlab::Graphql::Errors::ResourceNotAvailable' do + expect_graphql_error_to_be_created(Gitlab::Graphql::Errors::ResourceNotAvailable) do + resolve_scope + end end end @@ -30,20 +32,26 @@ RSpec.describe Resolvers::Ci::RunnersResolver, feature_category: :runner_fleet d context 'when admin mode setting is disabled', :do_not_mock_admin_mode_setting do it 'returns all the runners' do - expect(subject.items.to_a).to contain_exactly(inactive_project_runner, offline_project_runner, group_runner, subgroup_runner, instance_runner) + expect(resolve_scope.items.to_a).to contain_exactly( + inactive_project_runner, offline_project_runner, group_runner, subgroup_runner, instance_runner + ) end end context 'when admin mode setting is enabled' do context 'when in admin mode', :enable_admin_mode do it 'returns all the runners' do - expect(subject.items.to_a).to contain_exactly(inactive_project_runner, offline_project_runner, group_runner, subgroup_runner, instance_runner) + expect(resolve_scope.items.to_a).to contain_exactly( + inactive_project_runner, offline_project_runner, group_runner, subgroup_runner, instance_runner + ) end end context 'when not in admin mode' do - it 'returns no runners' do - expect(subject.items.to_a).to eq([]) + it 'returns Gitlab::Graphql::Errors::ResourceNotAvailable' do + expect_graphql_error_to_be_created(Gitlab::Graphql::Errors::ResourceNotAvailable) do + resolve_scope + end end end end @@ -54,7 +62,7 @@ RSpec.describe Resolvers::Ci::RunnersResolver, feature_category: :runner_fleet d let(:obj) { build(:project) } it 'raises an error' do - expect { subject }.to raise_error(a_string_including('Unexpected parent type')) + expect { resolve_scope }.to raise_error(a_string_including('Unexpected parent type')) end end @@ -93,7 +101,7 @@ RSpec.describe Resolvers::Ci::RunnersResolver, feature_category: :runner_fleet d expect(::Ci::RunnersFinder).to receive(:new).with(current_user: user, params: expected_params).once.and_return(finder) allow(finder).to receive(:execute).once.and_return([:execute_return_value]) - expect(subject.items.to_a).to eq([:execute_return_value]) + expect(resolve_scope.items.to_a).to contain_exactly :execute_return_value end end @@ -116,7 +124,7 @@ RSpec.describe Resolvers::Ci::RunnersResolver, feature_category: :runner_fleet d expect(::Ci::RunnersFinder).to receive(:new).with(current_user: user, params: expected_params).once.and_return(finder) allow(finder).to receive(:execute).once.and_return([:execute_return_value]) - expect(subject.items.to_a).to eq([:execute_return_value]) + expect(resolve_scope.items.to_a).to contain_exactly :execute_return_value end end @@ -136,7 +144,7 @@ RSpec.describe Resolvers::Ci::RunnersResolver, feature_category: :runner_fleet d expect(::Ci::RunnersFinder).to receive(:new).with(current_user: user, params: expected_params).once.and_return(finder) allow(finder).to receive(:execute).once.and_return([:execute_return_value]) - expect(subject.items.to_a).to eq([:execute_return_value]) + expect(resolve_scope.items.to_a).to contain_exactly :execute_return_value end end @@ -153,7 +161,7 @@ RSpec.describe Resolvers::Ci::RunnersResolver, feature_category: :runner_fleet d expect(::Ci::RunnersFinder).to receive(:new).with(current_user: user, params: expected_params).once.and_return(finder) allow(finder).to receive(:execute).once.and_return([:execute_return_value]) - expect(subject.items.to_a).to eq([:execute_return_value]) + expect(resolve_scope.items.to_a).to contain_exactly :execute_return_value end end end |