なるようになるブログ

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

rails commit log流し読み(2015/05/28)

2015/05/28分のコミットです。

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

activerecord/CHANGELOG.md

actionpack/lib/action_controller/metal/rendering.rb


Fix indentation warning on active_support ordered_options

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

method_missingメソッドで、 インデントがずれていて下記ワーニング出ていたのを対応しています。

rails/activesupport/lib/active_support/ordered_options.rb:40: warning: mismatched indentations at 'end' with 'if' at 36

Remove web-console and spring from test group on default Gemfile.

railties/lib/rails/generators/rails/app/templates/Gemfileの集計です。

developmenttestグループ配下に記載してあったweb-consolespringdevelopmentグループ配下のみに修正しています。

web-consoleがデフォルトではdevelopment環境での動作しなくなり、testグループ配下にあるのはおかしいだろう、という事で修正されたようです。参考: Force development only web console by default by gsamokovarov · Pull Request #134 · rails/web-console


Remove unnecessary reference to example Blog app [ci skip]

rails guideのThe Rails Initialization Processの修正です。

Back to config/environment.rbの項で、不要なBlog appへの言及があったのを削除しています。


add fixed file

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

updateタスクの中で、グローバルにメソッドを定義していたのを、新規にRailsUpdateクラスを作成し、その配下にメソッドを定義するよう修正しています。


[ci skip] Replace dead link about HttpOnly cookies.

rails guideのRuby on Rails Security Guideの修正です。

既に存在しないha.ckers.orgへのリンクがあったのを、www.owasp.org へのリンクに修正しています。


Merge pull request #19867 from radar/rename-app-rails-loader

railtiesの修正です。

Rails::AppRailsLoader moduleを Rails::AppLoaderに名前を変更しています。 namespaceをフルに書くと、Railsと2回入ってしまっており、冗長だろう、という事で修正されたようです。


Merge pull request #19808 from byroot/action-parameter https://github.com/rails/rails/commit/f02f2872426a5973bd2da720f843748d12c11513

actionpack/lib/action_controller/test_case.rbの修正です。

ActionController::TestRequestクラスを使用してテストを行った際、パラメータ名にactionを使用出来なかった問題があったのを、使用出来るよう対応しています。

getメソッド等にactionというキーのパラメータを渡すと、強制的にcontrollerのアクション名と判断してしまっていた為、使用出来なくなってしまっていたようです。


Fix file name

railties/test/app_loader_test.rbの修正です。

Rails::AppRailsLoader moduleを Rails::AppLoaderに名前を変更した対応で、require方の修正が漏れていたのを対応しています。


:bomb: Fix another leftover

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

先のコミット同様、Rails::AppRailsLoader moduleを Rails::AppLoaderに名前を変更した対応で、require方の修正が漏れていたのを対応しています。


Resolve enums in test fixtures

activerecord/lib/active_record/fixtures.rbの修正です。

fixture fileで、enumを使用しているattributeへの値の指定に、symbolを指定出来るよう対応しています。

awdr:
  title: "Agile Web Development with Rails"
  status: :proposed

Merge pull request #17654 from kamipo/strict_mode_explicitly

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb の修正です。

If our connection is explicitly non-strict, tell MySQL by matthewd · Pull Request #16065 · rails/rails の対応から、strictオプションが設定されている/いないに関わらず、sql_modeが設定されるようになってたのを、 strictオプションが指定されている場合、sql_modeを設定しないよう修正しています。


Merge pull request #19886 from henders/henders/reload_wipe_query_cache

activerecord/lib/active_record/persistence.rbの修正です。

ActiveRecord::Base#relaodメソッドを呼び出した際、query cacheもクリアーするよう修正しています。


Add application/vnd.api+json alias to the JSON MIME Type.

actionpack/lib/action_dispatch/http/mime_types.rbの修正です。

JSON MIME typeの一覧にapplication/vnd.api+jsonを追加しています。


Add collation support for string and text columns in SQLite3

ActiveRecordのSQLite3 adapterの修正です。

SQLite3のtextstringカラムにcollationオプションを指定出来るよう対応しています。

例。

create_table :foo do |t|
  t.string :string_nocase, collation: 'NOCASE'
  t.text :text_rtrim, collation: 'RTRIM'
end

add_column :foo, :title, :string, collation: 'RTRIM'
change_column :foo, :title, :string, collation: 'NOCASE'

Allow Relation#compact using delegation

activerecord/lib/active_record/relation/delegation.rbの修正です。

Relation#compactメソッドArray#compactdelegate出来るよう、BLACKLISTED_ARRAY_METHODSから:compactを削除しています。


Add test to 57daaef

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

先のRelation#compactメソッドの対応のテストを追加しています。


Merge pull request #20263 from arunagw/aa-remove-custom-lines-actionview

actionview/Rakefileの修正です。

全体の行数を表示する為のrake taskで、独自に行計算のロジックを定義していたのを、既存のCodeTools::LineStatisticsクラスを使用するよう修正しています。


Properly append preload / includes args on Merger

activerecord/lib/active_record/relation/merger.rbの修正です。

Merger#mergeメソッドpreloadincludesメソッドにした値もmerge処理行うよう修正しています。

preloadがmergeされてなかった為、association名が解決出来ず、AssociationNotFoundErrorがおきてしまうという問題が起きるケースがあった為追加したとの事です。

issueより例。

class Product < ActiveRecord::Base
  has_many :variants
  has_many :translations
end

class Translation < ActiveRecord::Base
  belongs_to :product
end

class Variant < ActiveRecord::Base
  belongs_to :product
end

class BugTest < Minitest::Test
  def test_merge_stuff
    product = Product.create! name: 'huhu'
    variant = Variant.create! product_id: product.id
    Translation.create! locale: 'en', product_id: product.id

    product_relation = Product.all
                              .preload(:translations)
                              .joins(:translations)
                              .merge(Translation.where(locale: 'en'))
                              .where(name: 'huhu')

    Variant.joins(:product).merge(product_relation).first
    # => ActiveRecord::AssociationNotFoundError: Association named 'translations' was not found on Variant; perhaps you misspelled it?
  end
end

Give credit to extra contributor for Base.reload fix

activerecord/CHANGELOG.mdの修正です。

Clear query cache when ActiveRecord::Base#relaod is called.の説明についてタイポがあったのを修正、及びコントリビューターに協力者の名前を追加しています。


Deprecate :nothing option for render method

actionpack/lib/action_controller/metal/rendering.rbの修正です。

renderメソッドnothingオプションがdeprecateになりました。

headメソッドがほぼ同じ動作をするので、response bodyを空にしたい場合は、headメソッドの方を使用するよう、との事です。


[ci skip] Fix block parameter of assert_no_difference

rails guideのA Guide to Testing Rails Applicationsの修正です。

assert_no_differenceメソッドについて説明している箇所で、引数の&block&amp;blockにタイポしていたのを修正しています。