Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for directly mounted Grape::API::Instance #22

Merged
merged 4 commits into from
Feb 13, 2020
Merged

Conversation

tlconnor
Copy link
Contributor

@tlconnor tlconnor commented Feb 11, 2020

This PR adds support for Grape APIs that are mounted directly as Grape::API::Instance instead of Grape::API.

Appraisals are also added for Grape 1.3.0.

gem 'grape', '1.2.3'
gem 'rails-controller-testing'
gem 'sqlite3', '~> 1.4'
when '2.5.3', '2.6.3' then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am only seeing this gem used in ops_app and property, which both use ruby 2.6.3, so support for ruby 2.5.3 can probably be dropped as well at this point. (Unless it is used somewhere else that I am missing)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, the .ruby-version file still lists ruby-2.3.3 so that can probably be updated to ruby-2.6.3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that this is a public gem, so I guess it should support more versions than one's used at Appfolio.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should support more than just what we use internally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, as a public repo we need to support more versions. I can update the .ruby-version though.

Copy link
Collaborator

@dvicory dvicory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check this prerelease already with grape 1.2 and 1.3 in property? I see we officially removed Ruby 2.3.3 from the appraisals. It would have been nice to keep but would require not trying too new of a Rails with it.

[
options[:for],
options[:for].base
].detect { |api| api.respond_to?(:decl_auth_context) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL detect exists and is basically find.

# Grape >= 1.2.0 endpoint
# Authorization::Controller::Grape can be included into either Grape::API
# or Grape::API::Instance, so we need to check both.
[
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the order significant? It seems we used to check options[:for].base first when it used to be in ControllerPermission.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its only ever going to be one or the other.

@tlconnor
Copy link
Contributor Author

This CI run tests the changes against Grape 1.2:
https://circleci.com/workflow-run/17543936-7083-4fe7-8624-c7b7772849c1

@tlconnor tlconnor merged commit 0dd4d9a into master Feb 13, 2020
@tlconnor tlconnor deleted the grape1_3 branch February 13, 2020 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants