diff --git a/devise-jwt.gemspec b/devise-jwt.gemspec index 272d16d..415a376 100644 --- a/devise-jwt.gemspec +++ b/devise-jwt.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency 'devise', '~> 4.0' + spec.add_dependency 'devise', '>= 4.0' spec.add_dependency 'warden-jwt_auth', '~> 0.10' spec.add_development_dependency "bundler", "> 1" diff --git a/lib/devise/jwt/railtie.rb b/lib/devise/jwt/railtie.rb index 8fdbe70..260b451 100644 --- a/lib/devise/jwt/railtie.rb +++ b/lib/devise/jwt/railtie.rb @@ -9,9 +9,7 @@ class Railtie < Rails::Railtie initializer 'devise-jwt-middleware' do |app| app.middleware.use Warden::JWTAuth::Middleware - config.after_initialize do - Rails.application.reload_routes! - + config.after_routes_loaded do Warden::JWTAuth.configure do |config| defaults = DefaultsGenerator.call @@ -21,15 +19,6 @@ class Railtie < Rails::Railtie config.revocation_strategies = defaults[:revocation_strategies] end end - - ActiveSupport::Reloader.to_prepare do - Warden::JWTAuth.configure do |config| - defaults = DefaultsGenerator.call - - config.mappings = defaults[:mappings] - config.revocation_strategies = defaults[:revocation_strategies] - end - end end end end diff --git a/spec/fixtures/rails_app/Gemfile b/spec/fixtures/rails_app/Gemfile index c81669a..3ed837d 100644 --- a/spec/fixtures/rails_app/Gemfile +++ b/spec/fixtures/rails_app/Gemfile @@ -10,6 +10,8 @@ gem 'rails' gem 'sqlite3' # Use Puma as the app server gem 'puma' + +gem 'devise', github: 'heartcombo/devise', branch: 'main' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # gem 'jbuilder', '~> 2.5' # Use ActiveModel has_secure_password diff --git a/spec/fixtures/rails_app/Gemfile.lock b/spec/fixtures/rails_app/Gemfile.lock index 8fc2f87..cfd72af 100644 --- a/spec/fixtures/rails_app/Gemfile.lock +++ b/spec/fixtures/rails_app/Gemfile.lock @@ -1,8 +1,20 @@ +GIT + remote: https://github.com/heartcombo/devise.git + revision: fec67f98f26fcd9a79072e4581b1bd40d0c7fa1d + branch: main + specs: + devise (5.0.0.beta) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 6.0.0) + responders + warden (~> 1.2.3) + PATH remote: ../../.. specs: devise-jwt (0.12.1) - devise (~> 4.0) + devise (>= 4.0) warden-jwt_auth (~> 0.10) GEM @@ -85,15 +97,9 @@ GEM bigdecimal (3.1.9) builder (3.3.0) concurrent-ruby (1.3.5) - connection_pool (2.5.1) + connection_pool (2.5.3) crass (1.0.6) date (3.4.1) - devise (4.9.4) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 4.1.0) - responders - warden (~> 1.2.3) drb (2.2.1) dry-auto_inject (1.1.0) dry-core (~> 1.1) @@ -147,14 +153,14 @@ GEM pp (0.6.2) prettyprint prettyprint (0.2.0) - psych (5.2.3) + psych (5.2.5) date stringio puma (6.6.0) nio4r (~> 2.0) racc (1.8.1) - rack (3.1.13) - rack-session (2.1.0) + rack (3.1.14) + rack-session (2.1.1) base64 (>= 0.1.0) rack (>= 3.0.0) rack-test (2.2.0) @@ -225,6 +231,7 @@ PLATFORMS ruby DEPENDENCIES + devise! devise-jwt! puma rails diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d3ee3d1..ed648a1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,4 +30,10 @@ RSpec.configure do |config| config.use_transactional_fixtures = true + + # Make sure routes are loaded once before the test suite is run + # Since they are lazy loaded by default on Rails 8 + config.before(:suite) do + Rails.application.try(:reload_routes_unless_loaded) + end end