diff --git a/Gemfile.lock b/Gemfile.lock index 8d8acf52..2b50e3f2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,51 +3,51 @@ PATH specs: devise_security_extension (0.10.0) devise (>= 3.0.0, < 5.0) - railties (>= 3.2.6, < 5.0) + railties (>= 3.2.6, < 6.0) GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.5.1) - actionpack (= 4.2.5.1) - actionview (= 4.2.5.1) - activejob (= 4.2.5.1) + actionmailer (4.2.6) + actionpack (= 4.2.6) + actionview (= 4.2.6) + activejob (= 4.2.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.5.1) - actionview (= 4.2.5.1) - activesupport (= 4.2.5.1) + actionpack (4.2.6) + actionview (= 4.2.6) + activesupport (= 4.2.6) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.5.1) - activesupport (= 4.2.5.1) + actionview (4.2.6) + activesupport (= 4.2.6) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.5.1) - activesupport (= 4.2.5.1) + activejob (4.2.6) + activesupport (= 4.2.6) globalid (>= 0.3.0) - activemodel (4.2.5.1) - activesupport (= 4.2.5.1) + activemodel (4.2.6) + activesupport (= 4.2.6) builder (~> 3.1) - activerecord (4.2.5.1) - activemodel (= 4.2.5.1) - activesupport (= 4.2.5.1) + activerecord (4.2.6) + activemodel (= 4.2.6) + activesupport (= 4.2.6) arel (~> 6.0) - activesupport (4.2.5.1) + activesupport (4.2.6) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) - ast (2.2.0) + ast (2.3.0) bcrypt (3.1.11) builder (3.2.2) - concurrent-ruby (1.0.0) + concurrent-ruby (1.0.2) coveralls (0.8.13) json (~> 1.8) simplecov (~> 0.11.0) @@ -76,32 +76,34 @@ GEM json (1.8.3) loofah (2.0.3) nokogiri (>= 1.5.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) - mime-types (2.99.1) + mail (2.6.4) + mime-types (>= 1.16, < 4) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) mini_portile2 (2.1.0) minitest (5.9.0) nokogiri (1.6.8) mini_portile2 (~> 2.1.0) pkg-config (~> 1.1.7) orm_adapter (0.5.0) - parser (2.3.0.6) + parser (2.3.1.2) ast (~> 2.2) pkg-config (1.1.7) powerpack (0.1.1) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.5.1) - actionmailer (= 4.2.5.1) - actionpack (= 4.2.5.1) - actionview (= 4.2.5.1) - activejob (= 4.2.5.1) - activemodel (= 4.2.5.1) - activerecord (= 4.2.5.1) - activesupport (= 4.2.5.1) + rails (4.2.6) + actionmailer (= 4.2.6) + actionpack (= 4.2.6) + actionview (= 4.2.6) + activejob (= 4.2.6) + activemodel (= 4.2.6) + activerecord (= 4.2.6) + activesupport (= 4.2.6) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.5.1) + railties (= 4.2.6) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) @@ -113,9 +115,9 @@ GEM loofah (~> 2.0) rails_email_validator (0.1.4) activemodel (>= 3.0.0) - railties (4.2.5.1) - actionpack (= 4.2.5.1) - activesupport (= 4.2.5.1) + railties (4.2.6) + actionpack (= 4.2.6) + activesupport (= 4.2.6) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.1.0) @@ -123,7 +125,7 @@ GEM responders (2.2.0) railties (>= 4.2.0, < 5.1) rmagick (2.15.4) - rspec-core (3.4.3) + rspec-core (3.4.4) rspec-support (~> 3.4.0) rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) @@ -140,22 +142,22 @@ GEM rspec-mocks (~> 3.4.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - rubocop (0.37.2) - parser (>= 2.3.0.4, < 3.0) + rubocop (0.40.0) + parser (>= 2.3.1.0, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 0.3) - ruby-progressbar (1.7.5) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.8.1) simplecov (0.11.2) docile (~> 1.1.0) json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) - sprockets (3.5.2) + sprockets (3.6.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.0.3) + sprockets-rails (3.0.4) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) @@ -167,7 +169,7 @@ GEM tins (1.6.0) tzinfo (1.2.2) thread_safe (~> 0.1) - unicode-display_width (0.3.1) + unicode-display_width (1.0.5) warden (1.2.6) rack (>= 1.0) yard (0.8.7.6) diff --git a/devise_security_extension.gemspec b/devise_security_extension.gemspec index 7e5c3ada..eb985df3 100644 --- a/devise_security_extension.gemspec +++ b/devise_security_extension.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| s.require_paths = ['lib'] s.required_ruby_version = '>= 2.1.0' - s.add_runtime_dependency 'railties', '>= 3.2.6', '< 5.0' + s.add_runtime_dependency 'railties', '>= 3.2.6', '< 6.0' s.add_runtime_dependency 'devise', '>= 3.0.0', '< 5.0' s.add_development_dependency 'bundler', '>= 1.3.0', '< 2.0' s.add_development_dependency 'sqlite3', '~> 1.3.10' diff --git a/lib/devise_security_extension/rails.rb b/lib/devise_security_extension/rails.rb index d4cf5a97..ed115398 100644 --- a/lib/devise_security_extension/rails.rb +++ b/lib/devise_security_extension/rails.rb @@ -3,9 +3,9 @@ class Engine < ::Rails::Engine ActiveSupport.on_load(:action_controller) do include DeviseSecurityExtension::Controllers::Helpers end - - if defined?(ActiveSupport::Reloader) - ActiveSupport::Callbacks.to_prepare do + + if Rails.version > "5" + ActiveSupport::Reloader.to_prepare do DeviseSecurityExtension::Patches.apply end else diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 697d77cb..107ff519 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -2,8 +2,13 @@ config.cache_classes = true config.eager_load = false - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + if Rails.version > "5" + config.public_file_server.enabled = true + config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } + else + config.serve_static_files = true + config.static_cache_control = 'public, max-age=3600' + end config.consider_all_requests_local = true config.action_controller.perform_caching = false diff --git a/test/dummy/config/initializers/migration_class.rb b/test/dummy/config/initializers/migration_class.rb new file mode 100644 index 00000000..4c9861e9 --- /dev/null +++ b/test/dummy/config/initializers/migration_class.rb @@ -0,0 +1,6 @@ +MIGRATION_CLASS = + if ActiveRecord::VERSION::MAJOR >= 5 + ActiveRecord::Migration[4.2] + else + ActiveRecord::Migration + end diff --git a/test/dummy/db/migrate/20120508165529_create_tables.rb b/test/dummy/db/migrate/20120508165529_create_tables.rb index fbe5bd14..e028af32 100644 --- a/test/dummy/db/migrate/20120508165529_create_tables.rb +++ b/test/dummy/db/migrate/20120508165529_create_tables.rb @@ -1,4 +1,4 @@ -class CreateTables < ActiveRecord::Migration +class CreateTables < MIGRATION_CLASS def self.up create_table :users do |t| t.string :username @@ -15,7 +15,7 @@ def self.up create_table :secure_users do |t| t.string :email t.string :encrypted_password, null: false, default: '' - t.timestamps + t.timestamps null: false end create_table :old_passwords do |t| diff --git a/test/dummy/db/migrate/20150402165590_add_verification_columns.rb b/test/dummy/db/migrate/20150402165590_add_verification_columns.rb index 65fc5760..b4607216 100644 --- a/test/dummy/db/migrate/20150402165590_add_verification_columns.rb +++ b/test/dummy/db/migrate/20150402165590_add_verification_columns.rb @@ -1,4 +1,4 @@ -class AddVerificationColumns < ActiveRecord::Migration +class AddVerificationColumns < MIGRATION_CLASS def self.up add_column :users, :paranoid_verification_code, :string add_column :users, :paranoid_verified_at, :datetime diff --git a/test/dummy/db/migrate/20150407162345_add_verification_attempt_column.rb b/test/dummy/db/migrate/20150407162345_add_verification_attempt_column.rb index 6961e3a8..68e0ff8b 100644 --- a/test/dummy/db/migrate/20150407162345_add_verification_attempt_column.rb +++ b/test/dummy/db/migrate/20150407162345_add_verification_attempt_column.rb @@ -1,4 +1,4 @@ -class AddVerificationAttemptColumn < ActiveRecord::Migration +class AddVerificationAttemptColumn < MIGRATION_CLASS def self.up add_column :users, :paranoid_verification_attempt, :integer, default: 0 end diff --git a/test/dummy/db/migrate/20160320162345_add_security_questions_fields.rb b/test/dummy/db/migrate/20160320162345_add_security_questions_fields.rb index 7b5f1e54..d061203e 100644 --- a/test/dummy/db/migrate/20160320162345_add_security_questions_fields.rb +++ b/test/dummy/db/migrate/20160320162345_add_security_questions_fields.rb @@ -1,4 +1,4 @@ -class AddSecurityQuestionsFields < ActiveRecord::Migration +class AddSecurityQuestionsFields < MIGRATION_CLASS def change add_column :users, :locked_at, :datetime add_column :users, :unlock_token, :string diff --git a/test/test_captcha_controller.rb b/test/test_captcha_controller.rb index 7c8297e3..fd7a1983 100644 --- a/test/test_captcha_controller.rb +++ b/test/test_captcha_controller.rb @@ -9,9 +9,11 @@ class TestWithCaptcha < ActionController::TestCase end test 'When captcha is enabled, it is inserted correctly' do - post :create, captcha_user: { - email: "wrong@email.com", - password: "wrongpassword" + post :create, { + captcha_user: { + email: "wrong@email.com", + password: "wrongpassword" + } } assert_equal "The captcha input was invalid.", flash[:alert] @@ -23,9 +25,12 @@ class TestWithCaptcha < ActionController::TestCase true end - post :create, captcha: "ABCDE", captcha_user: { - email: "wrong@email.com", - password: "wrongpassword" + post :create, { + captcha: "ABCDE", + captcha_user: { + email: "wrong@email.com", + password: "wrongpassword" + } } assert_equal "Invalid Email or password.", flash[:alert] @@ -41,9 +46,11 @@ class TestWithoutCaptcha < ActionController::TestCase end test 'When captcha is not enabled, it is not inserted' do - post :create, user: { - email: "wrong@email.com", - password: "wrongpassword" + post :create, { + user: { + email: "wrong@email.com", + password: "wrongpassword" + } } assert_equal "Invalid Email or password.", flash[:alert] diff --git a/test/test_password_expired_controller.rb b/test/test_password_expired_controller.rb index 7bbfda20..17bde8f6 100644 --- a/test/test_password_expired_controller.rb +++ b/test/test_password_expired_controller.rb @@ -17,8 +17,13 @@ class Devise::PasswordExpiredControllerTest < ActionController::TestCase end test 'shold update password' do - put :update, user: { current_password: '1234', password: '12345', - password_confirmation: '12345' } + put :update, { + user: { + current_password: '1234', + password: '12345', + password_confirmation: '12345' + } + } assert_redirected_to root_path end end diff --git a/test/test_security_question_controller.rb b/test/test_security_question_controller.rb index ee5ce297..f5605fd5 100644 --- a/test/test_security_question_controller.rb +++ b/test/test_security_question_controller.rb @@ -13,18 +13,22 @@ class TestWithSecurityQuestion < ActionController::TestCase end test 'When security question is enabled, it is inserted correctly' do - post :create, security_question_user: { - email: @user.email - }, security_question_answer: "wrong answer" + post :create, { + security_question_user: { + email: @user.email + }, security_question_answer: "wrong answer" + } assert_equal "The security question answer was invalid.", flash[:alert] assert_redirected_to new_security_question_user_unlock_path end test 'When security_question is valid, it runs as normal' do - post :create, security_question_user: { - email: @user.email - }, security_question_answer: @user.security_question_answer + post :create, { + security_question_user: { + email: @user.email + }, security_question_answer: @user.security_question_answer + } assert_equal "You will receive an email with instructions for how to unlock your account in a few minutes.", flash[:notice] assert_redirected_to new_security_question_user_session_path @@ -44,8 +48,10 @@ class TestWithoutSecurityQuestion < ActionController::TestCase end test 'When security question is not enabled it is not inserted' do - post :create, user: { - email: @user.email + post :create, { + user: { + email: @user.email + } } assert_equal "You will receive an email with instructions for how to unlock your account in a few minutes.", flash[:notice]