Skip to content

Commit 3360522

Browse files
committed
Fix deprecated use of ActiveSupport::Deprecation singleton instance
1 parent bedc9f3 commit 3360522

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/grape-swagger-rails.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
module GrapeSwaggerRails
77
class Options < OpenStruct
88
def before_filter(&block)
9-
ActiveSupport::Deprecation.warn('This option is deprecated and going to be removed in 1.0.0. ' \
10-
'Please use `before_action` instead')
9+
GrapeSwaggerRails.deprecator.warn(
10+
'This option is deprecated and going to be removed in 1.0.0. ' \
11+
'Please use `before_action` instead'
12+
)
1113
before_action(&block)
1214
end
1315

@@ -43,4 +45,8 @@ def before_action(&block)
4345
hide_url_input: false,
4446
hide_api_key_input: false
4547
)
48+
49+
def self.deprecator
50+
@deprecator ||= ActiveSupport::Deprecation.new('1.0', 'GrapeSwaggerRails')
51+
end
4652
end

spec/features/swagger_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,16 @@
171171

172172
describe '#before_filter' do
173173
before do
174-
allow(ActiveSupport::Deprecation).to receive(:warn)
174+
allow(GrapeSwaggerRails.deprecator).to receive(:warn)
175175
end
176176

177177
it 'throws deprecation warning' do
178178
GrapeSwaggerRails.options.before_filter { true }
179179

180-
expect(ActiveSupport::Deprecation).to have_received(:warn).with('This option is deprecated ' \
181-
'and going to be removed in 1.0.0. Please use `before_action` instead')
180+
expect(GrapeSwaggerRails.deprecator).to have_received(:warn).with(
181+
'This option is deprecated and going to be removed in 1.0.0. ' \
182+
'Please use `before_action` instead'
183+
)
182184
end
183185
end
184186

0 commit comments

Comments
 (0)