Skip to content

Commit

Permalink
Merge pull request grape-oauth2#6 from nbulaj/ruby2.4
Browse files Browse the repository at this point in the history
Bump gems, update code style
  • Loading branch information
nbulaj committed Aug 28, 2017
2 parents f54fb07 + 2b777e5 commit 5d41bec
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AllCops:
- 'spec/**/*'
DisplayCopNames: true
Rails:
Enabled: true
Enabled: false
Documentation:
Enabled: false
Style/EndOfLine:
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ matrix:
- rvm: 2.3.3
gemfile: gemfiles/mongoid.rb
env: ORM=mongoid
- rvm: 2.4.0
- rvm: 2.4.1
gemfile: gemfiles/active_record.rb
env: ORM=active_record
- rvm: 2.4.0
- rvm: 2.4.1
gemfile: gemfiles/sequel.rb
env: ORM=sequel
- rvm: ruby-head
Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

gemspec

gem 'grape', '~> 0.16'
gem 'grape', '~> 1.0'
gem 'rack-oauth2'

gem 'activerecord'
Expand All @@ -13,11 +13,11 @@ group :test do
gem 'sqlite3'
end

gem 'rspec-rails', '~> 3.5'
gem 'coveralls', require: false
gem 'database_cleaner'
gem 'rack-test', require: 'rack/test'
gem 'otr-activerecord'
gem 'rack-test', require: 'rack/test'
gem 'rspec-rails', '~> 3.5'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
4 changes: 2 additions & 2 deletions gemfiles/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
gem 'bcrypt'

group :test do
gem 'rspec-rails', '~> 3.5'
gem 'rspec-rails', '~> 3.6'
gem 'database_cleaner'
gem 'rack-test', require: 'rack/test'
gem 'coveralls', require: false
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
4 changes: 2 additions & 2 deletions gemfiles/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
gem 'mongoid', '~> 6'

group :test do
gem 'rspec-rails', '~> 3.4'
gem 'rspec-rails', '~> 3.6'
gem 'database_cleaner'
gem 'rack-test', require: 'rack/test'
gem 'coveralls', require: false
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
4 changes: 2 additions & 2 deletions gemfiles/sequel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
gem 'sequel_secure_password'

group :test do
gem 'rspec-rails', '~> 3.4'
gem 'rspec-rails', '~> 3.6'
gem 'database_cleaner'
gem 'rack-test', require: 'rack/test'
gem 'coveralls', require: false
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
8 changes: 4 additions & 4 deletions grape_oauth2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ Gem::Specification.new do |gem|
gem.description = 'Provides flexible, ORM-agnostic, fully customizable and simple OAuth2 support for Grape APIs'
gem.license = 'MIT'

gem.require_paths = %w(lib)
gem.require_paths = %w[lib]
gem.files = `git ls-files`.split($RS)
gem.test_files = Dir['spec/**/*']

gem.required_ruby_version = '>= 2.2.2'

gem.add_runtime_dependency 'grape', '~> 0.16'
gem.add_runtime_dependency 'rack-oauth2', '~> 1.3.0', '>= 1.3.0'
gem.add_runtime_dependency 'grape', '~> 1.0', '>= 1.0'
gem.add_runtime_dependency 'rack-oauth2', '~> 1.6.0', '>= 1.6.0'

gem.add_development_dependency 'rspec-rails', '~> 3.4.0', '>= 3.4.0'
gem.add_development_dependency 'rspec-rails', '~> 3.6.0', '>= 3.6.0'
gem.add_development_dependency 'database_cleaner', '~> 1.5.0', '>= 1.5.0'
end
4 changes: 2 additions & 2 deletions lib/grape_oauth2/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Configuration
DEFAULT_REALM = 'OAuth 2.0'.freeze

# Currently supported (by the gem) OAuth2 grant types
SUPPORTED_GRANT_TYPES = %w(password client_credentials refresh_token).freeze
SUPPORTED_GRANT_TYPES = %w[password client_credentials refresh_token].freeze

