Skip to content
This repository was archived by the owner on Jan 30, 2024. It is now read-only.

Commit b2ee978

Browse files
author
Mario Manno
authored
Merge pull request #188 from natebird/rails5_deprecation_fixes
Rails5 deprecation fixes
2 parents 012b55a + fdedcd1 commit b2ee978

12 files changed

Lines changed: 105 additions & 74 deletions

Gemfile.lock

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,51 @@ PATH
33
specs:
44
devise_security_extension (0.10.0)
55
devise (>= 3.0.0, < 5.0)
6-
railties (>= 3.2.6, < 5.0)
6+
railties (>= 3.2.6, < 6.0)
77

88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
actionmailer (4.2.5.1)
12-
actionpack (= 4.2.5.1)
13-
actionview (= 4.2.5.1)
14-
activejob (= 4.2.5.1)
11+
actionmailer (4.2.6)
12+
actionpack (= 4.2.6)
13+
actionview (= 4.2.6)
14+
activejob (= 4.2.6)
1515
mail (~> 2.5, >= 2.5.4)
1616
rails-dom-testing (~> 1.0, >= 1.0.5)
17-
actionpack (4.2.5.1)
18-
actionview (= 4.2.5.1)
19-
activesupport (= 4.2.5.1)
17+
actionpack (4.2.6)
18+
actionview (= 4.2.6)
19+
activesupport (= 4.2.6)
2020
rack (~> 1.6)
2121
rack-test (~> 0.6.2)
2222
rails-dom-testing (~> 1.0, >= 1.0.5)
2323
rails-html-sanitizer (~> 1.0, >= 1.0.2)
24-
actionview (4.2.5.1)
25-
activesupport (= 4.2.5.1)
24+
actionview (4.2.6)
25+
activesupport (= 4.2.6)
2626
builder (~> 3.1)
2727
erubis (~> 2.7.0)
2828
rails-dom-testing (~> 1.0, >= 1.0.5)
2929
rails-html-sanitizer (~> 1.0, >= 1.0.2)
30-
activejob (4.2.5.1)
31-
activesupport (= 4.2.5.1)
30+
activejob (4.2.6)
31+
activesupport (= 4.2.6)
3232
globalid (>= 0.3.0)
33-
activemodel (4.2.5.1)
34-
activesupport (= 4.2.5.1)
33+
activemodel (4.2.6)
34+
activesupport (= 4.2.6)
3535
builder (~> 3.1)
36-
activerecord (4.2.5.1)
37-
activemodel (= 4.2.5.1)
38-
activesupport (= 4.2.5.1)
36+
activerecord (4.2.6)
37+
activemodel (= 4.2.6)
38+
activesupport (= 4.2.6)
3939
arel (~> 6.0)
40-
activesupport (4.2.5.1)
40+
activesupport (4.2.6)
4141
i18n (~> 0.7)
4242
json (~> 1.7, >= 1.7.7)
4343
minitest (~> 5.1)
4444
thread_safe (~> 0.3, >= 0.3.4)
4545
tzinfo (~> 1.1)
4646
arel (6.0.3)
47-
ast (2.2.0)
47+
ast (2.3.0)
4848
bcrypt (3.1.11)
4949
builder (3.2.2)
50-
concurrent-ruby (1.0.0)
50+
concurrent-ruby (1.0.2)
5151
coveralls (0.8.13)
5252
json (~> 1.8)
5353
simplecov (~> 0.11.0)
@@ -76,32 +76,34 @@ GEM
7676
json (1.8.3)
7777
loofah (2.0.3)
7878
nokogiri (>= 1.5.9)
79-
mail (2.6.3)
80-
mime-types (>= 1.16, < 3)
81-
mime-types (2.99.1)
79+
mail (2.6.4)
80+
mime-types (>= 1.16, < 4)
81+
mime-types (3.1)
82+
mime-types-data (~> 3.2015)
83+
mime-types-data (3.2016.0521)
8284
mini_portile2 (2.1.0)
8385
minitest (5.9.0)
8486
nokogiri (1.6.8)
8587
mini_portile2 (~> 2.1.0)
8688
pkg-config (~> 1.1.7)
8789
orm_adapter (0.5.0)
88-
parser (2.3.0.6)
90+
parser (2.3.1.2)
8991
ast (~> 2.2)
9092
pkg-config (1.1.7)
9193
powerpack (0.1.1)
9294
rack (1.6.4)
9395
rack-test (0.6.3)
9496
rack (>= 1.0)
95-
rails (4.2.5.1)
96-
actionmailer (= 4.2.5.1)
97-
actionpack (= 4.2.5.1)
98-
actionview (= 4.2.5.1)
99-
activejob (= 4.2.5.1)
100-
activemodel (= 4.2.5.1)
101-
activerecord (= 4.2.5.1)
102-
activesupport (= 4.2.5.1)
97+
rails (4.2.6)
98+
actionmailer (= 4.2.6)
99+
actionpack (= 4.2.6)
100+
actionview (= 4.2.6)
101+
activejob (= 4.2.6)
102+
activemodel (= 4.2.6)
103+
activerecord (= 4.2.6)
104+
activesupport (= 4.2.6)
103105
bundler (>= 1.3.0, < 2.0)
104-
railties (= 4.2.5.1)
106+
railties (= 4.2.6)
105107
sprockets-rails
106108
rails-deprecated_sanitizer (1.0.3)
107109
activesupport (>= 4.2.0.alpha)
@@ -113,17 +115,17 @@ GEM
113115
loofah (~> 2.0)
114116
rails_email_validator (0.1.4)
115117
activemodel (>= 3.0.0)
116-
railties (4.2.5.1)
117-
actionpack (= 4.2.5.1)
118-
activesupport (= 4.2.5.1)
118+
railties (4.2.6)
119+
actionpack (= 4.2.6)
120+
activesupport (= 4.2.6)
119121
rake (>= 0.8.7)
120122
thor (>= 0.18.1, < 2.0)
121123
rainbow (2.1.0)
122124
rake (11.2.2)
123125
responders (2.2.0)
124126
railties (>= 4.2.0, < 5.1)
125127
rmagick (2.15.4)
126-
rspec-core (3.4.3)
128+
rspec-core (3.4.4)
127129
rspec-support (~> 3.4.0)
128130
rspec-expectations (3.4.0)
129131
diff-lcs (>= 1.2.0, < 2.0)
@@ -140,22 +142,22 @@ GEM
140142
rspec-mocks (~> 3.4.0)
141143
rspec-support (~> 3.4.0)
142144
rspec-support (3.4.1)
143-
rubocop (0.37.2)
144-
parser (>= 2.3.0.4, < 3.0)
145+
rubocop (0.40.0)
146+
parser (>= 2.3.1.0, < 3.0)
145147
powerpack (~> 0.1)
146148
rainbow (>= 1.99.1, < 3.0)
147149
ruby-progressbar (~> 1.7)
148-
unicode-display_width (~> 0.3)
149-
ruby-progressbar (1.7.5)
150+
unicode-display_width (~> 1.0, >= 1.0.1)
151+
ruby-progressbar (1.8.1)
150152
simplecov (0.11.2)
151153
docile (~> 1.1.0)
152154
json (~> 1.8)
153155
simplecov-html (~> 0.10.0)
154156
simplecov-html (0.10.0)
155-
sprockets (3.5.2)
157+
sprockets (3.6.0)
156158
concurrent-ruby (~> 1.0)
157159
rack (> 1, < 3)
158-
sprockets-rails (3.0.3)
160+
sprockets-rails (3.0.4)
159161
actionpack (>= 4.0)
160162
activesupport (>= 4.0)
161163
sprockets (>= 3.0.0)
@@ -167,7 +169,7 @@ GEM
167169
tins (1.6.0)
168170
tzinfo (1.2.2)
169171
thread_safe (~> 0.1)
170-
unicode-display_width (0.3.1)
172+
unicode-display_width (1.0.5)
171173
warden (1.2.6)
172174
rack (>= 1.0)
173175
yard (0.8.7.6)

