はじめに
4.0 から 4.1 は細かい修正がいくつかあります。順番に設定していきます。Ruby は 2.3 まであげられます。
Rails のアップデート
まず、Gemfile の Rails のバージョンを変更します。
gem 'rails', '4.1.16'
bundle update で一式をアップデートします。
bundle update
また、PostgreSQL 10 対策もしておきます。rspec でエラーが出たものを修正していきます。
scoped の削除
4.0 の時に消したつもりものが残っていました。4.1 ではエラーになるので、all に変更します。
リレーションに対する破壊的メソッド呼び出し
Relation に対して、shift などで破壊的に配列を変更しているものがエラーになりました。一度 .to_a してから変更します。
Relationには#map!や#delete_ifなどの破壊的メソッド (mutator method) が含まれなくなりました。これらのメソッドを使いたい場合は#to_aを呼び出してArrayに変更してからにしてください。この変更は、Relationに対して破壊的メソッドを直接呼び出すことによる奇妙なバグや混乱を防止するために行われました。
リモート script タグにCSRF保護を実施
Javascript 系のテストをしていないので、これは後でテストします。
JavaScriptレスポンスを伴うGETリクエストもクロスサイトリクエストフォージェリ (CSRF) 保護の対象となりました。これは、サイトの scriptタグのJavaScriptが第三者のサイトから参照されて重要なデータが奪取されないよう保護するためのものです。
文字列コンテンツのレンダリング
format.text だけを指定したいたものがあったので、多分 text/html で出力されていたと思われます。明示的に render :plain を記述するようにしました。
Rails 4.1のrenderに:plain、:html、:bodyオプションが導入されました。以下のようにコンテンツタイプを指定できるため、文字列ベースのコンテンツ表示にはこれらのオプションの利用が推奨されます。
render :plainを実行するとcontent typeはtext/plainに設定される render :htmlを実行するとcontent typeはtext/htmlに設定される render :bodyを実行した場合、content typeヘッダーは「設定されない」 セキュリティ上の観点から、レスポンスのbodyにマークアップを含めない場合にはrender :plainを使うすべきです。これによって多くのブラウザが安全でないコンテンツをエスケープできるからです。
今後のバージョンでは、render :textは非推奨にされる予定です。今のうちに、正しい:plain、:html、:bodyオプションに切り替えてください。render :textを使うとtext/htmlで送信されるため、セキュリティ上のリスクが生じる可能性があります。
Ruby のバージョンアップ
Rails 4.1 は Ruby 2.3 まで上げられるようなので、上げてみたところバスエラーで止まってしまったので、ここではスキップして先に Rails のバージョンを上げることにします。
Finished in 10 minutes 59 seconds (files took 6 seconds to load) 7719 examples, 0 failures, 98 pending Coverage report generated for RSpec to /opt/webcitc/coverage. 23460 / 38103 LOC (61.57%) covered. Coverage report Rcov style generated for RSpec to /opt/webcitc/coverage/rcov
(12/29追記) Segmentation fault の原因が hpricot だとわかったので、 Ruby 2.3.0 でやり直してみましたが、あまり時間は変わりませんでした。
Finished in 11 minutes 37 seconds (files took 4.52 seconds to load) 7719 examples, 0 failures, 98 pending
gem の推移はこんな感じです。
gem_name | ver4.0 | ver4.1 | changed |
---|---|---|---|
actionmailer | 4.0.13 | 4.1.16 | ↑ |
actionpack | 4.0.13 | 4.1.16 | ↑ |
activemodel | 4.0.13 | 4.1.16 | ↑ |
activerecord | 4.0.13 | 4.1.16 | ↑ |
activerecord-deprecated_finders | 1.0.4 | 4.1.16 | ↑ |
activesupport | 4.0.13 | 4.1.16 | ↑ |
arel | 4.0.2 | 5.0.1.20140414130214 | ↑ |
bcrypt | 3.1.16 | 3.1.16 | = |
better_errors | 2.9.1 | 2.9.1 | = |
binding_of_caller | 0.8.0 | 0.8.0 | = |
brakeman | 4.4.0 | 4.4.0 | = |
builder | 3.1.4 | 3.2.4 | ↑ |
choice | 0.2.0 | 0.2.0 | = |
ci_reporter | 2.0.0 | 2.0.0 | = |
coderay | 1.1.3 | 1.1.3 | = |
coffee-rails | 4.2.2 | 4.2.2 | = |
coffee-script | 2.4.1 | 2.4.1 | = |
coffee-script-source | 1.12.2 | 1.12.2 | = |
concurrent-ruby | 1.1.7 | 1.1.7 | = |
database_cleaner | 1.8.5 | 1.8.5 | = |
debug_inspector | 0.0.3 | 0.0.3 | = |
devise | 3.5.10 | 3.5.10 | = |
devise-encryptable | 0.2.0 | 0.2.0 | = |
devise_ldap_authenticatable | 0.8.7 | 0.8.7 | = |
diff-lcs | 1.4.4 | 1.4.4 | = |
docile | 1.3.4 | 1.3.4 | = |
dotenv | 2.7.6 | 2.7.6 | = |
erubi | 1.10.0 | 1.10.0 | = |
erubis | 2.7.0 | 2.7.0 | = |
execjs | 2.7.0 | 2.7.0 | = |
factory_bot | 4.11.1 | 4.11.1 | = |
factory_bot_rails | 4.11.1 | 4.11.1 | = |
ffi | 1.12.2 | 1.12.2 | = |
formatador | 0.2.5 | 0.2.5 | = |
guard | 2.15.1 | 2.15.1 | = |
guard-compat | 1.2.1 | 1.2.1 | = |
guard-rspec | 4.7.3 | 4.7.3 | = |
haml | 4.0.7 | 4.0.7 | = |
haml-rails | 1.0.0 | 1.0.0 | = |
hpricot | 0.8.6 | 0.8.6 | = |
html2haml | 2.2.0 | 2.2.0 | = |
i18n | 0.9.5 | 0.9.5 | = |
interception | 0.5 | 0.5 | = |
jquery-rails | 3.1.5 | 3.1.5 | = |
json | 2.5.1 | 1.8.6 | ↑ |
kaminari | 0.17.0 | 1.2.1 | ↑ |
kaminari-actionview | 1.2.1 | + | |
kaminari-activerecord | 1.2.1 | + | |
kaminari-core | 1.2.1 | + | |
listen | 3.0.8 | 3.0.8 | = |
lumberjack | 1.0.13 | 1.0.13 | = |
2.7.1 | 2.7.1 | = | |
method_source | 0.9.2 | 0.9.2 | = |
mini_mime | 1.0.2 | 1.0.2 | = |
mini_portile2 | 2.4.0 | 2.4.0 | = |
minitest | 4.7.5 | 5.14.2 | ↑ |
multi_json | 1.15.0 | 0.3.0 | ↑ |
nenv | 0.3.0 | - | |
net-ldap | 0.17.0 | 0.17.0 | = |
nokogiri | 1.9.1 | 1.9.1 | = |
notiffany | 0.1.3 | 0.1.3 | = |
orm_adapter | 0.5.0 | 0.5.0 | = |
pg | 0.20.0 | 0.20.0 | = |
power_assert | 1.2.0 | 1.2.0 | = |
pry | 0.12.2 | 0.12.2 | = |
pry-doc | 1.1.0 | 1.1.0 | = |
pry-rails | 0.3.9 | 0.3.9 | = |
pry-rescue | 1.5.2 | 1.5.2 | = |
public_suffix | 3.1.1 | 3.1.1 | = |
puma | 3.12.6 | 3.12.6 | = |
rack | 1.5.5 | 1.5.5 | = |
rack-cache | 1.9.0 | 1.9.0 | = |
rack-test | 0.6.3 | 0.6.3 | = |
rails | 4.0.13 | 4.1.16 | ↑ |
rails-erd | 1.5.2 | 1.5.2 | = |
railties | 4.0.13 | 4.1.16 | ↑ |
rake | 13.0.3 | 13.0.3 | = |
rb-fsevent | 0.10.4 | 0.10.4 | = |
rb-inotify | 0.10.1 | 0.10.1 | = |
rb-readline | 0.5.5 | 0.5.5 | = |
rdoc | 5.1.0 | 5.1.0 | = |
redcarpet | 3.5.1 | 3.5.1 | = |
responders | 1.1.2 | 1.1.2 | = |
rspec | 3.9.0 | 3.9.0 | = |
rspec-core | 3.9.3 | 3.9.3 | = |
rspec-expectations | 3.9.4 | 3.9.4 | = |
rspec-mocks | 3.9.1 | 3.9.1 | = |
rspec-rails | 3.9.1 | 3.9.1 | = |
rspec-support | 3.9.4 | 3.9.4 | = |
ruby-graphviz | 1.2.4 | 1.2.4 | = |
ruby_parser | 3.15.0 | 3.15.0 | = |
sass | 3.7.4 | 3.7.4 | = |
sass-listen | 4.0.0 | 4.0.0 | = |
sass-rails | 6.0.0 | 6.0.0 | = |
sassc | 2.4.0 | 2.4.0 | = |
sassc-rails | 2.1.2 | 2.1.2 | = |
sexp_processor | 4.15.1 | 4.15.1 | = |
shellany | 0.0.1 | 0.0.1 | = |
simplecov | 0.17.1 | 0.17.1 | = |
simplecov-html | 0.10.2 | 0.10.2 | = |
simplecov-rcov | 0.2.3 | 0.2.3 | = |
spring | 1.7.2 | 1.7.2 | = |
spring-commands-rspec | 1.0.4 | 1.0.4 | = |
sprockets | 3.7.2 | 3.7.2 | = |
sprockets-rails | 2.3.3 | 2.3.3 | = |
test-unit | 3.3.7 | 3.3.8 | ↑ |
thor | 0.20.3 | 0.20.3 | = |
thread_safe | 0.3.6 | 0.3.6 | = |
tilt | 2.0.10 | 2.0.10 | = |
tzinfo | 0.3.58 | 1.2.9 | ↑ |
uglifier | 4.2.0 | 4.2.0 | = |
uniform_notifier | 1.11.0 | 1.11.0 | = |
warden | 1.2.7 | 1.2.7 | = |
yard | 0.9.25 | 0.9.25 | = |
yard-activerecord | 0.0.16 | 0.0.16 | = |