# The names of the classes that represents OAuth2 roles
#
Expand Down Expand Up @@ -118,7 +118,7 @@ def reset!

self.access_token_lifetime = DEFAULT_TOKEN_LIFETIME
self.authorization_code_lifetime = DEFAULT_CODE_LIFETIME
self.allowed_grant_types = %w(password client_credentials)
self.allowed_grant_types = %w[password client_credentials]

self.issue_refresh_token = false
self.on_refresh = :nothing
Expand Down
10 changes: 5 additions & 5 deletions lib/grape_oauth2/configuration/validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ def check!
# Classes, that represents OAuth2 roles, must have described methods.
REQUIRED_CLASSES_API = {
access_token_class: {
class_methods: %i(authenticate create_for),
instance_methods: %i(expired? revoked? revoke! to_bearer_token)
class_methods: %i[authenticate create_for],
instance_methods: %i[expired? revoked? revoke! to_bearer_token]
},
client_class: {
class_methods: %i(authenticate)
class_methods: %i[authenticate]
},
token_generator: {
class_methods: %i(generate)
class_methods: %i[generate]
},
scopes_validator: {
instance_methods: %i(valid_for?)
instance_methods: %i[valid_for?]
}
}.freeze

Expand Down
2 changes: 1 addition & 1 deletion lib/grape_oauth2/helpers/oauth_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module OAuthParams
params :oauth_token_revocation_params do
requires :token, type: String, desc: 'The token that the client wants to get revoked'
optional :token_type_hint, type: String,
values: %w(access_token refresh_token),
values: %w[access_token refresh_token],
default: 'access_token',
desc: 'A hint about the type of the token submitted for revocation'
end
Expand Down
2 changes: 1 addition & 1 deletion lib/grape_oauth2/mixins/sequel/access_grant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_for(client, resource_owner, redirect_uri, scopes = nil)

def validate
super
validates_presence [:token, :client_id]
validates_presence %i[token client_id]
validates_unique [:token]
end

Expand Down
2 changes: 1 addition & 1 deletion lib/grape_oauth2/mixins/sequel/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def before_validation

def validate
super
validates_presence [:key, :secret]
validates_presence %i[key secret]
validates_unique :key
end

Expand Down
1 change: 1 addition & 0 deletions lib/grape_oauth2/responses/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module OAuth2
module Responses
# Authorization response.
class Authorization < Base
# [IMPORTANT]: need to be implemented!
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/configuration/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def self.oauth_authenticate(client, username, password)
expect(config.authorization_code_lifetime).to eq(1800)

expect(config.realm).to eq(Grape::OAuth2::Configuration::DEFAULT_REALM)
expect(config.allowed_grant_types).to eq(%w(password client_credentials))
expect(config.allowed_grant_types).to eq(%w[password client_credentials])

expect(config.issue_refresh_token).to be_falsey
expect(config.on_refresh).to eq(:nothing)
Expand All @@ -64,7 +64,7 @@ def initialize(scopes)
@scopes = scopes
end

def valid_for?(access_token)
def valid_for?(*)
false
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/scopes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
let(:scopes) { described_class.new([]) }

it 'converts the String scopes to an Array' do
expect(scopes.send(:to_array, 'read write delete')).to eq(%w(read write delete))
expect(scopes.send(:to_array, 'read write delete')).to eq(%w[read write delete])
end

it 'converts the object that responds to `to_a` to an Array' do
Expand All @@ -39,8 +39,8 @@
end

it 'returns an Array of String values if Array was passed' do
expect(scopes.send(:to_array, %w(read write delete))).to eq(%w(read write delete))
expect(scopes.send(:to_array, %i(read write delete))).to eq(%w(read write delete))
expect(scopes.send(:to_array, %w(read write delete))).to eq(%w[read write delete])
expect(scopes.send(:to_array, %i(read write delete))).to eq(%w[read write delete])
end

it 'raises an error if scopes type is not supported' do
Expand Down

0 comments on commit 5d41bec

Please sign in to comment.