なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2017/01/18)

2017/01/18分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

railties/CHANGELOG.md

activerecord/CHANGELOG.md


Merge pull request #27700 from kenta-s/remove-meaningless-line-from-adapter-test

activerecord/test/cases/adapter_test.rbの修正です。

不要な変数の初期化処理を削除しています。


Move config reset to ensure block

railties/test/generators/migration_generator_test.rbの修正です。

Rails.application.config.paths["db/migrate"]に任意のpathを指定した場合のテストで、Rails.application.config.paths["db/migrate"]を元の値に戻す処理をensure節で行うよう修正しています。


Move config reset to ensure block

railties/test/generators/model_generator_test.rbの修正です。

Rails.application.config.paths["db/migrate"]に任意のpathを指定した場合のテストで、Rails.application.config.paths["db/migrate"]を元の値に戻す処理をensure節で行うよう修正しています。


Use appropriate assertion based on expectation

activesupport/test/json/decoding_test.rbの修正です。

JSONのテストで、assert_equalメソッドのexpected引数にnilを指定していたテストを、assert_nilを使用するよう修正しています。

Minitest 5.10から上記使い方がdeprecateになり、nilを期待する場合はassert_nilが使用する必要がある為。


Remove unused variable 'regex'

actionview/lib/action_view/helpers/text_helper.rbの修正です。

excerptメソッドから不要な代入処理を削除しています。


Merge pull request #27717 from JunichiIto/fix-byebug-platform

railties/lib/rails/generators/rails/app/templates/Gemfileの修正です。

rails newで生成されるGemfileで、Windows環境でもbyebugがインストールされるよう修正しています。byebugWindowsでも動作する為、との事です。


Merge pull request #27697 from toshimaru/rubocop-update

.rubocop.ymlGemfileの修正です。

Gemfileのバージョンを0.47に更新、及びdeprecatedになったAlignWithの代わりにEnforcedStyleAlignWithを使用するよう修正しています。


Fix all rubocop violations

rubocopのルールに違反していた箇所をまとめて修正しています。


Remove initialize_schema_migrations_table and initialize_internal_metadata_table internal public methods

Active Recordの修正です。

ActiveRecord::ConnectionAdapters::SchemaStatements moduleからinitialize_schema_migrations_tableinitialize_internal_metadata_tableメソッドを削除しています。

それぞれActiveRecord::SchemaMigration.create_tableActiveRecord::InternalMetadata.create_tableを呼び出しているだけで、メソッド経由ではなく直接呼びだせば良いだろう、という事で削除されたようです。


Merge pull request #27706 from y-yagi/allow_to_pass_describe_option_to_rake

railties/lib/rails/command.rbrailties/lib/rails/command/base.rbの修正です。

bin/rails -Dコマンドを実行した場合にrailsのヘルプが表示されるようになっていたのを、Rails 5.0.1と同様にrake taskのdescrpitonが表示されるよう修正しています。


Adjust Module.parent_name to work when frozen; fixes #27637

activesupport/lib/active_support/core_ext/module/introspection.rbの修正です。

freeze済みのクラスに対してparent_nameメソッドを呼び出した場合に、RuntimeErrorになっていたのを、値が正しく取得出来るよう修正しています。

class A
  class B
  end
end

A::B.freeze
# => A::B

# before

A::B.parent_name
# => RuntimeError: can't modify frozen #<Class:A::B>

# after
A::B.parent_name
# "A"

Add channel_prefix support to ActionCable redis/evented_redis adapters.

Action Cableの修正です。

redis/evented_redis adapterを使用している場合に、configファイルからchannel名にprefixをつけれるよう修正しています。prefixを指定したい場合は、config/cable.ymlchannel_prefixに指定すればOKです。

# config/cable.yml
production:
  adapter: redis
  url: redis://localhost:6379/1
  channel_prefix: myapp_production

Update ActionCable guide to better describe SubscriptionAdapter configuration.

rails guideのAction Cable Overviewの修正です。

Adapter Configurationの項を追加し、各adapter(Async AdapterRedis Adapter及びPostgreSQL adapter)についての説明を追加しています。


Merge pull request #27688 from kenta-s/add-test-for-safe_join

actionview/test/template/output_safety_helper_test.rbの修正です。

safe_joinメソッドに第二引数を指定しなかった場合のテストを追加しています。


Merge pull request #27693 from kenta-s/improve-to_sentence-method

actionview/lib/action_view/helpers/output_safety_helper.rbの修正です。

to_sentenceメソッドでsafe_joinメソッドを使用する際に、第二引数にnilを指定するよう修正しています。

