なるようになるブログ

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

rails commit log流し読み(2014/11/25)

2014/11/25分のコミットです。

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

activerecord/CHANGELOG.md

actionmailer/CHANGELOG.md

actionpack/CHANGELOG.md


Reword documentation for update_all

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

update_allメソッドの説明の箇所で、current relationのレコードが更新される旨説明を追加しています。合わせて、default_scopeについての記述は削除しています。 default_scopeが全てのメソッドに影響出るのは、別な箇所で説明されているので、ここで言及する必要は無いからのようです。


Change 'of plugins' syntax

generatorで生成されるjs/cssのテンプレートファイルの修正です。

vendor/assets/配下についての説明のグラマーを改善しています。元々の説明が一般的なAmerican Englishでは無かった、との事なのですが…。良く解らない…。


Fix wrong path in comments about stylesheets

railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.cssの修正です。

上記グラマーの改善で、stylesheetsのパスを誤って記載してしまったのを修正しています。


Merge pull request #17707 from claudiob/move-debug-helper-test

actionview/test/template/debug_helper_test.rb → actionview/test/activerecord/debug_helper_test.rb に移動しています。

debug_helper_test.rbがActiveRecordに依存している為、activerecord配下に移動したようです。


Merge pull request #17678 from siddharth28/includes_with_scope_with_joins

activerecord/lib/active_record/associations/preloader/association.rbactiverecord/lib/active_record/relation/query_methods.rbの修正です。

アソシエーションをincludesした際、そのアソシエーションがコンディションの指定でjoinを指定した場合に、正しく動作してなかったバグがあったのを修正しています。

何か何書いてるのか良く解らなくなってきたので、issueから抜粋。

class Character < ActiveRecord::Base
  has_many :appearances, -> { joins(:books).order("books.published_on") }
end

Character.where(name: "Gandalf").includes(:appearances).first

=> SQLite3::SQLException: no such column: books.published_on:
  SELECT "appearances".* FROM "appearances"
  WHERE "appearances"."character_id" IN (1)
  ORDER BY "books"."published_on"

Merge pull request #17737 from yui-knk/fix/head

guides/source/configuring.mdrailties/lib/rails/configuration.rbの修正です。

ActionDispatch::Head -> Rack::Headに修正しています。


Merge pull request #17725 from chancancode/deprecate_use_route

actionpack/lib/action_controller/test_case.rbactionpack/lib/action_dispatch/journey/formatter.rbの修正です。

functional testでprocessメソッド等でuse_routeオプションを使用するのは、deprecateになりました。

functional testの場合、routingがどうなってるかは明確な筈なので、use_routeを使用するのではなく、processメソッドに適切なオプションを渡すようにしてね、との事です。


Ensure the type map's cache is thread safe

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

ActiveRecord::Type::TypeMapでキャッシュの保持に普通のHashを使用していたのを、ThreadSafe::Cacheクラスを使用するよう修正しています。

スレッドセーフに動作するように、ですねえ。


Add .reflections change to release note [skip ci]

guides/source/4_2_release_notes.mdの修正です。

ActiveRecord::Base#reflectionsの修正について、release noteに追記しています。


Mark comments that should not be in the docs

ActiveRecordのdocの修正です。

API docに含めたくないコメントについて、非表示用のオプションを設定しています。

+      #--
       # DATABASE STATEMENTS ======================================
+      #++

Show source view and backtrace on missing template errors

actionpack/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erbactionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erbの修正です。

Missing Template errorが起きた際、他のエラー画面と同様にsource viewと backtraceを表示するよう修正しています。

error

便利…なような…。 Missing Template errorが起きた際って、単純にテンプレートの作成ミスのケースが多いので、あんまりピンときてない…。


Document String#html_safe [ci skip]

activesupport/lib/active_support/core_ext/string/output_safety.rbのdocn修正です。

String#html_safeメソッドについて、API docを追加しています。


Fix sprockets-rails dependency dance

rails.gemspecrailties/lib/rails/generators/app_base.rbの修正です。

generateされるGemfileからsprockets-railsの削除、rails.gemspecsprockets-railsのバージョンの指定を'>= 2.0.0'に修正しています。

railssprockets-railsに依存している為、generateされるGemfileから削除したとの事です。


allow the "USING" statement to be specified on change column calls

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

PostgreSQLの場合、"USING"句が使用出来るよう対応しています。

