diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 06:06:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 06:06:58 +0300 |
commit | accf0d7db3d58a62212125703df39e341d327ec6 (patch) | |
tree | 7ea5e828e0350f9ecd3fd9c8d6daee02849ab2ef /spec/support | |
parent | d7511e6d2f947dbae4b19947b746fdabb0897d92 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_examples/requests/api/graphql/remote_development_shared_examples.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/support/shared_examples/requests/api/graphql/remote_development_shared_examples.rb b/spec/support/shared_examples/requests/api/graphql/remote_development_shared_examples.rb new file mode 100644 index 00000000000..7c32c7bf2a9 --- /dev/null +++ b/spec/support/shared_examples/requests/api/graphql/remote_development_shared_examples.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'workspaces query in licensed environment and with feature flag on' do + describe 'when licensed and remote_development_feature_flag feature flag is enabled' do + before do + stub_licensed_features(remote_development: true) + + post_graphql(query, current_user: current_user) + end + + it_behaves_like 'a working graphql query' + + # noinspection RubyResolve + it { is_expected.to match_array(a_hash_including('name' => workspace.name)) } + # noinspection RubyResolve + + context 'when user is not authorized' do + let(:current_user) { create(:user) } + + it { is_expected.to eq([]) } + end + end +end + +RSpec.shared_examples 'workspaces query in unlicensed environment and with feature flag off' do + describe 'when remote_development feature is unlicensed' do + before do + stub_licensed_features(remote_development: false) + post_graphql(query, current_user: current_user) + end + + it 'returns an error' do + expect(subject).to be_nil + expect_graphql_errors_to_include(/'remote_development' licensed feature is not available/) + end + end + + describe 'when remote_development_feature_flag feature flag is disabled' do + before do + stub_licensed_features(remote_development: true) + stub_feature_flags(remote_development_feature_flag: false) + post_graphql(query, current_user: current_user) + end + + it 'returns an error' do + expect(subject).to be_nil + expect_graphql_errors_to_include(/'remote_development_feature_flag' feature flag is disabled/) + end + end +end |