debian-mirror-gitlab/spec/services/ide/schemas_config_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe Ide::SchemasConfigService, feature_category: :web_ide do
2020-11-24 15:15:51 +05:30
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
2021-04-29 21:17:54 +05:30
2020-11-24 15:15:51 +05:30
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 }
2023-03-17 16:20:25 +05:30
context 'when no predefined schema exists for the given filename', unless: Gitlab.ee? do
2020-11-24 15:15:51 +05:30
it 'returns an empty object' do
is_expected.to include(
status: :success,
schema: {})
end
end
2023-03-17 16:20:25 +05:30
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
2020-11-24 15:15:51 +05:30
end
end