-          execute "ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{sql_type}"
+          sql = "ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{sql_type}"
+          sql << " USING #{options[:using]}" if options[:using]
+          execute sql

optionsに:usingを指定してあげればOKなようです。


oops, forgot to add the real assertion!

activerecord/test/cases/adapters/postgresql/change_schema_test.rbの修正です。

上記"USING"の対応でテスト中にassertメソッドの追加が漏れていたので、追加しています。


allow types to be passed in for USING casts

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

PostgreSQLの場合、"CAST"句が使用出来るよう対応しています。

+          if options[:cast_as]
+            sql << " USING CAST(#{quote_column_name(column_name)} AS #{type_to_sql(options[:cast_as], options[:limit], options[:precision], options[:scale])})"
+          end

let mailer templates generate URLs by default [Xavier Noria, Richard Schneeman]

mailerのテンプレートで、link_tourl_forメソッドがデフォルトでURL全体を作成するよう修正しています。

これでプロトコルを変更したい場合に、いちいちonly_path: falseを渡す必要が無くなりました。便利。


Merge pull request #17646 from andyjeffries/html_layout_fix

ActionMailerの修正です。

mailer用のファイルを生成する際、mailer用のレイアウトファイルを生成するよう対応しています。生成されるファイルは以下の内容。

# app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
  default from: "from@example.com"
  layout 'mailer'
end
# app/views/layouts/mailer.html.erb
<html>
  <body>
    <%= yield %>
  </body>
</html>
# app/views/layouts/mailer.text.erb
<%= yield %>

Add a CHANGELOG entry for #16622 and a6de6f5 [ci skip]

railties/CHANGELOG.mdの修正です。

デフォルトログレベルの変更対応CHANGELOGに追記しています。


Add tests which were incorrectly removed.

ActionMailerのテストの修正です。

先に行われたmailerのテンプレート生成の対応で、誤って削除してしまったテストを戻しています。


MailerGenerator should inherit from Base.

railties/lib/rails/generators/erb/mailer/mailer_generator.rbの修正です。

MailerGeneratorクラスの親クラスをControllerGeneratorからBaseに変更しています。

元々


Generate mailer layouts even if no action is given.

railties/lib/rails/generators/erb/mailer/mailer_generator.rbの修正です。

mailerのgeneratorで、アクション名が指定されてない場合でも、テンプレートファイルは生成するよう対応しています。


Add missing CHANGELOG entry.

actionmailer/CHANGELOG.mdの修正です。

mailerのレイアウトファイルをの作成対応について、CHANGELOGに追記しています。


Update docs to reflect changes to MailerGenerator.

actionmailer/lib/action_mailer/base.rbguides/source/action_mailer_basics.mdの修正です。

上記レイアウトファイルの生成対応による変更内容を、各docに反映しています。


Deprecate string options in URL helpers

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

URL helpersメソッドのkeyにStringを使用するのがdeprecateになりました。代わりにSymbolを使用するように、との事です。


Changelog format

actionpack/CHANGELOG.mdの修正です。

フォーマットを整えています。


Add perform_enqueued_jobs

activejob/lib/active_job/test_helper.rbの修正です。

ActiveJobのテスト用メソッドassert_performed_jobsassert_no_performed_jobsassert_performed_withを使用する際、テスト側でperform_enqueued_jobs = trueを設定する必要があったのですが、各メソッド内で設定するよう対応しています。

assert_performed_jobs 0

perform_enqueued_jobs do
  HelloJob.perform_later('xavier')
end
assert_performed_jobs 1

perform_enqueued_jobs do
  HelloJob.perform_later('yves')
  assert_performed_jobs 2
end

ちょっと便利になりました。


Always default the log_level to :info for Railties

railties/test/isolation/abstract_unit.rbの修正です。

デフォルトのログレベルに:infoを指定しています。


Add Release Note for #16622 [ci skip]

guides/source/4_2_release_notes.mdの修正です。

https://github.com/rails/rails/pull/16622 の対応について、release noteに追記しています。


Add release note for #17743 [ci skip]

guides/source/4_2_release_notes.mdの修正です。

https://github.com/rails/rails/pull/16622 の対応について、release noteに追記しています。


Merge pull request #17760 from zzak/release-not-for-17743

https://github.com/rails/rails/pull/17743 の対応について、release noteに追記しています。


let the AM test suite pass in 1.9

actionmailer/test/url_test.rbの修正です。

