File tree 3 files changed +49
-0
lines changed
grape/validations/validators
3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -231,6 +231,7 @@ module Validations
231
231
autoload :Types
232
232
autoload :ParamsScope
233
233
autoload :ValidatorFactory
234
+ autoload :Base , 'grape/validations/validators/base'
234
235
end
235
236
236
237
module Types
Original file line number Diff line number Diff line change @@ -93,3 +93,10 @@ def fail_fast?
93
93
end
94
94
end
95
95
end
96
+
97
+ Grape ::Validations ::Base = Class . new ( Grape ::Validations ::Validators ::Base ) do
98
+ def initialize ( *)
99
+ super
100
+ warn '[DEPRECATION] `Grape::Validations::Base` is deprecated. Use `Grape::Validations::Validators::Base` instead.'
101
+ end
102
+ end
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
describe Grape ::Validations do
4
+ context 'deprecated Grape::Validations::Base' do
5
+ subject do
6
+ Class . new ( Grape ::API ) do
7
+ params do
8
+ requires :text , validator_with_old_base : true
9
+ end
10
+ get do
11
+ end
12
+ end
13
+ end
14
+
15
+ let ( :validator_with_old_base ) do
16
+ Class . new ( Grape ::Validations ::Base ) do
17
+ def validate_param! ( _attr_name , _params )
18
+ true
19
+ end
20
+ end
21
+ end
22
+
23
+ before do
24
+ described_class . register_validator ( 'validator_with_old_base' , validator_with_old_base )
25
+ allow ( Warning ) . to receive ( :warn )
26
+ end
27
+
28
+ after do
29
+ described_class . deregister_validator ( 'validator_with_old_base' )
30
+ end
31
+
32
+ def app
33
+ subject
34
+ end
35
+
36
+ it 'puts a deprecation warning' do
37
+ expect ( Warning ) . to receive ( :warn ) do |message |
38
+ expect ( message ) . to include ( '`Grape::Validations::Base` is deprecated' )
39
+ end
40
+
41
+ get '/'
42
+ end
43
+ end
44
+
4
45
context 'using a custom length validator' do
5
46
subject do
6
47
Class . new ( Grape ::API ) do
You can’t perform that action at this time.
0 commit comments