2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe API::Validations::Validators::Limit do
|
2020-04-22 19:07:51 +05:30
|
|
|
include ApiValidatorsHelpers
|
|
|
|
|
|
|
|
subject do
|
|
|
|
described_class.new(['test'], 255, false, scope.new)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'valid limit param' do
|
|
|
|
it 'does not raise a validation error' do
|
|
|
|
expect_no_validation_error('test' => '123-456')
|
|
|
|
expect_no_validation_error('test' => '00000000-ffff-0000-ffff-000000000000')
|
2023-01-13 00:05:48 +05:30
|
|
|
expect_no_validation_error('test' => 'a' * 255)
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'longer than limit param' do
|
|
|
|
it 'raises a validation error' do
|
2023-01-13 00:05:48 +05:30
|
|
|
expect_validation_error('test' => 'a' * 256)
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
2022-06-21 17:19:12 +05:30
|
|
|
|
|
|
|
context 'value is nil' do
|
|
|
|
it 'does not raise a validation error' do
|
|
|
|
expect_no_validation_error('test' => nil)
|
|
|
|
end
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|