diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/validators | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/validators')
-rw-r--r-- | spec/validators/json_schema_validator_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/validators/json_schema_validator_spec.rb b/spec/validators/json_schema_validator_spec.rb index 83eb0e2f3dd..1e9420c5422 100644 --- a/spec/validators/json_schema_validator_spec.rb +++ b/spec/validators/json_schema_validator_spec.rb @@ -29,6 +29,36 @@ RSpec.describe JsonSchemaValidator do expect(build_report_result.errors.full_messages).to eq(["Data must be a valid json schema"]) end end + + context 'when draft is > 4' do + let(:validator) { described_class.new(attributes: [:data], filename: "build_report_result_data", draft: 6) } + + it 'uses JSONSchemer to perform validations' do + expect(JSONSchemer).to receive(:schema).with(Pathname.new(Rails.root.join('app', 'validators', 'json_schemas', 'build_report_result_data.json').to_s)).and_call_original + + subject + end + end + + context 'when draft is <= 4' do + let(:validator) { described_class.new(attributes: [:data], filename: "build_report_result_data", draft: 4) } + + it 'uses JSON::Validator to perform validations' do + expect(JSON::Validator).to receive(:validate).with(Rails.root.join('app', 'validators', 'json_schemas', 'build_report_result_data.json').to_s, build_report_result.data) + + subject + end + end + + context 'when draft value is not provided' do + let(:validator) { described_class.new(attributes: [:data], filename: "build_report_result_data") } + + it 'uses JSON::Validator to perform validations' do + expect(JSON::Validator).to receive(:validate).with(Rails.root.join('app', 'validators', 'json_schemas', 'build_report_result_data.json').to_s, build_report_result.data) + + subject + end + end end context 'when filename is not set' do |