Skip to content

Commit

Permalink
clean up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
serggl committed Sep 21, 2016
1 parent 083b19a commit 2ceafaa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions app/controllers/grape_swagger_rails/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module GrapeSwaggerRails
class ApplicationController < ActionController::Base

if Rails::VERSION::MAJOR >= 4
before_action { run_before_action }
else
Expand All @@ -13,8 +12,8 @@ def index
private

def run_before_action
callback = [GrapeSwaggerRails.options.before_action, GrapeSwaggerRails.options.before_filter].compact.first
instance_exec(request, &callback) if callback
return unless GrapeSwaggerRails.options.before_action
instance_exec(request, &GrapeSwaggerRails.options.before_action)
end
end
end
6 changes: 2 additions & 4 deletions spec/features/swagger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@
end
context '#before_filter' do
before do
GrapeSwaggerRails.options.before_filter { true }
allow(ActiveSupport::Deprecation).to receive(:warn)
end
it 'throws deprecation warning' do
allow(ActiveSupport::Deprecation).to receive(:warn)

visit '/swagger'
GrapeSwaggerRails.options.before_filter { true }

expect(ActiveSupport::Deprecation).to have_received(:warn).with('This option is deprecated ' \
'and going to be removed in 0.3.0. Please use `before_action` instead')
Expand Down

0 comments on commit 2ceafaa

Please sign in to comment.