ActionMailerのテストでキーワード引数を使用している箇所があり、1.9系でテストが失敗してしまっていた為、キーワード引数を使用していた箇所を修正しています。


Mention log_level deprecation in upgrade guides [ci skip]

rails guideのA Guide for Upgrading Ruby on Railsの修正です。

Rails 5からproductionのデフォルトログレベルが:debug変更になる事について、説明を追加しています。


Fix out of range error message

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

RangeErrorのエラーメッセージにタイポがあったのを修正しています。


Set the default log_level to info in all tests

railties/test/isolation/abstract_unit.rbの修正です。

デフォルトのログレベルを:infoに修正しています。

ログ出力を減らす事でテストの高速化、ログレベルが設定されてない事によるdeprecationが出力されるのを避ける為との事です。


Set the test_order in the basic app as well, see 58e8b48

railties/test/application/configuration_test.rbrailties/test/isolation/abstract_unit.rbの修正です。

app.config.active_support.test_orderを設定し、不要なdeprecateメッセージが出力されないよう対応しています。また、合わせてtest_orderが設定されてない場合にdeprecateメッセージが出力される事についてのテストを追加しています。


Added tests for log_level deprecation

railties/test/application/configuration_test.rbの修正です。

config.log_levelが設定されてない場合に、deprecateメッセージが出力される事についてのテストを追加しています。


Simplify section on adequate record [ci skip]

rails guideのRuby on Rails 4.2 Release Notesの修正です。

Adequate Recordについての説明を修正しています。


The default hasn't changed, so this is not an incompatibility [ci skip]

rails guideのRuby on Rails 4.2 Release Notesの修正です。

Production loggingの項を削除しています。

rails 4.2ではproduction環境のデフォルトログレベルは変わらなかったので、不要な項の為まるごと削除したようです。


:scissors: TODO

rails guideのRuby on Rails 4.2 Release Notesの修正です。

assert_selectメソッドの説明の箇所にあったTODOを削除しています。ちゃんと説明を書くように、とのTODOだったのですが、あまり内容は変わってないような。


Final sync with CHANGELOGs [ci skip]

rails guideのRuby on Rails 4.2 Release Notesの修正です。

CHANGELOGの内容をrelease noteに反映しています。


sets script_name to always be a string.

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

url_forメソッドscript_nameオプションにnilを指定した場合に、String(空文字)を返すよう修正しています。

nilの場合、url_forメソッド内部でエラーになってしまっていた為、対応したとの事です


Add regression test case to ensure script_name as nil is not used anymore in url_for

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

上記script_nameオプションにnilを指定した場合についてのテストを追加しています。


Cross link to upgrade guide [ci skip]

rails guideのRuby on Rails 4.2 Release Notesの修正です。

respondersについての説明を行っている箇所で、upgrading_ruby_on_railsガイドへのリンクをを追加しています。


Prepare for RC: link to the 4-2-stable [ci skip]

guides/source/4_2_release_notes.mdguides/source/upgrading_ruby_on_rails.mdの修正です。

コミットの参照先を、masterブランチから4-2-stabbleブランチに修正しています。


We shouldn't be linking to edgeapi [ci skip]

rails guideのGetting Started with Enginesの修正です。

edgeapi.rubyonrails.orgの方にリンクを張っている箇所があったのを、api.rubyonrails.orgにリンクを修正しています。


Prepare for RC: un-wip release notes [ci skip]

guides/source/documents.yamlの修正です。

Ruby on Rails 4.2 Release Notesからwork_in_progress: trueを削除しています。


:scissors: WIP labels [ci skip]

rails guideのRuby on Rails 4.2 Release Notesの修正です。

guideからWIPを削除しています。


Rearrange release notes by importance [ci skip]

rails guideのRuby on Rails 4.2 Release Notesの修正です。

release noteの順番を、重要な順に並び替えています。


tests, run test_test.rb with RAILS_ENV=test.

railties/test/application/test_test.rbの修正です。

テストを単体で実行する際、envに"RAILS_ENV => test"を設定するよう修正しています。


Merge pull request #17753 from gsamokovarov/dont-center-routing-table

actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erbの修正です。

routing errorsの際に表示されるRoutesをセンタリングしないよう修正しています。

before

before

aftr

after


Merge pull request #17754 from eileencodes/refactor-aliased_table_for

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

aliased_table_foraliased_name_forメソッドを一つにまとめています。 類似処理をまとめて、コンディションチェックを減らす為、との事です。