Skip to content

Commit

Permalink
Fix deprecation warnings in Rails 6 (Sorcery#209)
Browse files Browse the repository at this point in the history
* Calling ActionController::Base causes deprecation warnings due to autoloading.

ActionController::Base is autoloaded by Rails when called from the initializer in engine.rb which causes Rails 6 to raise deprecation warnings.

* Added an empty manifest.js for specs

The latest version of sprockets (4.0.0) now requires a manifest.js file in ‘app/assets/config/‘ or else an Exception is raised.

* Deprecate Ruby Versions <= 2.3.x

Per the following article, ruby versions 2.3 and below are deprecated:

https://www.ruby-lang.org/en/news/2019/03/31/support-of-ruby-2-3-has-ended/

Ruby 2.4 will also be deprecated and should be removed by March 31, 2020.

* Update Ruby 2.5.x to latest version (2.5.7)
  • Loading branch information
tobyaherbert authored and Josh Buker committed Dec 19, 2019
1 parent a973ae4 commit 26dd64b
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml
AllCops:
Exclude:
- 'lib/generators/sorcery/templates/**/*'
TargetRubyVersion: 2.2
TargetRubyVersion: 2.6

# See: https://github.com/rubocop-hq/rubocop/issues/3344
Style/DoubleNegation:
Expand All @@ -21,7 +21,7 @@ Metrics/BlockLength:
Exclude:
- 'lib/**/*'
- 'spec/**/*'
Metrics/LineLength:
Layout/LineLength:
Exclude:
- 'lib/**/*'
- 'spec/**/*'
Expand Down
140 changes: 139 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,145 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-11-01 18:13:47 -0700 using RuboCop version 0.59.2.
# on 2019-12-18 16:18:24 -0800 using RuboCop version 0.78.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'sorcery.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Layout/EmptyLineBetweenDefs:
Exclude:
- 'lib/sorcery/providers/line.rb'

# Offense count: 83
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Enabled: false

# Offense count: 2
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
- 'spec/rails_app/app/controllers/sorcery_controller.rb'

# Offense count: 1
# Cop supports --auto-correct.
Lint/NonDeterministicRequireOrder:
Exclude:
- 'spec/spec_helper.rb'

# Offense count: 4
# Cop supports --auto-correct.
Lint/RedundantCopDisableDirective:
Exclude:
- 'lib/sorcery/controller.rb'
- 'lib/sorcery/model.rb'
- 'spec/rails_app/config/application.rb'
- 'spec/shared_examples/user_shared_examples.rb'

# Offense count: 4
# Cop supports --auto-correct.
Lint/SendWithMixinArgument:
Exclude:
- 'lib/sorcery.rb'
- 'lib/sorcery/engine.rb'
- 'lib/sorcery/test_helpers/internal/rails.rb'

# Offense count: 4
# Configuration parameters: AllowComments.
Lint/SuppressedException:
Exclude:
- 'lib/sorcery/controller.rb'
- 'lib/sorcery/model.rb'
- 'spec/rails_app/config/application.rb'
- 'spec/shared_examples/user_shared_examples.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'spec/shared_examples/user_shared_examples.rb'

# Offense count: 1
# Configuration parameters: EnforcedStyle.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
Exclude:
- 'lib/generators/sorcery/install_generator.rb'

# Offense count: 121
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 3
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/sorcery/controller/submodules/brute_force_protection.rb'
- 'lib/sorcery/controller/submodules/http_basic_auth.rb'
- 'lib/sorcery/controller/submodules/remember_me.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Exclude:
- 'lib/sorcery/adapters/active_record_adapter.rb'
- 'lib/sorcery/test_helpers/rails/integration.rb'

# Offense count: 49
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/RedundantBegin:
Exclude:
- 'lib/sorcery/controller.rb'
- 'lib/sorcery/model.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'lib/sorcery/controller/config.rb'
- 'lib/sorcery/controller/submodules/brute_force_protection.rb'
- 'lib/sorcery/controller/submodules/remember_me.rb'
- 'lib/sorcery/model.rb'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'spec/controllers/controller_oauth2_spec.rb'
- 'spec/sorcery_crypto_providers_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/UnpackFirst:
Exclude:
- 'lib/sorcery/crypto_providers/aes256.rb'
- 'spec/sorcery_crypto_providers_spec.rb'
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
language: ruby
rvm:
- 2.2.9
- 2.3.6
- 2.4.3
- 2.5.0
- 2.4.9
- 2.5.7
- 2.6.5

gemfile:
Expand Down
4 changes: 2 additions & 2 deletions lib/sorcery/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class Engine < Rails::Engine

initializer 'extend Controller with sorcery' do
# TODO: Should this include a modified version of the helper methods?
if defined?(ActionController::API)
ActiveSupport.on_load(:action_controller_api) do
ActionController::API.send(:include, Sorcery::Controller)
end

if defined?(ActionController::Base)
ActiveSupport.on_load(:action_controller_base) do
ActionController::Base.send(:include, Sorcery::Controller)
ActionController::Base.helper_method :current_user
ActionController::Base.helper_method :logged_in?
Expand Down
6 changes: 3 additions & 3 deletions sorcery.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ Gem::Specification.new do |s|
]

# TODO: Cleanup formatting.
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
s.description = 'Provides common authentication needs such as signing in/out, activating by email and resetting password.'
s.summary = 'Magical authentication for Rails applications'
s.homepage = 'https://github.com/Sorcery/sorcery'
s.post_install_message = "As of version 1.0 oauth/oauth2 won't be automatically bundled so you may need to add those dependencies to your Gemfile.\n"
s.post_install_message += 'You may need oauth2 if you use external providers such as any of these: https://github.com/Sorcery/sorcery/tree/master/lib/sorcery/providers'
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
s.require_paths = ['lib']

s.licenses = ['MIT']

s.required_ruby_version = '>= 2.2.9'
s.required_ruby_version = '>= 2.4.9'

s.add_dependency 'bcrypt', '~> 3.1'
s.add_dependency 'oauth', '~> 0.4', '>= 0.4.4'
Expand Down

0 comments on commit 26dd64b

Please sign in to comment.