なるようになるブログ

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

rails commit log流し読み(2017/11/10)

2017/11/10分のコミットです。

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

actionview/CHANGELOG.md


Fix field_error_proc wrap form select optgroup and divider option tag

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

formでエラーが発生した際に、field_error_procoptgroupタグやseletctタグ内のoptionタグもfield_with_errorsクラスでラップしていたのを、ラップしないよう修正しています。

<select name="post[category]" id="post_category">
  <option value="">Please select</option>
  <div class="field_with_errors">  <!-- ここ -->
    <optgroup label="A">
      <option value="A1">A1</option>
      <option value="A2">A2</option>
    </optgroup>
  </div>
</select>
<select id="post_time_zone" name="post[time_zone]">
  <option value=""></option>
  <option value="Hawaii">(GMT-10:00) Hawaii</option>
  <div class="field_with_errors">  <!-- ここ -->
    <option value="" disabled="disabled">-------------</option>
  </div>
</select>

元々は上記のようはhtmlが生成されていたのですが、selectタグの中にdivを書くのはhtmlの規約的にNGなので、上記ケースではfield_with_errorsを生成しないようにしています。


Merge pull request #31099 from nobu/patch-1

actionpack/test/controller/log_subscriber_test.rbの修正です。

cache用のtmpディレクトリを作成するのにDir::Tmpname.make_tmpnameを使用していたのを、Dir.mktmpdirを使用するよう修正しています。

Dir::Tmpname.make_tmpnameは内部用メソッドで、一意性は保証されておらず使用すべきでは無いため、とのことです。


Move Attribute and AttributeSet to ActiveModel

Active Modelの修正です。

Active Record配下にあったAttributeクラス及びAttributeSetクラスをActive Modelに移動しています。

Active Record内にあるattributes APIをActive Modelに移動する対応の一環。


Merge pull request #25346 from bogdan/correct-tags-count-in-fixtures

Active Recordのテストの修正です。

fixturesにcounter cacheの値が正しく指定されていなかったのを修正しています。


Merge pull request #30414 from bogdanvlviv/clear-mysql_database_tasks

Active Recordの修正です。

MySQL用のdatabase作成処理で、Access denied エラーがおきたときに、rootアカウントで再度処理を行う、という処理があったのをまとめて削除しています。

その処理の影響でAccess denied以外のエラーがおきた時にエラーメッセージが見づらくなってしまっていた為と、そもそも余計な事をせずエラーメッセージをそのまま表示した方が良いのでは、という事で削除されたようです。


Merge pull request #31027 from PHedkvist/inflector_test_type

activesupport/test/core_ext/string_ext_test.rbactivesupport/test/inflector_test_cases.rbの修正です。

parameterizeのテストでPreservePreserceにタイポしていたのを修正しています。


Bump RuboCop to 0.51.0

RuboCopのバージョンを0.51.0に更新、及び、copに違反している箇所があったのをまとめて修正しています。


Use -e option to specify the environment in console command [ci skip]

rails guideのThe Rails Command LineConfiguring Rails Applicationsの修正です。

rails consoleコマンドにenvを指定する際に、-eオプションを指定するよう修正しています。

-eオプションを使用しないenvの指定は、Deprecate environment as an argument for dbconsole and consoleでdeprecateになった為。


Add missing requires

activemodel/lib/active_model/attribute.rbactivemodel/test/cases/attribute_set_test.rbの修正です。

不足していたrequireを追加しています。


Remove unused require

activesupport/lib/active_support/test_case.rbの修正です。

不要なactive_support/core_ext/kernel/reportingのrequireを削除しています。


Merge pull request #31114 from y-yagi/fix_ruby_warnings_in_active_model

activemodel/lib/active_model/attributes.rbactivemodel/lib/active_model/dirty.rbの修正です。

Active ModelでRubyのwarnings("warning: instance variable @attributes not initialized"、及び、"warning: assigned but unused variable - name")が出ている箇所があったのを修正しています。


Use new RDoc URL of Ruby core [ci skip]

rails guideのAPI Documentation Guidelinesの修正です。

RDocのURLを正しいURLに修正しています。

-[RDoc](http://docs.seattlerb.org/rdoc/). To generate it, make sure you are
+[RDoc](https://ruby.github.io/rdoc/). To generate it, make sure you are

RDocはruby core配下で管理されてるので、ruby.github.ioが正しいURLなんですねえ。


Use new Rake URL of Ruby core [ci skip]

actionview/RUNNING_UNIT_TESTS.rdocの修正です。

RakeのURLを正しいURLに修正しています。

-Rake can be found at http://docs.seattlerb.org/rake/.
+Rake can be found at https://ruby.github.io/rake/.

こちらも同様にruby.github.io配下。


Remove useless preloader classes

Active Recordの修正です。

ActiveRecord::Associations::Preloader配下の不要なクラス(重複していた実装があった or そもそも実装が無かった)をまとめて削除しています。


Add missing requires

activemodel/lib/active_model/attribute.rbの修正です。

不足していたactive_model/typeのrequireを追加しています。


Merge pull request #31065 from bogdan/cleanup-cache-key

activesupport/lib/active_support/cache.rbの修正です。

Cache::Store#expanded_keyメソッドとCache.expanded_keyメソッドの実装が重複していたので、Store#expanded_keyメソッドを削除しCache.expanded_keyの方を使い回すよう修正しています。


Adjust blank lines

railtiesの修正です。

rails newで生成されるGemfile、gitignore、environmentsファイル内のコード間の空行の調整を行っています。


:scissors:

activesupport/CHANGELOG.mdの修正です。

不要なスペースを削除しています。


Ensure apply_join_dependency for subqueries in from and where

activerecord/lib/active_record/relation/predicate_builder/relation_handler.rbactiverecord/lib/active_record/relation/query_methods.rbの修正です。

PredicateBuilder::RelationHandler#callメソッド、及び、QueryMethods#build_fromメソッドでeager loadを使用している場合に、apply_join_dependencyメソッドを呼び出すよう修正しています。

fromメソッド、及び、whereメソッド内でsubquery + eager loadを使用した場合に正しいSQLを生成出来るようにするため、のようです。


Consolidate duplicated to_ary/to_a definitions in Relation and CollectionProxy

activerecord/lib/active_record/associations/collection_proxy.rbactiverecord/lib/active_record/relation.rbの修正です。

RelationCollectionProxyそれぞれに定義されていた同じ値を返すto_ary / to_aメソッドの定義をRelation側にマージしています。


Fix random CI failure due to non-deterministic sorting order

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

test_finding_with_subquery_with_eager_loading_in_whereでassociationを取得する際に、idでsortするよう修正しています。

sortしないと結果が不定になり、seedによってはテストが失敗してしまう為。


Add missing require "active_support/core_ext/hash/indifferent_access"

activemodel/lib/active_model/attribute_mutation_tracker.rbの修正です。

不足していたactive_support/core_ext/hash/indifferent_accessのrequireを追加しています。