-          safe_join([safe_join(array[0...-1], options[:words_connector]), options[:last_word_connector], array[-1]])
+          safe_join([safe_join(array[0...-1], options[:words_connector]), options[:last_word_connector], array[-1]], nil)

引数を指定しない場合、$,がセパレータとして使用されてしまい、$,の状態により予期せぬ結果が返ってきてしまう可能性がある為、それを避ける為に明示的にnilを指定するようにしています。


Merge pull request #27665 from kenta-s/improve-compute_asset_extname

actionview/lib/action_view/helpers/asset_url_helper.rbの修正です。

compute_asset_extnameメソッドでasset pathに追加するextnameが無い場合に、明示的にnilを返すようelse句を追加しています。


Merge pull request #27653 from s-jcs/feature/adjust_indentation_for_generator

railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.ttの修正です。

rails newで生成されるproduction.rb内でインデントがずれている箇所があったのを修正しています。


Merge pull request #27632 from dixpac/repo_initialize

railties/lib/rails/generators/rails/app/app_generator.rbの修正です。

rails newコマンドで新規railアプリを作成する際、git initも合わせて実行するよう修正しています。


rm rm_f that is not in use

activesupport/test/evented_file_update_checker_test.rbの修正です。

使用していないrm_fメソッドを削除しています。


Unused class for testing since 93559da4826546d07014f8cfa399b64b4a143127

activesupport/test/core_ext/kernel_test.rbの修正です。

使用していないMockStdErrクラスを削除しています。


:warning: "Use assert_nil if expecting nil. This will fail in MT6."

assert_equalメソッドを使用している、かつ、expected引数にnilが来る可能性のあるテストを、引数がnilの場合はassert_nilを使用するよう修正しています。


update links of pluralization in i18n guide

rails guideのRails Internationalization (I18n) APIの修正です。

plural formsについてのリンクを、http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html から http://cldr.unicode.org/index/cldr-spec/plural-rules に修正しています。

cldr-tmp の方はもう使用されていない為。


Merge pull request #27722 from y-yagi/follow_up_to_b1c08d8

railties/lib/rails/tasks.rbの修正です。

自動でloadするrake taskの一覧にyarn.rakeを追加しています。


I guess we're ready for the randomized tests now

GemfileGemfile.lockの修正です。

minitest gemのバージョンロックを削除しています。

rails自体のテストをランダムに実行するとテストがコケてしまう事がある為、ランダムに実行しないようにする為に5.3.4未満にminitestのバージョンをロックしていました。が、もうランダムに実行しても大丈夫だろう、という事でバージョンロックを削除しています。

しかしやはりまだ駄目で、テストがコケてしまう為後ほどrevertされています。


:warning: "Use assert_nil if expecting nil. This will fail in MT6."

actionpack/test/dispatch/ssl_test.rbの修正です。

assert_equalメソッドを使用している、かつ、expected引数にnilが来る可能性のあるテストを、引数がnilの場合はassert_nilを使用するよう修正しています。


Revert "I guess we're ready for the randomized tests now"

minitest gemのバージョンロックを削除した、 I guess we're ready for the randomized tests nowをrevertしています。

テストをランダムに実行するとまだコケてしまうテストがある為。


Merge pull request #27726 from kenta-s/fix-grammar-in-partial_renderer

actionview/lib/action_view/renderer/partial_renderer.rbのdocの修正です。

ActionView::PartialRendererクラスのdoc内のグラマーの修正を行っています。


Make sure to clear query cache to prevent sporadic test failure

activerecord/test/cases/query_cache_test.rbの修正です。

query cacheのテストで、テストの後処理でquery cacheをclearするようにしています。ランダムにコケるテストがあり、その対応の為との事です。


assert_send is going to be deprecated since minitest 5.10.0

activerecord/test/cases/adapters/postgresql/infinity_test.rbactiverecord/test/cases/adapters/postgresql/numbers_test.rbの修正です。

minitest 5.10.0でdeprecateになったassert_sendを使用している箇所があったのを、assert_sendを使用しないよう修正しています。


only enhance when assets:precompile task is defined

railties/lib/rails/tasks/yarn.rakeの修正です。

assets:precompile taskが定義されている場合のみ、assets:precompile taskの実行前にyarn:installを呼び出すようにしています。


Remove TODOs related to Exceptron [ci skip]

actionview/lib/action_view/renderer/streaming_template_renderer.rbのdocの修正です。

現状不要になっているexceptron gemに関連したコメントを削除しています。