devise_security_extension.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
2020
s.require_paths = ['lib']
2121
s.required_ruby_version = '>= 2.1.0'
2222

23-
s.add_runtime_dependency 'railties', '>= 3.2.6', '< 5.0'
23+
s.add_runtime_dependency 'railties', '>= 3.2.6', '< 6.0'
2424
s.add_runtime_dependency 'devise', '>= 3.0.0', '< 5.0'
2525
s.add_development_dependency 'bundler', '>= 1.3.0', '< 2.0'
2626
s.add_development_dependency 'sqlite3', '~> 1.3.10'

lib/devise_security_extension/rails.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ class Engine < ::Rails::Engine
33
ActiveSupport.on_load(:action_controller) do
44
include DeviseSecurityExtension::Controllers::Helpers
55
end
6-
7-
if defined?(ActiveSupport::Reloader)
8-
ActiveSupport::Callbacks.to_prepare do
6+
7+
if Rails.version > "5"
8+
ActiveSupport::Reloader.to_prepare do
99
DeviseSecurityExtension::Patches.apply
1010
end
1111
else

test/dummy/config/environments/test.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
config.cache_classes = true
33
config.eager_load = false
44

5-
config.serve_static_files = true
6-
config.static_cache_control = 'public, max-age=3600'
5+
if Rails.version > "5"
6+
config.public_file_server.enabled = true
7+
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
8+
else
9+
config.serve_static_files = true
10+
config.static_cache_control = 'public, max-age=3600'
11+
end
712

