diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-19 18:09:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-19 18:09:40 +0300 |
commit | 4a721269429a178957e8ce7c6d0a75d3307c9830 (patch) | |
tree | 5bce5c3909c59b3b453378dccf7fb383ea621c1b /spec | |
parent | 1072f96e340ddad78e5dad6dfedc7c6e85fc53ea (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb | 14 | ||||
-rw-r--r-- | spec/graphql/types/base_field_spec.rb | 44 | ||||
-rw-r--r-- | spec/routing/project_routing_spec.rb | 10 |
3 files changed, 49 insertions, 19 deletions
diff --git a/spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb b/spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb new file mode 100644 index 00000000000..818a7d303bd --- /dev/null +++ b/spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Mutations::Security::CiConfiguration::BaseSecurityAnalyzer do + include GraphqlHelpers + + it 'raises a NotImplementedError error if the resolve method is called on the base class' do + user = create(:user) + project = create(:project, :public, :repository) + project.add_developer(user) + expect { resolve(described_class, args: { project_path: project.full_path }, ctx: { current_user: user }) }.to raise_error(NotImplementedError) + end +end diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb index ebdb3299bc9..c34fbf42dd8 100644 --- a/spec/graphql/types/base_field_spec.rb +++ b/spec/graphql/types/base_field_spec.rb @@ -160,17 +160,17 @@ RSpec.describe Types::BaseField do let(:flag) { :test_flag } it 'prepends the description' do - expect(field.description). to eq 'Test description. Available only when feature flag `test_flag` is enabled.' + expect(field.description).to start_with 'Test description. Available only when feature flag `test_flag` is enabled.' end context 'falsey feature_flag values' do using RSpec::Parameterized::TableSyntax - where(:flag, :feature_value) do - '' | false - '' | true - nil | false - nil | true + where(:flag, :feature_value, :default_enabled) do + '' | false | false + '' | true | false + nil | false | true + nil | true | false end with_them do @@ -179,6 +179,33 @@ RSpec.describe Types::BaseField do end end end + + context 'with different default_enabled values' do + using RSpec::Parameterized::TableSyntax + + where(:feature_value, :default_enabled, :expected_description) do + disabled_ff_description = "Test description. Available only when feature flag `test_flag` is enabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice." + enabled_ff_description = "Test description. Available only when feature flag `test_flag` is enabled. This flag is enabled by default." + + false | false | disabled_ff_description + true | false | disabled_ff_description + false | true | enabled_ff_description + true | true | enabled_ff_description + end + + with_them do + before do + stub_feature_flags("#{flag}": feature_value) + + allow(Feature::Definition).to receive(:has_definition?).with(flag).and_return(true) + allow(Feature::Definition).to receive(:default_enabled?).and_return(default_enabled) + end + + it 'returns the correct availability in the description' do + expect(field.description). to eq expected_description + end + end + end end end @@ -196,9 +223,8 @@ RSpec.describe Types::BaseField do feature_flag: 'foo_flag' ) - expectation = 'Field description. Available only when feature flag `foo_flag` is enabled. Deprecated in 1.10: Deprecation reason.' - - expect(field.description).to eq(expectation) + expect(field.description).to start_with('Field description. Available only when feature flag `foo_flag` is enabled.') + expect(field.description).to end_with('Deprecated in 1.10: Deprecation reason.') end end end diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 7b194ef8122..f3d0179ffdd 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -771,16 +771,6 @@ RSpec.describe 'project routing' do end describe Projects::ServicePingController, 'routing' do - describe 'deprecated routing' do - it 'routes to service_ping#web_ide_clientside_preview' do - expect(post('/gitlab/gitlabhq/usage_ping/web_ide_clientside_preview')).to route_to('projects/service_ping#web_ide_clientside_preview', namespace_id: 'gitlab', project_id: 'gitlabhq') - end - - it 'routes to service_ping#web_ide_pipelines_count' do - expect(post('/gitlab/gitlabhq/usage_ping/web_ide_pipelines_count')).to route_to('projects/service_ping#web_ide_pipelines_count', namespace_id: 'gitlab', project_id: 'gitlabhq') - end - end - it 'routes to service_ping#web_ide_clientside_preview' do expect(post('/gitlab/gitlabhq/service_ping/web_ide_clientside_preview')).to route_to('projects/service_ping#web_ide_clientside_preview', namespace_id: 'gitlab', project_id: 'gitlabhq') end |