Skip to content

Commit

Permalink
Rails5 requires x_action; use in tests when available
Browse files Browse the repository at this point in the history
Fix Rails 5 DEPRECATION WARNING
  • Loading branch information
bf4 committed Nov 24, 2015
1 parent 1388a90 commit a84ec92
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/action_controller/serialization_scope_name_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ def admin?
class UserTestController < ActionController::Base
protect_from_forgery

before_filter { request.format = :json }
# For Rails5
if self.respond_to?(:before_action)
before_action { request.format = :json }
else
before_filter { request.format = :json }
end

def current_user
User.new(id: 1, name: 'Pete', admin: false)
Expand Down Expand Up @@ -43,7 +48,12 @@ class AdminUserTestController < ActionController::Base
protect_from_forgery

serialization_scope :current_admin
before_filter { request.format = :json }
# For Rails5
if self.respond_to?(:before_action)
before_action { request.format = :json }
else
before_filter { request.format = :json }
end

def current_admin
User.new(id: 2, name: 'Bob', admin: true)
Expand Down

0 comments on commit a84ec92

Please sign in to comment.