diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-16 12:09:53 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-16 12:09:53 +0000 |
commit | 5a2284f3500088e04cf3a5854fb06dc9db2b6077 (patch) | |
tree | d8dc0c1b24a31de47d81cf6771504bd439b20625 /spec/models/alert_management | |
parent | a11e5bac528dd5c84e19acb3db1b8addd698726e (diff) | |
download | gitlab-ce-5a2284f3500088e04cf3a5854fb06dc9db2b6077.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/alert_management')
-rw-r--r-- | spec/models/alert_management/http_integration_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/models/alert_management/http_integration_spec.rb b/spec/models/alert_management/http_integration_spec.rb index a3e7b47c116..910df51801a 100644 --- a/spec/models/alert_management/http_integration_spec.rb +++ b/spec/models/alert_management/http_integration_spec.rb @@ -31,6 +31,54 @@ RSpec.describe AlertManagement::HttpIntegration do it { is_expected.not_to validate_uniqueness_of(:endpoint_identifier).scoped_to(:project_id, :active) } end + + context 'payload_attribute_mapping' do + subject { build(:alert_management_http_integration, payload_attribute_mapping: attribute_mapping) } + + context 'with valid JSON schema' do + let(:attribute_mapping) do + { + title: { path: %w(a b c), type: 'string' }, + description: { path: %w(a), type: 'string' } + } + end + + it { is_expected.to be_valid } + end + + context 'with invalid JSON schema' do + shared_examples 'is invalid record' do + it do + expect(subject).to be_invalid + expect(subject.errors.messages[:payload_attribute_mapping]).to eq(['must be a valid json schema']) + end + end + + context 'when property is not an object' do + let(:attribute_mapping) do + { title: 'That is not a valid schema' } + end + + it_behaves_like 'is invalid record' + end + + context 'when property missing required attributes' do + let(:attribute_mapping) do + { title: { type: 'string' } } + end + + it_behaves_like 'is invalid record' + end + + context 'when property has extra attributes' do + let(:attribute_mapping) do + { title: { path: %w(a b c), type: 'string', extra: 'property' } } + end + + it_behaves_like 'is invalid record' + end + end + end end describe '#token' do |