diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/services/ide/schemas_config_service_spec.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/services/ide/schemas_config_service_spec.rb')
-rw-r--r-- | spec/services/ide/schemas_config_service_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/services/ide/schemas_config_service_spec.rb b/spec/services/ide/schemas_config_service_spec.rb new file mode 100644 index 00000000000..19e5ca9e87d --- /dev/null +++ b/spec/services/ide/schemas_config_service_spec.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ide::SchemasConfigService do + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { create(:user) } + let(:filename) { 'sample.yml' } + let(:schema_content) { double(body: '{"title":"Sample schema"}') } + + describe '#execute' do + before do + project.add_developer(user) + + allow(Gitlab::HTTP).to receive(:get).with(anything) do + schema_content + end + end + + subject { described_class.new(project, user, filename: filename).execute } + + context 'feature flag schema_linting is enabled', unless: Gitlab.ee? do + before do + stub_feature_flags(schema_linting: true) + end + + context 'when no predefined schema exists for the given filename' do + it 'returns an empty object' do + is_expected.to include( + status: :success, + schema: {}) + end + end + + context 'when a predefined schema exists for the given filename' do + let(:filename) { '.gitlab-ci.yml' } + + it 'uses predefined schema matches' do + expect(Gitlab::HTTP).to receive(:get).with('https://json.schemastore.org/gitlab-ci') + expect(subject[:schema]['title']).to eq "Sample schema" + end + end + end + + context 'feature flag schema_linting is disabled', unless: Gitlab.ee? do + it 'returns an empty object' do + is_expected.to include( + status: :success, + schema: {}) + end + end + end +end |