813
config.consider_all_requests_local = true
914
config.action_controller.perform_caching = false
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MIGRATION_CLASS =
2+
if ActiveRecord::VERSION::MAJOR >= 5
3+
ActiveRecord::Migration[4.2]
4+
else
5+
ActiveRecord::Migration
6+
end

test/dummy/db/migrate/20120508165529_create_tables.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class CreateTables < ActiveRecord::Migration
1+
class CreateTables < MIGRATION_CLASS
22
def self.up
33
create_table :users do |t|
44
t.string :username
@@ -15,7 +15,7 @@ def self.up
1515
create_table :secure_users do |t|
1616
t.string :email
1717
t.string :encrypted_password, null: false, default: ''
18-
t.timestamps
18+
t.timestamps null: false
1919
end
2020

2121
create_table :old_passwords do |t|

test/dummy/db/migrate/20150402165590_add_verification_columns.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class AddVerificationColumns < ActiveRecord::Migration
1+
class AddVerificationColumns < MIGRATION_CLASS
22
def self.up
33
add_column :users, :paranoid_verification_code, :string
44
add_column :users, :paranoid_verified_at, :datetime

test/dummy/db/migrate/20150407162345_add_verification_attempt_column.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class AddVerificationAttemptColumn < ActiveRecord::Migration
1+
class AddVerificationAttemptColumn < MIGRATION_CLASS
22
def self.up
33
add_column :users, :paranoid_verification_attempt, :integer, default: 0
44
end

test/dummy/db/migrate/20160320162345_add_security_questions_fields.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class AddSecurityQuestionsFields < ActiveRecord::Migration
1+
class AddSecurityQuestionsFields < MIGRATION_CLASS
22
def change
33
add_column :users, :locked_at, :datetime
44
add_column :users, :unlock_token, :string

test/test_captcha_controller.rb

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ class TestWithCaptcha < ActionController::TestCase
99
end
1010

1111
test 'When captcha is enabled, it is inserted correctly' do
12-
post :create, captcha_user: {
13-
email: "wrong@email.com",
14-
password: "wrongpassword"
12+
post :create, {
13+
captcha_user: {
14+
email: "wrong@email.com",
15+
password: "wrongpassword"
16+
}
1517
}
1618

1719
assert_equal "The captcha input was invalid.", flash[:alert]
@@ -23,9 +25,12 @@ class TestWithCaptcha < ActionController::TestCase
2325
true
2426
end
2527

26-
post :create, captcha: "ABCDE", captcha_user: {
27-
email: "wrong@email.com",
28-
password: "wrongpassword"
28+
post :create, {
29+
captcha: "ABCDE",
30+
captcha_user: {
31+
email: "wrong@email.com",
32+
password: "wrongpassword"
33+
}
2934
}
3035

3136
assert_equal "Invalid Email or password.", flash[:alert]
@@ -41,9 +46,11 @@ class TestWithoutCaptcha < ActionController::TestCase
4146
end
4247

4348
test 'When captcha is not enabled, it is not inserted' do
44-
post :create, user: {
45-
email: "wrong@email.com",
46-
password: "wrongpassword"
49+
post :create, {
50+
user: {
51+
email: "wrong@email.com",
52+
password: "wrongpassword"
53+
}
4754
}
4855

4956
assert_equal "Invalid Email or password.", flash[:alert]

0 commit comments

Comments
 (0)