Skip to content

Commit

Permalink
Merge pull request #23 from appfolio/fixAllPublicActionsGrape
Browse files Browse the repository at this point in the history
Ensure the all_public_actions method works for Grape APIs
  • Loading branch information
Tim Connor authored Aug 11, 2020
2 parents ea7e001 + 14983ee commit 964c9c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/declarative_authorization/test/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,14 @@ def this_is_an_abstract_controller_so_it_needs_no_access_tests
alias :access_tests_not_required :this_is_an_abstract_controller_so_it_needs_no_access_tests

def all_public_actions
actions = controller_class.public_instance_methods(false)
actions += controller_class.superclass.public_instance_methods(false)
actions = []
if defined?(Grape) && [Grape::API, Grape::API::Instance].any? { |base| controller_class < base }
actions += controller_class.routes.map { |api| "#{api.request_method} #{api.origin}" }
else
actions += controller_class.public_instance_methods(false)
actions += controller_class.superclass.public_instance_methods(false)
end

actions.reject! do |method|
method =~ /^_/ ||
method =~ /^rescue_action/ ||
Expand Down
2 changes: 1 addition & 1 deletion lib/declarative_authorization/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module DeclarativeAuthorization
VERSION = '0.12.0'.freeze
VERSION = '0.12.1.tim1'.freeze
end

0 comments on commit 964c9c6

Please sign in to comment.