diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-06 21:10:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-06 21:10:52 +0300 |
commit | 653048c5eeb8351344155d5e03a7d5a6138ba6ec (patch) | |
tree | 85ae41bb39070a2293c6b48fe56028da43cca51f /spec | |
parent | 04a42f5e032537fc95c5158379748a7ff44385d5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
7 files changed, 14 insertions, 45 deletions
diff --git a/spec/frontend/pipelines/unwrapping_utils_spec.js b/spec/frontend/pipelines/unwrapping_utils_spec.js index 853bc37e9df..cd16ed7262e 100644 --- a/spec/frontend/pipelines/unwrapping_utils_spec.js +++ b/spec/frontend/pipelines/unwrapping_utils_spec.js @@ -1,5 +1,4 @@ import { - unwrapArrayOfJobs, unwrapGroups, unwrapNodesWithName, unwrapStagesWithNeeds, @@ -95,29 +94,6 @@ const completeMock = [ ]; describe('Shared pipeline unwrapping utils', () => { - describe('unwrapArrayOfJobs', () => { - it('returns an empty array if the input is an empty undefined', () => { - expect(unwrapArrayOfJobs(undefined)).toEqual([]); - }); - - it('returns an empty array if the input is an empty array', () => { - expect(unwrapArrayOfJobs([])).toEqual([]); - }); - - it('returns a flatten array of each job with their data and stage name', () => { - expect( - unwrapArrayOfJobs([ - { name: 'build', groups: [{ name: 'job_a_1' }, { name: 'job_a_2' }] }, - { name: 'test', groups: [{ name: 'job_b' }] }, - ]), - ).toMatchObject([ - { category: 'build', name: 'job_a_1' }, - { category: 'build', name: 'job_a_2' }, - { category: 'test', name: 'job_b' }, - ]); - }); - }); - describe('unwrapGroups', () => { it('takes stages without nodes and returns the unwrapped groups', () => { expect(unwrapGroups(stagesAndGroups)[0].groups).toEqual(groupsArray); diff --git a/spec/lib/atlassian/jira_connect/client_spec.rb b/spec/lib/atlassian/jira_connect/client_spec.rb index 7c05912a49d..9759bceb58e 100644 --- a/spec/lib/atlassian/jira_connect/client_spec.rb +++ b/spec/lib/atlassian/jira_connect/client_spec.rb @@ -114,7 +114,7 @@ RSpec.describe Atlassian::JiraConnect::Client do end let(:body) do - matcher = be_valid_json.according_to_schema(schema) + matcher = be_valid_json.and match_schema(schema) ->(text) { matcher.matches?(text) } end @@ -164,7 +164,7 @@ RSpec.describe Atlassian::JiraConnect::Client do end let(:body) do - matcher = be_valid_json.according_to_schema(build_info_payload_schema) + matcher = be_valid_json.and match_schema(build_info_payload_schema) ->(text) { matcher.matches?(text) } end diff --git a/spec/lib/atlassian/jira_connect/serializers/build_entity_spec.rb b/spec/lib/atlassian/jira_connect/serializers/build_entity_spec.rb index 52e475d20ca..4bbd654655d 100644 --- a/spec/lib/atlassian/jira_connect/serializers/build_entity_spec.rb +++ b/spec/lib/atlassian/jira_connect/serializers/build_entity_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Atlassian::JiraConnect::Serializers::BuildEntity do end it 'is invalid, since it has no issue keys' do - expect(subject.to_json).not_to be_valid_json.according_to_schema(Atlassian::Schemata.build_info) + expect(subject.to_json).not_to match_schema(Atlassian::Schemata.build_info) end end end @@ -43,7 +43,7 @@ RSpec.describe Atlassian::JiraConnect::Serializers::BuildEntity do describe '#to_json' do it 'is valid according to the build info schema' do - expect(subject.to_json).to be_valid_json.according_to_schema(Atlassian::Schemata.build_info) + expect(subject.to_json).to be_valid_json.and match_schema(Atlassian::Schemata.build_info) end end end diff --git a/spec/lib/atlassian/jira_connect/serializers/deployment_entity_spec.rb b/spec/lib/atlassian/jira_connect/serializers/deployment_entity_spec.rb index 42a10944dc9..82bcbdc4561 100644 --- a/spec/lib/atlassian/jira_connect/serializers/deployment_entity_spec.rb +++ b/spec/lib/atlassian/jira_connect/serializers/deployment_entity_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Atlassian::JiraConnect::Serializers::DeploymentEntity do end it 'is invalid, since it has no issue keys' do - expect(subject.to_json).not_to be_valid_json.according_to_schema(Atlassian::Schemata.deployment_info) + expect(subject.to_json).not_to match_schema(Atlassian::Schemata.deployment_info) end end end @@ -86,7 +86,7 @@ RSpec.describe Atlassian::JiraConnect::Serializers::DeploymentEntity do describe '#to_json' do it 'is valid according to the deployment info schema' do - expect(subject.to_json).to be_valid_json.according_to_schema(Atlassian::Schemata.deployment_info) + expect(subject.to_json).to be_valid_json.and match_schema(Atlassian::Schemata.deployment_info) end end end diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index fb993a1ce17..c80fafe1c5d 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -1142,6 +1142,11 @@ RSpec.describe QuickActions::InterpretService do let(:issuable) { issue } end + it_behaves_like 'confidential command' do + let(:content) { '/confidential' } + let(:issuable) { create(:incident, project: project) } + end + it_behaves_like 'lock command' do let(:content) { '/lock' } let(:issuable) { issue } diff --git a/spec/support/matchers/be_valid_json.rb b/spec/support/matchers/be_valid_json.rb index f46c35c7198..228c1fc986e 100644 --- a/spec/support/matchers/be_valid_json.rb +++ b/spec/support/matchers/be_valid_json.rb @@ -1,20 +1,8 @@ # frozen_string_literal: true RSpec::Matchers.define :be_valid_json do - def according_to_schema(schema) - @schema = schema - self - end - match do |actual| - data = Gitlab::Json.parse(actual) - - if @schema.present? - @validation_errors = JSON::Validator.fully_validate(@schema, data) - @validation_errors.empty? - else - data.present? - end + Gitlab::Json.parse(actual).present? rescue JSON::ParserError => e @error = e false @@ -23,8 +11,6 @@ RSpec::Matchers.define :be_valid_json do def failure_message if @error "Parse failed with error: #{@error}" - elsif @validation_errors.present? - "Validation failed because #{@validation_errors.join(', and ')}" else "Parsing did not return any data" end diff --git a/spec/support/matchers/schema_matcher.rb b/spec/support/matchers/schema_matcher.rb index ebbd57c8115..a7696a511bd 100644 --- a/spec/support/matchers/schema_matcher.rb +++ b/spec/support/matchers/schema_matcher.rb @@ -2,6 +2,8 @@ module SchemaPath def self.expand(schema, dir = nil) + return schema unless schema.is_a?(String) + if Gitlab.ee? && dir.nil? ee_path = expand(schema, 'ee') |