aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--Rakefile2
-rw-r--r--actionmailer/Rakefile4
-rw-r--r--actionpack/CHANGELOG.md42
-rw-r--r--actionpack/Rakefile27
-rw-r--r--actionpack/actionpack.gemspec4
-rw-r--r--actionpack/lib/action_controller/test_case.rb12
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb2
-rw-r--r--actionpack/lib/action_dispatch/journey/router.rb8
-rw-r--r--actionpack/lib/action_dispatch/middleware/ssl.rb5
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb12
-rw-r--r--actionpack/test/controller/caching_test.rb1
-rw-r--r--actionpack/test/controller/render_test.rb6
-rw-r--r--actionpack/test/controller/test_case_test.rb7
-rw-r--r--actionpack/test/dispatch/mount_test.rb5
-rw-r--r--actionpack/test/dispatch/routing_test.rb13
-rw-r--r--actionpack/test/dispatch/ssl_test.rb19
-rw-r--r--actionview/CHANGELOG.md61
-rw-r--r--actionview/MIT-LICENSE21
-rw-r--r--actionview/README.rdoc31
-rw-r--r--actionview/RUNNING_UNIT_TESTS27
-rw-r--r--actionview/Rakefile77
-rw-r--r--actionview/actionview.gemspec29
-rw-r--r--actionview/lib/action_view.rb (renamed from actionpack/lib/action_view.rb)1
-rw-r--r--actionview/lib/action_view/base.rb (renamed from actionpack/lib/action_view/base.rb)0
-rw-r--r--actionview/lib/action_view/buffers.rb (renamed from actionpack/lib/action_view/buffers.rb)0
-rw-r--r--actionview/lib/action_view/context.rb (renamed from actionpack/lib/action_view/context.rb)0
-rw-r--r--actionview/lib/action_view/dependency_tracker.rb (renamed from actionpack/lib/action_view/dependency_tracker.rb)0
-rw-r--r--actionview/lib/action_view/digestor.rb (renamed from actionpack/lib/action_view/digestor.rb)0
-rw-r--r--actionview/lib/action_view/flows.rb (renamed from actionpack/lib/action_view/flows.rb)4
-rw-r--r--actionview/lib/action_view/helpers.rb (renamed from actionpack/lib/action_view/helpers.rb)0
-rw-r--r--actionview/lib/action_view/helpers/active_model_helper.rb (renamed from actionpack/lib/action_view/helpers/active_model_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/asset_tag_helper.rb (renamed from actionpack/lib/action_view/helpers/asset_tag_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/asset_url_helper.rb (renamed from actionpack/lib/action_view/helpers/asset_url_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/atom_feed_helper.rb (renamed from actionpack/lib/action_view/helpers/atom_feed_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/cache_helper.rb (renamed from actionpack/lib/action_view/helpers/cache_helper.rb)30
-rw-r--r--actionview/lib/action_view/helpers/capture_helper.rb (renamed from actionpack/lib/action_view/helpers/capture_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/controller_helper.rb (renamed from actionpack/lib/action_view/helpers/controller_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/csrf_helper.rb (renamed from actionpack/lib/action_view/helpers/csrf_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/date_helper.rb (renamed from actionpack/lib/action_view/helpers/date_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/debug_helper.rb (renamed from actionpack/lib/action_view/helpers/debug_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/form_helper.rb (renamed from actionpack/lib/action_view/helpers/form_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/form_options_helper.rb (renamed from actionpack/lib/action_view/helpers/form_options_helper.rb)15
-rw-r--r--actionview/lib/action_view/helpers/form_tag_helper.rb (renamed from actionpack/lib/action_view/helpers/form_tag_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/javascript_helper.rb (renamed from actionpack/lib/action_view/helpers/javascript_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/number_helper.rb (renamed from actionpack/lib/action_view/helpers/number_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/output_safety_helper.rb (renamed from actionpack/lib/action_view/helpers/output_safety_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/record_tag_helper.rb (renamed from actionpack/lib/action_view/helpers/record_tag_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/rendering_helper.rb (renamed from actionpack/lib/action_view/helpers/rendering_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/sanitize_helper.rb (renamed from actionpack/lib/action_view/helpers/sanitize_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tag_helper.rb (renamed from actionpack/lib/action_view/helpers/tag_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags.rb (renamed from actionpack/lib/action_view/helpers/tags.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/base.rb (renamed from actionpack/lib/action_view/helpers/tags/base.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/check_box.rb (renamed from actionpack/lib/action_view/helpers/tags/check_box.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/checkable.rb (renamed from actionpack/lib/action_view/helpers/tags/checkable.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_check_boxes.rb (renamed from actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_helpers.rb (renamed from actionpack/lib/action_view/helpers/tags/collection_helpers.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb (renamed from actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/collection_select.rb (renamed from actionpack/lib/action_view/helpers/tags/collection_select.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/color_field.rb (renamed from actionpack/lib/action_view/helpers/tags/color_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/date_field.rb (renamed from actionpack/lib/action_view/helpers/tags/date_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/date_select.rb (renamed from actionpack/lib/action_view/helpers/tags/date_select.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/datetime_field.rb (renamed from actionpack/lib/action_view/helpers/tags/datetime_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/datetime_local_field.rb (renamed from actionpack/lib/action_view/helpers/tags/datetime_local_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/datetime_select.rb (renamed from actionpack/lib/action_view/helpers/tags/datetime_select.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/email_field.rb (renamed from actionpack/lib/action_view/helpers/tags/email_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/file_field.rb (renamed from actionpack/lib/action_view/helpers/tags/file_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/grouped_collection_select.rb (renamed from actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/hidden_field.rb (renamed from actionpack/lib/action_view/helpers/tags/hidden_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/label.rb (renamed from actionpack/lib/action_view/helpers/tags/label.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/month_field.rb (renamed from actionpack/lib/action_view/helpers/tags/month_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/number_field.rb (renamed from actionpack/lib/action_view/helpers/tags/number_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/password_field.rb (renamed from actionpack/lib/action_view/helpers/tags/password_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/radio_button.rb (renamed from actionpack/lib/action_view/helpers/tags/radio_button.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/range_field.rb (renamed from actionpack/lib/action_view/helpers/tags/range_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/search_field.rb (renamed from actionpack/lib/action_view/helpers/tags/search_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/select.rb (renamed from actionpack/lib/action_view/helpers/tags/select.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/tel_field.rb (renamed from actionpack/lib/action_view/helpers/tags/tel_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/text_area.rb (renamed from actionpack/lib/action_view/helpers/tags/text_area.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/text_field.rb (renamed from actionpack/lib/action_view/helpers/tags/text_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/time_field.rb (renamed from actionpack/lib/action_view/helpers/tags/time_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/time_select.rb (renamed from actionpack/lib/action_view/helpers/tags/time_select.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/time_zone_select.rb (renamed from actionpack/lib/action_view/helpers/tags/time_zone_select.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/url_field.rb (renamed from actionpack/lib/action_view/helpers/tags/url_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/tags/week_field.rb (renamed from actionpack/lib/action_view/helpers/tags/week_field.rb)0
-rw-r--r--actionview/lib/action_view/helpers/text_helper.rb (renamed from actionpack/lib/action_view/helpers/text_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/translation_helper.rb (renamed from actionpack/lib/action_view/helpers/translation_helper.rb)0
-rw-r--r--actionview/lib/action_view/helpers/url_helper.rb (renamed from actionpack/lib/action_view/helpers/url_helper.rb)0
-rw-r--r--actionview/lib/action_view/locale/en.yml (renamed from actionpack/lib/action_view/locale/en.yml)0
-rw-r--r--actionview/lib/action_view/log_subscriber.rb (renamed from actionpack/lib/action_view/log_subscriber.rb)0
-rw-r--r--actionview/lib/action_view/lookup_context.rb (renamed from actionpack/lib/action_view/lookup_context.rb)0
-rw-r--r--actionview/lib/action_view/model_naming.rb (renamed from actionpack/lib/action_view/model_naming.rb)0
-rw-r--r--actionview/lib/action_view/path_set.rb (renamed from actionpack/lib/action_view/path_set.rb)0
-rw-r--r--actionview/lib/action_view/railtie.rb (renamed from actionpack/lib/action_view/railtie.rb)0
-rw-r--r--actionview/lib/action_view/record_identifier.rb (renamed from actionpack/lib/action_view/record_identifier.rb)0
-rw-r--r--actionview/lib/action_view/renderer/abstract_renderer.rb (renamed from actionpack/lib/action_view/renderer/abstract_renderer.rb)0
-rw-r--r--actionview/lib/action_view/renderer/partial_renderer.rb (renamed from actionpack/lib/action_view/renderer/partial_renderer.rb)0
-rw-r--r--actionview/lib/action_view/renderer/renderer.rb (renamed from actionpack/lib/action_view/renderer/renderer.rb)0
-rw-r--r--actionview/lib/action_view/renderer/streaming_template_renderer.rb (renamed from actionpack/lib/action_view/renderer/streaming_template_renderer.rb)0
-rw-r--r--actionview/lib/action_view/renderer/template_renderer.rb (renamed from actionpack/lib/action_view/renderer/template_renderer.rb)0
-rw-r--r--actionview/lib/action_view/routing_url_for.rb (renamed from actionpack/lib/action_view/routing_url_for.rb)0
-rw-r--r--actionview/lib/action_view/template.rb (renamed from actionpack/lib/action_view/template.rb)0
-rw-r--r--actionview/lib/action_view/template/error.rb (renamed from actionpack/lib/action_view/template/error.rb)0
-rw-r--r--actionview/lib/action_view/template/handlers.rb (renamed from actionpack/lib/action_view/template/handlers.rb)0
-rw-r--r--actionview/lib/action_view/template/handlers/builder.rb (renamed from actionpack/lib/action_view/template/handlers/builder.rb)0
-rw-r--r--actionview/lib/action_view/template/handlers/erb.rb (renamed from actionpack/lib/action_view/template/handlers/erb.rb)1
-rw-r--r--actionview/lib/action_view/template/handlers/raw.rb (renamed from actionpack/lib/action_view/template/handlers/raw.rb)0
-rw-r--r--actionview/lib/action_view/template/resolver.rb (renamed from actionpack/lib/action_view/template/resolver.rb)0
-rw-r--r--actionview/lib/action_view/template/text.rb (renamed from actionpack/lib/action_view/template/text.rb)0
-rw-r--r--actionview/lib/action_view/template/types.rb (renamed from actionpack/lib/action_view/template/types.rb)0
-rw-r--r--actionview/lib/action_view/test_case.rb (renamed from actionpack/lib/action_view/test_case.rb)0
-rw-r--r--actionview/lib/action_view/testing/resolvers.rb (renamed from actionpack/lib/action_view/testing/resolvers.rb)0
-rw-r--r--actionview/lib/action_view/vendor/html-scanner.rb (renamed from actionpack/lib/action_view/vendor/html-scanner.rb)0
-rw-r--r--actionview/lib/action_view/vendor/html-scanner/html/document.rb (renamed from actionpack/lib/action_view/vendor/html-scanner/html/document.rb)0
-rw-r--r--actionview/lib/action_view/vendor/html-scanner/html/node.rb (renamed from actionpack/lib/action_view/vendor/html-scanner/html/node.rb)0
-rw-r--r--actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb (renamed from actionpack/lib/action_view/vendor/html-scanner/html/sanitizer.rb)0
-rw-r--r--actionview/lib/action_view/vendor/html-scanner/html/selector.rb (renamed from actionpack/lib/action_view/vendor/html-scanner/html/selector.rb)0
-rw-r--r--actionview/lib/action_view/vendor/html-scanner/html/tokenizer.rb (renamed from actionpack/lib/action_view/vendor/html-scanner/html/tokenizer.rb)0
-rw-r--r--actionview/lib/action_view/vendor/html-scanner/html/version.rb (renamed from actionpack/lib/action_view/vendor/html-scanner/html/version.rb)0
-rw-r--r--actionview/lib/action_view/version.rb11
-rw-r--r--actionview/test/abstract_unit.rb382
-rw-r--r--actionview/test/active_record_unit.rb91
-rw-r--r--actionview/test/activerecord/controller_runtime_test.rb (renamed from actionpack/test/activerecord/controller_runtime_test.rb)0
-rw-r--r--actionview/test/activerecord/form_helper_activerecord_test.rb (renamed from actionpack/test/activerecord/form_helper_activerecord_test.rb)0
-rw-r--r--actionview/test/activerecord/polymorphic_routes_test.rb (renamed from actionpack/test/activerecord/polymorphic_routes_test.rb)0
-rw-r--r--actionview/test/activerecord/render_partial_with_record_identification_test.rb (renamed from actionpack/test/activerecord/render_partial_with_record_identification_test.rb)0
-rw-r--r--actionview/test/fixtures/_top_level_partial.html.erb (renamed from actionpack/test/fixtures/_top_level_partial.html.erb)0
-rw-r--r--actionview/test/fixtures/_top_level_partial_only.erb1
-rw-r--r--actionview/test/fixtures/blog_public/.gitignore (renamed from actionpack/test/fixtures/blog_public/.gitignore)0
-rw-r--r--actionview/test/fixtures/blog_public/blog.html (renamed from actionpack/test/fixtures/blog_public/blog.html)0
-rw-r--r--actionview/test/fixtures/blog_public/index.html (renamed from actionpack/test/fixtures/blog_public/index.html)0
-rw-r--r--actionview/test/fixtures/blog_public/subdir/index.html (renamed from actionpack/test/fixtures/blog_public/subdir/index.html)0
-rw-r--r--actionview/test/fixtures/comments/empty.de.html.erb (renamed from actionpack/test/fixtures/comments/empty.de.html.erb)0
-rw-r--r--actionview/test/fixtures/comments/empty.html.builder (renamed from actionpack/test/fixtures/comments/empty.html.builder)0
-rw-r--r--actionview/test/fixtures/comments/empty.html.erb (renamed from actionpack/test/fixtures/comments/empty.html.erb)0
-rw-r--r--actionview/test/fixtures/comments/empty.xml.erb (renamed from actionpack/test/fixtures/comments/empty.xml.erb)0
-rw-r--r--actionview/test/fixtures/companies.yml (renamed from actionpack/test/fixtures/companies.yml)0
-rw-r--r--actionview/test/fixtures/company.rb9
-rw-r--r--actionview/test/fixtures/custom_pattern/another.html.erb (renamed from actionpack/test/fixtures/custom_pattern/another.html.erb)0
-rw-r--r--actionview/test/fixtures/custom_pattern/html/another.erb (renamed from actionpack/test/fixtures/custom_pattern/html/another.erb)0
-rw-r--r--actionview/test/fixtures/custom_pattern/html/path.erb (renamed from actionpack/test/fixtures/custom_pattern/html/path.erb)0
-rw-r--r--actionview/test/fixtures/customers/_customer.html.erb1
-rw-r--r--actionview/test/fixtures/db_definitions/sqlite.sql (renamed from actionpack/test/fixtures/db_definitions/sqlite.sql)0
-rw-r--r--actionview/test/fixtures/developer.rb (renamed from actionpack/test/fixtures/developer.rb)0
-rw-r--r--actionview/test/fixtures/developers.yml (renamed from actionpack/test/fixtures/developers.yml)0
-rw-r--r--actionview/test/fixtures/developers/_developer.erb (renamed from actionpack/test/fixtures/developers/_developer.erb)0
-rw-r--r--actionview/test/fixtures/developers_projects.yml (renamed from actionpack/test/fixtures/developers_projects.yml)0
-rw-r--r--actionview/test/fixtures/digestor/comments/_comment.html.erb (renamed from actionpack/test/fixtures/digestor/comments/_comment.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/comments/_comments.html.erb (renamed from actionpack/test/fixtures/digestor/comments/_comments.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/events/_event.html.erb (renamed from actionpack/test/fixtures/digestor/events/_event.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/level/below/_header.html.erb (renamed from actionpack/test/fixtures/digestor/level/below/_header.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/level/below/index.html.erb (renamed from actionpack/test/fixtures/digestor/level/below/index.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/messages/_form.html.erb (renamed from actionpack/test/fixtures/digestor/messages/_form.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/messages/_header.html.erb (renamed from actionpack/test/fixtures/digestor/messages/_header.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/messages/_message.html.erb (renamed from actionpack/test/fixtures/digestor/messages/_message.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/messages/actions/_move.html.erb (renamed from actionpack/test/fixtures/digestor/messages/actions/_move.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/messages/edit.html.erb (renamed from actionpack/test/fixtures/digestor/messages/edit.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/messages/index.html.erb (renamed from actionpack/test/fixtures/digestor/messages/index.html.erb)0
-rw-r--r--actionview/test/fixtures/digestor/messages/show.html.erb (renamed from actionpack/test/fixtures/digestor/messages/show.html.erb)6
-rw-r--r--actionview/test/fixtures/fun/games/_game.erb (renamed from actionpack/test/fixtures/fun/games/_game.erb)0
-rw-r--r--actionview/test/fixtures/fun/games/hello_world.erb1
-rw-r--r--actionview/test/fixtures/fun/serious/games/_game.erb (renamed from actionpack/test/fixtures/fun/serious/games/_game.erb)0
-rw-r--r--actionview/test/fixtures/functional_caching/fragment_cached_without_digest.html.erb3
-rw-r--r--actionview/test/fixtures/games/_game.erb (renamed from actionpack/test/fixtures/games/_game.erb)0
-rw-r--r--actionview/test/fixtures/good_customers/_good_customer.html.erb1
-rw-r--r--actionview/test/fixtures/happy_path/render_action/hello_world.erb (renamed from actionpack/test/fixtures/happy_path/render_action/hello_world.erb)0
-rw-r--r--actionview/test/fixtures/layout_tests/alt/hello.erb (renamed from actionpack/test/fixtures/layout_tests/alt/hello.erb)0
-rw-r--r--actionview/test/fixtures/layouts/_column.html.erb (renamed from actionpack/test/fixtures/layouts/_column.html.erb)0
-rw-r--r--actionview/test/fixtures/layouts/_customers.erb1
-rw-r--r--actionview/test/fixtures/layouts/_partial_and_yield.erb (renamed from actionpack/test/fixtures/layouts/_partial_and_yield.erb)0
-rw-r--r--actionview/test/fixtures/layouts/_yield_only.erb (renamed from actionpack/test/fixtures/layouts/_yield_only.erb)0
-rw-r--r--actionview/test/fixtures/layouts/_yield_with_params.erb (renamed from actionpack/test/fixtures/layouts/_yield_with_params.erb)0
-rw-r--r--actionview/test/fixtures/layouts/streaming.erb (renamed from actionpack/test/fixtures/layouts/streaming.erb)0
-rw-r--r--actionview/test/fixtures/layouts/yield.erb2
-rw-r--r--actionview/test/fixtures/layouts/yield_with_render_inline_inside.erb (renamed from actionpack/test/fixtures/layouts/yield_with_render_inline_inside.erb)0
-rw-r--r--actionview/test/fixtures/layouts/yield_with_render_partial_inside.erb (renamed from actionpack/test/fixtures/layouts/yield_with_render_partial_inside.erb)0
-rw-r--r--actionview/test/fixtures/mascot.rb (renamed from actionpack/test/fixtures/mascot.rb)0
-rw-r--r--actionview/test/fixtures/mascots.yml (renamed from actionpack/test/fixtures/mascots.yml)0
-rw-r--r--actionview/test/fixtures/mascots/_mascot.html.erb (renamed from actionpack/test/fixtures/mascots/_mascot.html.erb)0
-rw-r--r--actionview/test/fixtures/multipart/bracketed_utf8_param5
-rw-r--r--actionview/test/fixtures/multipart/single_utf8_param5
-rw-r--r--actionview/test/fixtures/plain_text.raw (renamed from actionpack/test/fixtures/plain_text.raw)0
-rw-r--r--actionview/test/fixtures/plain_text_with_characters.raw (renamed from actionpack/test/fixtures/plain_text_with_characters.raw)0
-rw-r--r--actionview/test/fixtures/project.rb (renamed from actionpack/test/fixtures/project.rb)0
-rw-r--r--actionview/test/fixtures/projects.yml (renamed from actionpack/test/fixtures/projects.yml)0
-rw-r--r--actionview/test/fixtures/projects/_project.erb (renamed from actionpack/test/fixtures/projects/_project.erb)0
-rw-r--r--actionview/test/fixtures/public/.gitignore (renamed from actionpack/test/fixtures/public/.gitignore)0
-rw-r--r--actionview/test/fixtures/public/elsewhere/cools.js (renamed from actionpack/test/fixtures/public/elsewhere/cools.js)0
-rw-r--r--actionview/test/fixtures/public/elsewhere/file.css (renamed from actionpack/test/fixtures/public/elsewhere/file.css)0
-rw-r--r--actionview/test/fixtures/public/foo/baz.css3
-rw-r--r--actionview/test/fixtures/public/javascripts/application.js (renamed from actionpack/test/fixtures/public/javascripts/application.js)0
-rw-r--r--actionview/test/fixtures/public/javascripts/bank.js (renamed from actionpack/test/fixtures/public/javascripts/bank.js)0
-rw-r--r--actionview/test/fixtures/public/javascripts/common.javascript (renamed from actionpack/test/fixtures/public/javascripts/common.javascript)0
-rw-r--r--actionview/test/fixtures/public/javascripts/controls.js (renamed from actionpack/test/fixtures/public/javascripts/controls.js)0
-rw-r--r--actionview/test/fixtures/public/javascripts/dragdrop.js (renamed from actionpack/test/fixtures/public/javascripts/dragdrop.js)0
-rw-r--r--actionview/test/fixtures/public/javascripts/effects.js (renamed from actionpack/test/fixtures/public/javascripts/effects.js)0
-rw-r--r--actionview/test/fixtures/public/javascripts/prototype.js (renamed from actionpack/test/fixtures/public/javascripts/prototype.js)0
-rw-r--r--actionview/test/fixtures/public/javascripts/robber.js (renamed from actionpack/test/fixtures/public/javascripts/robber.js)0
-rw-r--r--actionview/test/fixtures/public/javascripts/subdir/subdir.js (renamed from actionpack/test/fixtures/public/javascripts/subdir/subdir.js)0
-rw-r--r--actionview/test/fixtures/public/javascripts/version.1.0.js (renamed from actionpack/test/fixtures/public/javascripts/version.1.0.js)0
-rw-r--r--actionview/test/fixtures/public/stylesheets/bank.css (renamed from actionpack/test/fixtures/public/stylesheets/bank.css)0
-rw-r--r--actionview/test/fixtures/public/stylesheets/random.styles (renamed from actionpack/test/fixtures/public/stylesheets/random.styles)0
-rw-r--r--actionview/test/fixtures/public/stylesheets/robber.css (renamed from actionpack/test/fixtures/public/stylesheets/robber.css)0
-rw-r--r--actionview/test/fixtures/public/stylesheets/subdir/subdir.css (renamed from actionpack/test/fixtures/public/stylesheets/subdir/subdir.css)0
-rw-r--r--actionview/test/fixtures/public/stylesheets/version.1.0.css (renamed from actionpack/test/fixtures/public/stylesheets/version.1.0.css)0
-rw-r--r--actionview/test/fixtures/replies.yml (renamed from actionpack/test/fixtures/replies.yml)0
-rw-r--r--actionview/test/fixtures/replies/_reply.erb (renamed from actionpack/test/fixtures/replies/_reply.erb)0
-rw-r--r--actionview/test/fixtures/reply.rb (renamed from actionpack/test/fixtures/reply.rb)0
-rw-r--r--actionview/test/fixtures/respond_to/using_defaults_with_all.html.erb1
-rw-r--r--actionview/test/fixtures/ruby_template.ruby2
-rw-r--r--actionview/test/fixtures/scope/test/modgreet.erb (renamed from actionpack/test/fixtures/scope/test/modgreet.erb)0
-rw-r--r--actionview/test/fixtures/shared.html.erb1
-rw-r--r--actionview/test/fixtures/test/_200.html.erb (renamed from actionpack/test/fixtures/test/_200.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_b_layout_for_partial.html.erb (renamed from actionpack/test/fixtures/test/_b_layout_for_partial.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_b_layout_for_partial_with_object.html.erb (renamed from actionpack/test/fixtures/test/_b_layout_for_partial_with_object.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_b_layout_for_partial_with_object_counter.html.erb (renamed from actionpack/test/fixtures/test/_b_layout_for_partial_with_object_counter.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_changing_priority.html.erb1
-rw-r--r--actionview/test/fixtures/test/_changing_priority.json.erb1
-rw-r--r--actionview/test/fixtures/test/_content_tag_nested_in_content_tag.erb (renamed from actionpack/test/fixtures/test/_content_tag_nested_in_content_tag.erb)0
-rw-r--r--actionview/test/fixtures/test/_counter.html.erb1
-rw-r--r--actionview/test/fixtures/test/_customer.erb1
-rw-r--r--actionview/test/fixtures/test/_customer_greeting.erb1
-rw-r--r--actionview/test/fixtures/test/_customer_with_var.erb1
-rw-r--r--actionview/test/fixtures/test/_directory/_partial_with_locales.html.erb1
-rw-r--r--actionview/test/fixtures/test/_first_json_partial.json.erb1
-rw-r--r--actionview/test/fixtures/test/_from_helper.erb (renamed from actionpack/test/fixtures/test/_from_helper.erb)0
-rw-r--r--actionview/test/fixtures/test/_json_change_priority.json.erb0
-rw-r--r--actionview/test/fixtures/test/_label_with_block.erb (renamed from actionpack/test/fixtures/test/_label_with_block.erb)0
-rw-r--r--actionview/test/fixtures/test/_layout_for_block_with_args.html.erb (renamed from actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_layout_for_partial.html.erb3
-rw-r--r--actionview/test/fixtures/test/_layout_with_partial_and_yield.html.erb (renamed from actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_local_inspector.html.erb (renamed from actionpack/test/fixtures/test/_local_inspector.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_object_inspector.erb (renamed from actionpack/test/fixtures/test/_object_inspector.erb)0
-rw-r--r--actionview/test/fixtures/test/_one.html.erb (renamed from actionpack/test/fixtures/test/_one.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_partial.erb1
-rw-r--r--actionview/test/fixtures/test/_partial.html.erb1
-rw-r--r--actionview/test/fixtures/test/_partial.js.erb1
-rw-r--r--actionview/test/fixtures/test/_partial_for_use_in_layout.html.erb1
-rw-r--r--actionview/test/fixtures/test/_partial_name_local_variable.erb1
-rw-r--r--actionview/test/fixtures/test/_partial_only.erb1
-rw-r--r--actionview/test/fixtures/test/_partial_with_layout.erb (renamed from actionpack/test/fixtures/test/_partial_with_layout.erb)0
-rw-r--r--actionview/test/fixtures/test/_partial_with_layout_block_content.erb (renamed from actionpack/test/fixtures/test/_partial_with_layout_block_content.erb)0
-rw-r--r--actionview/test/fixtures/test/_partial_with_layout_block_partial.erb (renamed from actionpack/test/fixtures/test/_partial_with_layout_block_partial.erb)0
-rw-r--r--actionview/test/fixtures/test/_partial_with_only_html_version.html.erb (renamed from actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_partial_with_partial.erb2
-rw-r--r--actionview/test/fixtures/test/_raise.html.erb (renamed from actionpack/test/fixtures/test/_raise.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_raise_indentation.html.erb13
-rw-r--r--actionview/test/fixtures/test/_second_json_partial.json.erb1
-rw-r--r--actionview/test/fixtures/test/_two.html.erb (renamed from actionpack/test/fixtures/test/_two.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_utf8_partial.html.erb (renamed from actionpack/test/fixtures/test/_utf8_partial.html.erb)0
-rw-r--r--actionview/test/fixtures/test/_utf8_partial_magic.html.erb (renamed from actionpack/test/fixtures/test/_utf8_partial_magic.html.erb)0
-rw-r--r--actionview/test/fixtures/test/basic.html.erb (renamed from actionpack/test/fixtures/test/basic.html.erb)0
-rw-r--r--actionview/test/fixtures/test/calling_partial_with_layout.html.erb1
-rw-r--r--actionview/test/fixtures/test/change_priority.html.erb2
-rw-r--r--actionview/test/fixtures/test/dont_pick_me (renamed from actionpack/test/fixtures/test/dont_pick_me)0
-rw-r--r--actionview/test/fixtures/test/dot.directory/render_file_with_ivar.erb1
-rw-r--r--actionview/test/fixtures/test/greeting.xml.erb1
-rw-r--r--actionview/test/fixtures/test/hello.builder4
-rw-r--r--actionview/test/fixtures/test/hello/hello.erb1
-rw-r--r--actionview/test/fixtures/test/hello_world.da.html.erb (renamed from actionpack/test/fixtures/test/hello_world.da.html.erb)0
-rw-r--r--actionview/test/fixtures/test/hello_world.erb1
-rw-r--r--actionview/test/fixtures/test/hello_world.erb~ (renamed from actionpack/test/fixtures/test/hello_world.erb~)0
-rw-r--r--actionview/test/fixtures/test/hello_world.pt-BR.html.erb (renamed from actionpack/test/fixtures/test/hello_world.pt-BR.html.erb)0
-rw-r--r--actionview/test/fixtures/test/hello_world_with_partial.html.erb2
-rw-r--r--actionview/test/fixtures/test/html_template.html.erb1
-rw-r--r--actionview/test/fixtures/test/layout_render_file.erb (renamed from actionpack/test/fixtures/test/layout_render_file.erb)0
-rw-r--r--actionview/test/fixtures/test/layout_render_object.erb (renamed from actionpack/test/fixtures/test/layout_render_object.erb)0
-rw-r--r--actionview/test/fixtures/test/list.erb1
-rw-r--r--actionview/test/fixtures/test/malformed/malformed.en.html.erb~ (renamed from actionpack/test/fixtures/test/malformed/malformed.en.html.erb~)0
-rw-r--r--actionview/test/fixtures/test/malformed/malformed.erb~ (renamed from actionpack/test/fixtures/test/malformed/malformed.erb~)0
-rw-r--r--actionview/test/fixtures/test/malformed/malformed.html.erb~ (renamed from actionpack/test/fixtures/test/malformed/malformed.html.erb~)0
-rw-r--r--actionview/test/fixtures/test/malformed/malformed~1
-rw-r--r--actionview/test/fixtures/test/nested_layout.erb (renamed from actionpack/test/fixtures/test/nested_layout.erb)0
-rw-r--r--actionview/test/fixtures/test/nested_streaming.erb (renamed from actionpack/test/fixtures/test/nested_streaming.erb)0
-rw-r--r--actionview/test/fixtures/test/one.html.erb (renamed from actionpack/test/fixtures/test/one.html.erb)0
-rw-r--r--actionview/test/fixtures/test/render_file_with_ivar.erb1
-rw-r--r--actionview/test/fixtures/test/render_file_with_locals.erb1
-rw-r--r--actionview/test/fixtures/test/render_file_with_locals_and_default.erb1
-rw-r--r--actionview/test/fixtures/test/render_partial_inside_directory.html.erb1
-rw-r--r--actionview/test/fixtures/test/render_two_partials.html.erb2
-rw-r--r--actionview/test/fixtures/test/streaming.erb (renamed from actionpack/test/fixtures/test/streaming.erb)0
-rw-r--r--actionview/test/fixtures/test/streaming_buster.erb (renamed from actionpack/test/fixtures/test/streaming_buster.erb)0
-rw-r--r--actionview/test/fixtures/test/sub_template_raise.html.erb (renamed from actionpack/test/fixtures/test/sub_template_raise.html.erb)0
-rw-r--r--actionview/test/fixtures/test/template.erb (renamed from actionpack/test/fixtures/test/template.erb)0
-rw-r--r--actionview/test/fixtures/test/update_element_with_capture.erb (renamed from actionpack/test/fixtures/test/update_element_with_capture.erb)0
-rw-r--r--actionview/test/fixtures/test/utf8.html.erb (renamed from actionpack/test/fixtures/test/utf8.html.erb)0
-rw-r--r--actionview/test/fixtures/test/utf8_magic.html.erb (renamed from actionpack/test/fixtures/test/utf8_magic.html.erb)0
-rw-r--r--actionview/test/fixtures/test/utf8_magic_with_bare_partial.html.erb (renamed from actionpack/test/fixtures/test/utf8_magic_with_bare_partial.html.erb)0
-rw-r--r--actionview/test/fixtures/topic.rb (renamed from actionpack/test/fixtures/topic.rb)0
-rw-r--r--actionview/test/fixtures/topics.yml (renamed from actionpack/test/fixtures/topics.yml)0
-rw-r--r--actionview/test/fixtures/topics/_topic.html.erb (renamed from actionpack/test/fixtures/topics/_topic.html.erb)0
-rw-r--r--actionview/test/fixtures/translations/templates/array.erb (renamed from actionpack/test/fixtures/translations/templates/array.erb)0
-rw-r--r--actionview/test/fixtures/translations/templates/default.erb (renamed from actionpack/test/fixtures/translations/templates/default.erb)0
-rw-r--r--actionview/test/fixtures/translations/templates/found.erb (renamed from actionpack/test/fixtures/translations/templates/found.erb)0
-rw-r--r--actionview/test/fixtures/translations/templates/missing.erb (renamed from actionpack/test/fixtures/translations/templates/missing.erb)0
-rw-r--r--actionview/test/fixtures/with_format.json.erb (renamed from actionpack/test/fixtures/with_format.json.erb)0
-rw-r--r--actionview/test/lib/controller/fake_controllers.rb35
-rw-r--r--actionview/test/lib/controller/fake_models.rb185
-rw-r--r--actionview/test/template/active_model_helper_test.rb (renamed from actionpack/test/template/active_model_helper_test.rb)0
-rw-r--r--actionview/test/template/asset_tag_helper_test.rb (renamed from actionpack/test/template/asset_tag_helper_test.rb)0
-rw-r--r--actionview/test/template/atom_feed_helper_test.rb (renamed from actionpack/test/template/atom_feed_helper_test.rb)0
-rw-r--r--actionview/test/template/capture_helper_test.rb (renamed from actionpack/test/template/capture_helper_test.rb)0
-rw-r--r--actionview/test/template/compiled_templates_test.rb (renamed from actionpack/test/template/compiled_templates_test.rb)1
-rw-r--r--actionview/test/template/date_helper_i18n_test.rb (renamed from actionpack/test/template/date_helper_i18n_test.rb)0
-rw-r--r--actionview/test/template/date_helper_test.rb (renamed from actionpack/test/template/date_helper_test.rb)0
-rw-r--r--actionview/test/template/debug_helper_test.rb (renamed from actionpack/test/template/debug_helper_test.rb)0
-rw-r--r--actionview/test/template/dependency_tracker_test.rb (renamed from actionpack/test/template/dependency_tracker_test.rb)0
-rw-r--r--actionview/test/template/digestor_test.rb (renamed from actionpack/test/template/digestor_test.rb)0
-rw-r--r--actionview/test/template/erb/form_for_test.rb (renamed from actionpack/test/template/erb/form_for_test.rb)0
-rw-r--r--actionview/test/template/erb/helper.rb (renamed from actionpack/test/template/erb/helper.rb)0
-rw-r--r--actionview/test/template/erb/tag_helper_test.rb (renamed from actionpack/test/template/erb/tag_helper_test.rb)0
-rw-r--r--actionview/test/template/erb_util_test.rb (renamed from actionpack/test/template/erb_util_test.rb)0
-rw-r--r--actionview/test/template/form_collections_helper_test.rb (renamed from actionpack/test/template/form_collections_helper_test.rb)0
-rw-r--r--actionview/test/template/form_helper_test.rb (renamed from actionpack/test/template/form_helper_test.rb)0
-rw-r--r--actionview/test/template/form_options_helper_i18n_test.rb (renamed from actionpack/test/template/form_options_helper_i18n_test.rb)0
-rw-r--r--actionview/test/template/form_options_helper_test.rb (renamed from actionpack/test/template/form_options_helper_test.rb)17
-rw-r--r--actionview/test/template/form_tag_helper_test.rb (renamed from actionpack/test/template/form_tag_helper_test.rb)0
-rw-r--r--actionview/test/template/html-scanner/cdata_node_test.rb (renamed from actionpack/test/template/html-scanner/cdata_node_test.rb)0
-rw-r--r--actionview/test/template/html-scanner/document_test.rb (renamed from actionpack/test/template/html-scanner/document_test.rb)0
-rw-r--r--actionview/test/template/html-scanner/node_test.rb (renamed from actionpack/test/template/html-scanner/node_test.rb)0
-rw-r--r--actionview/test/template/html-scanner/sanitizer_test.rb (renamed from actionpack/test/template/html-scanner/sanitizer_test.rb)0
-rw-r--r--actionview/test/template/html-scanner/tag_node_test.rb (renamed from actionpack/test/template/html-scanner/tag_node_test.rb)0
-rw-r--r--actionview/test/template/html-scanner/text_node_test.rb (renamed from actionpack/test/template/html-scanner/text_node_test.rb)0
-rw-r--r--actionview/test/template/html-scanner/tokenizer_test.rb (renamed from actionpack/test/template/html-scanner/tokenizer_test.rb)0
-rw-r--r--actionview/test/template/javascript_helper_test.rb (renamed from actionpack/test/template/javascript_helper_test.rb)0
-rw-r--r--actionview/test/template/log_subscriber_test.rb (renamed from actionpack/test/template/log_subscriber_test.rb)0
-rw-r--r--actionview/test/template/lookup_context_test.rb (renamed from actionpack/test/template/lookup_context_test.rb)0
-rw-r--r--actionview/test/template/number_helper_test.rb (renamed from actionpack/test/template/number_helper_test.rb)0
-rw-r--r--actionview/test/template/output_buffer_test.rb (renamed from actionpack/test/template/output_buffer_test.rb)0
-rw-r--r--actionview/test/template/output_safety_helper_test.rb (renamed from actionpack/test/template/output_safety_helper_test.rb)0
-rw-r--r--actionview/test/template/record_identifier_test.rb (renamed from actionpack/test/template/record_identifier_test.rb)0
-rw-r--r--actionview/test/template/record_tag_helper_test.rb (renamed from actionpack/test/template/record_tag_helper_test.rb)0
-rw-r--r--actionview/test/template/render_test.rb (renamed from actionpack/test/template/render_test.rb)1
-rw-r--r--actionview/test/template/resolver_patterns_test.rb (renamed from actionpack/test/template/resolver_patterns_test.rb)0
-rw-r--r--actionview/test/template/sanitize_helper_test.rb (renamed from actionpack/test/template/sanitize_helper_test.rb)0
-rw-r--r--actionview/test/template/streaming_render_test.rb (renamed from actionpack/test/template/streaming_render_test.rb)1
-rw-r--r--actionview/test/template/tag_helper_test.rb (renamed from actionpack/test/template/tag_helper_test.rb)0
-rw-r--r--actionview/test/template/template_error_test.rb (renamed from actionpack/test/template/template_error_test.rb)0
-rw-r--r--actionview/test/template/template_test.rb (renamed from actionpack/test/template/template_test.rb)0
-rw-r--r--actionview/test/template/test_case_test.rb (renamed from actionpack/test/template/test_case_test.rb)1
-rw-r--r--actionview/test/template/test_test.rb (renamed from actionpack/test/template/test_test.rb)0
-rw-r--r--actionview/test/template/testing/fixture_resolver_test.rb (renamed from actionpack/test/template/testing/fixture_resolver_test.rb)0
-rw-r--r--actionview/test/template/testing/null_resolver_test.rb (renamed from actionpack/test/template/testing/null_resolver_test.rb)0
-rw-r--r--actionview/test/template/text_helper_test.rb (renamed from actionpack/test/template/text_helper_test.rb)0
-rw-r--r--actionview/test/template/translation_helper_test.rb (renamed from actionpack/test/template/translation_helper_test.rb)0
-rw-r--r--actionview/test/template/url_helper_test.rb (renamed from actionpack/test/template/url_helper_test.rb)1
-rw-r--r--activemodel/CHANGELOG.md9
-rw-r--r--activemodel/Rakefile2
-rw-r--r--activemodel/examples/validations.rb2
-rw-r--r--activemodel/lib/active_model.rb1
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb8
-rw-r--r--activemodel/lib/active_model/deprecated_mass_assignment_security.rb21
-rw-r--r--activemodel/lib/active_model/errors.rb6
-rw-r--r--activemodel/lib/active_model/secure_password.rb2
-rw-r--r--activemodel/lib/active_model/validations/clusivity.rb7
-rw-r--r--activemodel/lib/active_model/validations/inclusion.rb2
-rw-r--r--activemodel/test/cases/attribute_methods_test.rb11
-rw-r--r--activemodel/test/cases/deprecated_mass_assignment_security_test.rb16
-rw-r--r--activemodel/test/cases/validations/inclusion_validation_test.rb1
-rw-r--r--activerecord/CHANGELOG.md78
-rw-r--r--activerecord/Rakefile4
-rw-r--r--activerecord/activerecord.gemspec1
-rw-r--r--activerecord/examples/performance.rb32
-rw-r--r--activerecord/examples/simple.rb8
-rw-r--r--activerecord/lib/active_record.rb1
-rw-r--r--activerecord/lib/active_record/associations/association.rb6
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb2
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb1
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb2
-rw-r--r--activerecord/lib/active_record/associations/preloader/association.rb3
-rw-r--r--activerecord/lib/active_record/associations/through_association.rb2
-rw-r--r--activerecord/lib/active_record/attribute_assignment.rb1
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb4
-rw-r--r--activerecord/lib/active_record/core.rb4
-rw-r--r--activerecord/lib/active_record/querying.rb17
-rw-r--r--activerecord/lib/active_record/railtie.rb21
-rw-r--r--activerecord/lib/active_record/relation.rb50
-rw-r--r--activerecord/lib/active_record/relation/batches.rb15
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb12
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb11
-rw-r--r--activerecord/lib/active_record/relation/merger.rb4
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb4
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb1
-rw-r--r--activerecord/lib/active_record/result.rb6
-rw-r--r--activerecord/lib/active_record/scoping/named.rb16
-rw-r--r--activerecord/lib/active_record/tasks/database_tasks.rb4
-rw-r--r--activerecord/lib/active_record/tasks/firebird_database_tasks.rb56
-rw-r--r--activerecord/lib/active_record/tasks/oracle_database_tasks.rb45
-rw-r--r--activerecord/lib/active_record/tasks/sqlserver_database_tasks.rb48
-rw-r--r--activerecord/lib/active_record/transactions.rb10
-rw-r--r--activerecord/test/cases/associations/eager_test.rb4
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb37
-rw-r--r--activerecord/test/cases/associations/inner_join_association_test.rb8
-rw-r--r--activerecord/test/cases/associations/inverse_associations_test.rb14
-rw-r--r--activerecord/test/cases/batches_test.rb18
-rw-r--r--activerecord/test/cases/counter_cache_test.rb17
-rw-r--r--activerecord/test/cases/deprecated_dynamic_methods_test.rb592
-rw-r--r--activerecord/test/cases/disconnected_test.rb3
-rw-r--r--activerecord/test/cases/finder_respond_to_test.rb40
-rw-r--r--activerecord/test/cases/invalid_connection_test.rb22
-rw-r--r--activerecord/test/cases/relation_test.rb9
-rw-r--r--activerecord/test/cases/relations_test.rb2
-rw-r--r--activerecord/test/cases/result_test.rb32
-rw-r--r--activerecord/test/cases/scoping/default_scoping_test.rb5
-rw-r--r--activerecord/test/cases/tasks/firebird_rake_test.rb100
-rw-r--r--activerecord/test/cases/tasks/oracle_rake_test.rb93
-rw-r--r--activerecord/test/cases/tasks/sqlserver_rake_test.rb87
-rw-r--r--activesupport/CHANGELOG.md7
-rw-r--r--activesupport/Rakefile4
-rw-r--r--activesupport/lib/active_support/backtrace_cleaner.rb6
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/module/delegation.rb6
-rw-r--r--activesupport/lib/active_support/deprecation.rb6
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb2
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb1
-rw-r--r--activesupport/test/clean_backtrace_test.rb21
-rw-r--r--activesupport/test/core_ext/module_test.rb2
-rwxr-xr-xci/travis.rb3
-rw-r--r--guides/assets/stylesheets/main.css2
-rw-r--r--guides/bug_report_templates/active_record_gem.rb2
-rw-r--r--guides/code/getting_started/app/views/posts/_form.html.erb6
-rw-r--r--guides/code/getting_started/config/environments/development.rb2
-rw-r--r--guides/source/4_0_release_notes.md6
-rw-r--r--guides/source/_welcome.html.erb5
-rw-r--r--guides/source/action_controller_overview.md2
-rw-r--r--guides/source/action_view_overview.md19
-rw-r--r--guides/source/active_record_querying.md2
-rw-r--r--guides/source/active_record_validations.md4
-rw-r--r--guides/source/active_support_instrumentation.md8
-rw-r--r--guides/source/association_basics.md18
-rw-r--r--guides/source/command_line.md23
-rw-r--r--guides/source/contributing_to_ruby_on_rails.md4
-rw-r--r--guides/source/debugging_rails_applications.md6
-rw-r--r--guides/source/form_helpers.md2
-rw-r--r--guides/source/getting_started.md22
-rw-r--r--guides/source/i18n.md8
-rw-r--r--guides/source/kindle/toc.html.erb2
-rw-r--r--guides/source/layout.html.erb10
-rw-r--r--guides/source/layouts_and_rendering.md2
-rw-r--r--guides/source/migrations.md4
-rw-r--r--guides/source/routing.md12
-rw-r--r--guides/source/upgrading_ruby_on_rails.md2
-rw-r--r--guides/source/working_with_javascript_in_rails.md4
-rw-r--r--rails.gemspec1
-rw-r--r--railties/CHANGELOG.md9
-rw-r--r--railties/Rakefile2
-rw-r--r--railties/lib/rails/commands.rb2
-rw-r--r--railties/lib/rails/commands/dbconsole.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/routes.rb2
-rw-r--r--railties/lib/rails/generators/rails/controller/USAGE1
-rw-r--r--railties/lib/rails/test_unit/testing.rake80
-rw-r--r--railties/test/application/assets_test.rb23
-rw-r--r--railties/test/application/rake_test.rb39
-rw-r--r--railties/test/railties/engine_test.rb2
455 files changed, 1705 insertions, 1627 deletions
diff --git a/.travis.yml b/.travis.yml
index 5214b989af..012e795caa 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,7 @@ rvm:
- 2.0.0
env:
- "GEM=railties"
- - "GEM=ap,am,amo,as"
+ - "GEM=ap,am,amo,as,av"
- "GEM=ar:mysql"
- "GEM=ar:mysql2"
- "GEM=ar:sqlite3"
diff --git a/Rakefile b/Rakefile
index d26e1d3a85..9645788307 100644
--- a/Rakefile
+++ b/Rakefile
@@ -8,7 +8,7 @@ require 'railties/lib/rails/api/task'
desc "Build gem files for all projects"
task :build => "all:build"
-desc "Release all gems to gemcutter and create a tag"
+desc "Release all gems to rubygems and create a tag"
task :release => "all:release"
PROJECTS = %w(activesupport activemodel actionpack actionmailer activerecord railties)
diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile
index d1134ba2b5..5d5539df1d 100644
--- a/actionmailer/Rakefile
+++ b/actionmailer/Rakefile
@@ -16,7 +16,7 @@ namespace :test do
task :isolated do
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
Dir.glob("test/**/*_test.rb").all? do |file|
- sh(ruby, '-Ilib:test', file)
+ sh(ruby, '-w', '-Ilib:test', file)
end or raise "Failures"
end
end
@@ -27,7 +27,7 @@ Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end
-desc "Release to gemcutter"
+desc "Release to rubygems"
task release: :package do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index b1c5987fe4..05495179c3 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,38 +1,26 @@
-* Use a case insensitive URI Regexp for #asset_path.
+* Fix `Mime::Type.parse` when bad accepts header is looked up. Previously it
+ was setting `request.formats` with an array containing a `nil` value, which
+ raised an error when setting the controller formats.
- This fix a problem where the same asset path using different case are generating
- different URIs.
+ Fixes #10965
- Before:
+ *Becker*
- image_tag("HTTP://google.com")
- # => "<img alt=\"Google\" src=\"/assets/HTTP://google.com\" />"
- image_tag("http://google.com")
- # => "<img alt=\"Google\" src=\"http://google.com\" />"
+* Merge `:action` from routing scope and assign endpoint if both `:controller`
+ and `:action` are present. The endpoint assignment only occurs if there is
+ no `:to` present in the options hash so should only affect routes using the
+ shorthand syntax (i.e. endpoint is inferred from the path).
- After:
+ Fixes #9856
- image_tag("HTTP://google.com")
- # => "<img alt=\"Google\" src=\"HTTP://google.com\" />"
- image_tag("http://google.com")
- # => "<img alt=\"Google\" src=\"http://google.com\" />"
+ *Yves Senn*, *Andrew White*
- *David Celis*
+* ActionView extracted from ActionPack
-* Element of the `collection_check_boxes` and `collection_radio_buttons` can
- optionally contain html attributes as the last element of the array.
+ *Piotr Sarnacki*, *Łukasz Strzałkowski*
- *Vasiliy Ermolovich*
+* Fix removing trailing slash for mounted apps #3215
-* Update the HTML `BOOLEAN_ATTRIBUTES` in `ActionView::Helpers::TagHelper`
- to conform to the latest HTML 5.1 spec. Add attributes `allowfullscreen`,
- `default`, `inert`, `sortable`, `truespeed`, `typemustmatch`. Fix attribute
- `seamless` (previously misspelled `seemless`).
-
- *Alex Peattie*
-
-* Fix an issue where partials with a number in the filename weren't being digested for cache dependencies.
-
- *Bryan Ricker*
+ *Piotr Sarnacki*
Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/actionpack/CHANGELOG.md) for previous changes.
diff --git a/actionpack/Rakefile b/actionpack/Rakefile
index 56fc92963a..114d3a7c0c 100644
--- a/actionpack/Rakefile
+++ b/actionpack/Rakefile
@@ -5,16 +5,12 @@ desc "Default Task"
task :default => :test
# Run the unit tests
-
-desc "Run all unit tests"
-task :test => [:test_action_pack, :test_active_record_integration]
-
-Rake::TestTask.new(:test_action_pack) do |t|
+Rake::TestTask.new do |t|
t.libs << 'test'
# make sure we include the tests in alphabetical order as on some systems
# this will not happen automatically and the tests (as a whole) will error
- t.test_files = Dir.glob('test/{abstract,controller,dispatch,template,assertions,journey}/**/*_test.rb').sort
+ t.test_files = Dir.glob('test/{abstract,controller,dispatch,assertions,journey}/**/*_test.rb').sort
t.warning = true
t.verbose = true
@@ -23,32 +19,19 @@ end
namespace :test do
task :isolated do
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
- Dir.glob("test/{abstract,controller,dispatch,template}/**/*_test.rb").all? do |file|
- sh(ruby, '-Ilib:test', file)
+ Dir.glob("test/{abstract,controller,dispatch}/**/*_test.rb").all? do |file|
+ sh(ruby, '-w', '-Ilib:test', file)
end or raise "Failures"
end
end
-namespace :test do
- Rake::TestTask.new(:template) do |t|
- t.libs << 'test'
- t.pattern = 'test/template/**/*.rb'
- end
-end
-
-desc 'ActiveRecord Integration Tests'
-Rake::TestTask.new(:test_active_record_integration) do |t|
- t.libs << 'test'
- t.test_files = Dir.glob("test/activerecord/*_test.rb")
-end
-
spec = eval(File.read('actionpack.gemspec'))
Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end
-desc "Release to gemcutter"
+desc "Release to rubygems"
task :release => :package do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec
index cc8351a489..e3aa84ba0f 100644
--- a/actionpack/actionpack.gemspec
+++ b/actionpack/actionpack.gemspec
@@ -20,10 +20,10 @@ Gem::Specification.new do |s|
s.requirements << 'none'
s.add_dependency 'activesupport', version
- s.add_dependency 'builder', '~> 3.1.0'
+ s.add_dependency 'actionview', version
+
s.add_dependency 'rack', '~> 1.5.2'
s.add_dependency 'rack-test', '~> 0.6.2'
- s.add_dependency 'erubis', '~> 2.7.0'
s.add_development_dependency 'activemodel', version
s.add_development_dependency 'tzinfo', '~> 0.3.37'
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 0cbbbbe1fd..5ed3d2ebc1 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -524,7 +524,6 @@ module ActionController
def process(action, http_method = 'GET', *args)
check_required_ivars
- http_method, args = handle_old_process_api(http_method, args, caller)
if args.first.is_a?(String) && http_method != 'HEAD'
@request.env['RAW_POST_DATA'] = args.shift
@@ -628,17 +627,6 @@ module ActionController
end
end
- def handle_old_process_api(http_method, args, callstack)
- # 4.0: Remove this method.
- if http_method.is_a?(Hash)
- ActiveSupport::Deprecation.warn("TestCase#process now expects the HTTP method as second argument: process(action, http_method, params, session, flash)", callstack)
- args.unshift(http_method)
- http_method = args.last.is_a?(String) ? args.last : "GET"
- end
-
- [http_method, args]
- end
-
def build_request_uri(action, parameters)
unless @request.env["PATH_INFO"]
options = @controller.respond_to?(:url_options) ? @controller.__send__(:url_options).merge(parameters) : parameters
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index 61dbf2b96c..ef144c3c76 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -175,7 +175,7 @@ module Mime
def parse(accept_header)
if accept_header !~ /,/
accept_header = accept_header.split(PARAMETER_SEPARATOR_REGEXP).first
- parse_trailing_star(accept_header) || [Mime::Type.lookup(accept_header)]
+ parse_trailing_star(accept_header) || [Mime::Type.lookup(accept_header)].compact
else
list, index = AcceptList.new, 0
accept_header.split(',').each do |header|
diff --git a/actionpack/lib/action_dispatch/journey/router.rb b/actionpack/lib/action_dispatch/journey/router.rb
index 419e665d12..da32f1bfe7 100644
--- a/actionpack/lib/action_dispatch/journey/router.rb
+++ b/actionpack/lib/action_dispatch/journey/router.rb
@@ -54,7 +54,7 @@ module ActionDispatch
end
def call(env)
- env['PATH_INFO'] = Utils.normalize_path(env['PATH_INFO'])
+ env['PATH_INFO'] = normalize_path(env['PATH_INFO'])
find_routes(env).each do |match, parameters, route|
script_name, path_info, set_params = env.values_at('SCRIPT_NAME',
@@ -103,6 +103,12 @@ module ActionDispatch
private
+ def normalize_path(path)
+ path = "/#{path}"
+ path.squeeze!('/')
+ path
+ end
+
def partitioned_routes
routes.partitioned_routes
end
diff --git a/actionpack/lib/action_dispatch/middleware/ssl.rb b/actionpack/lib/action_dispatch/middleware/ssl.rb
index 9e03cbf2b7..8d5ab19f60 100644
--- a/actionpack/lib/action_dispatch/middleware/ssl.rb
+++ b/actionpack/lib/action_dispatch/middleware/ssl.rb
@@ -36,8 +36,7 @@ module ActionDispatch
url.scheme = "https"
url.host = @host if @host
url.port = @port if @port
- headers = hsts_headers.merge('Content-Type' => 'text/html',
- 'Location' => url.to_s)
+ headers = { 'Content-Type' => 'text/html', 'Location' => url.to_s }
[301, headers, []]
end
@@ -58,7 +57,7 @@ module ActionDispatch
cookies = cookies.split("\n")
headers['Set-Cookie'] = cookies.map { |cookie|
- if cookie !~ /;\s+secure(;|$)/
+ if cookie !~ /;\s+secure(;|$)/i
"#{cookie}; secure"
else
cookie
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 3c58a2cfc3..288ce3e867 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -11,8 +11,8 @@ module ActionDispatch
class Mapper
URL_OPTIONS = [:protocol, :subdomain, :domain, :host, :port]
SCOPE_OPTIONS = [:path, :shallow_path, :as, :shallow_prefix, :module,
- :controller, :path_names, :constraints, :defaults,
- :shallow, :blocks, :options]
+ :controller, :action, :path_names, :constraints,
+ :shallow, :blocks, :defaults, :options]
class Constraints #:nodoc:
def self.new(app, constraints, request = Rack::Request)
@@ -874,6 +874,10 @@ module ActionDispatch
child
end
+ def merge_action_scope(parent, child) #:nodoc:
+ child
+ end
+
def merge_path_names_scope(parent, child) #:nodoc:
merge_options_scope(parent, child)
end
@@ -1383,6 +1387,10 @@ module ActionDispatch
raise ArgumentError, "Unknown scope #{on.inspect} given to :on"
end
+ if @scope[:controller] && @scope[:action]
+ options[:to] ||= "#{@scope[:controller]}##{@scope[:action]}"
+ end
+
paths.each do |_path|
route_options = options.dup
route_options[:path] ||= _path if _path.is_a?(String)
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index ca86837a2c..e521c6ce96 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -1,6 +1,5 @@
require 'fileutils'
require 'abstract_unit'
-require 'active_record_unit'
CACHE_DIR = 'test_cache'
# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 72411ec900..fd835795c0 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -1089,6 +1089,12 @@ class RenderTest < ActionController::TestCase
assert_equal '<test>passed formatted html erb</test>', @response.body
end
+ def test_should_render_formatted_html_erb_template_with_bad_accepts_header
+ @request.env["HTTP_ACCEPT"] = "; a=dsf"
+ get :formatted_xml_erb
+ assert_equal '<test>passed formatted html erb</test>', @response.body
+ end
+
def test_should_render_formatted_html_erb_template_with_faulty_accepts_header
@request.accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appliction/x-shockwave-flash, */*"
get :formatted_xml_erb
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb
index 7c27458f46..f75c604277 100644
--- a/actionpack/test/controller/test_case_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -280,13 +280,6 @@ XML
assert_equal "/test_case_test/test/test_uri/7", @response.body
end
- def test_process_with_old_api
- assert_deprecated do
- process :test_uri, :id => 7
- assert_equal "/test_case_test/test/test_uri/7", @response.body
- end
- end
-
def test_process_with_request_uri_with_params_with_explicit_uri
@request.env['PATH_INFO'] = "/explicit/uri"
process :test_uri, "GET", :id => 7
diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb
index e5e28c28be..30e95a0b75 100644
--- a/actionpack/test/dispatch/mount_test.rb
+++ b/actionpack/test/dispatch/mount_test.rb
@@ -33,6 +33,11 @@ class TestRoutingMount < ActionDispatch::IntegrationTest
Router
end
+ def test_trailing_slash_is_not_removed_from_path_info
+ get "/sprockets/omg/"
+ assert_equal "/sprockets -- /omg/", response.body
+ end
+
def test_mounting_sets_script_name
get "/sprockets/omg"
assert_equal "/sprockets -- /omg", response.body
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 16ba746b9c..8e4339aa0c 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -1253,6 +1253,19 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal 'api/v3/products#list', @response.body
end
+ def test_controller_option_with_nesting_and_leading_slash
+ draw do
+ scope '/job', controller: 'job' do
+ scope ':id', action: 'manage_applicant' do
+ get "/active"
+ end
+ end
+ end
+
+ get '/job/5/active'
+ assert_equal 'job#manage_applicant', @response.body
+ end
+
def test_dynamically_generated_helpers_on_collection_do_not_clobber_resources_url_helper
draw do
resources :replies do
diff --git a/actionpack/test/dispatch/ssl_test.rb b/actionpack/test/dispatch/ssl_test.rb
index a9bea7ea73..61b55f3d82 100644
--- a/actionpack/test/dispatch/ssl_test.rb
+++ b/actionpack/test/dispatch/ssl_test.rb
@@ -37,6 +37,11 @@ class SSLTest < ActionDispatch::IntegrationTest
response.headers['Strict-Transport-Security']
end
+ def test_no_hsts_with_insecure_connection
+ get "http://example.org/"
+ assert_not response.headers['Strict-Transport-Security']
+ end
+
def test_hsts_header
self.app = ActionDispatch::SSL.new(default_app, :hsts => true)
get "https://example.org/"
@@ -119,6 +124,20 @@ class SSLTest < ActionDispatch::IntegrationTest
response.headers['Set-Cookie'].split("\n")
end
+ def test_flag_cookies_as_secure_with_ignore_case
+ self.app = ActionDispatch::SSL.new(lambda { |env|
+ headers = {
+ 'Content-Type' => "text/html",
+ 'Set-Cookie' => "problem=def; path=/; Secure; HttpOnly"
+ }
+ [200, headers, ["OK"]]
+ })
+
+ get "https://example.org/"
+ assert_equal ["problem=def; path=/; Secure; HttpOnly"],
+ response.headers['Set-Cookie'].split("\n")
+ end
+
def test_no_cookies
self.app = ActionDispatch::SSL.new(lambda { |env|
[200, {'Content-Type' => "text/html"}, ["OK"]]
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md
new file mode 100644
index 0000000000..543367a216
--- /dev/null
+++ b/actionview/CHANGELOG.md
@@ -0,0 +1,61 @@
+* Remove the deprecated `prompt` argument from `grouped_options_for_select`,
+ pass in a `:prompt` hash option to use this feature.
+
+ *kennyj*
+
+* Always escape the result of `link_to_unless` method.
+
+ Before:
+
+ link_to_unless(true, '<b>Showing</b>', 'github.com')
+ # => "<b>Showing</b>"
+
+ After:
+
+ link_to_unless(true, '<b>Showing</b>', 'github.com')
+ # => "&lt;b&gt;Showing&lt;/b&gt;"
+
+ *dtaniwaki*
+
+* Use a case insensitive URI Regexp for #asset_path.
+
+ This fix a problem where the same asset path using different case are generating
+ different URIs.
+
+ Before:
+
+ image_tag("HTTP://google.com")
+ # => "<img alt=\"Google\" src=\"/assets/HTTP://google.com\" />"
+ image_tag("http://google.com")
+ # => "<img alt=\"Google\" src=\"http://google.com\" />"
+
+ After:
+
+ image_tag("HTTP://google.com")
+ # => "<img alt=\"Google\" src=\"HTTP://google.com\" />"
+ image_tag("http://google.com")
+ # => "<img alt=\"Google\" src=\"http://google.com\" />"
+
+ *David Celis*
+
+* Element of the `collection_check_boxes` and `collection_radio_buttons` can
+ optionally contain html attributes as the last element of the array.
+
+ *Vasiliy Ermolovich*
+
+* Update the HTML `BOOLEAN_ATTRIBUTES` in `ActionView::Helpers::TagHelper`
+ to conform to the latest HTML 5.1 spec. Add attributes `allowfullscreen`,
+ `default`, `inert`, `sortable`, `truespeed`, `typemustmatch`. Fix attribute
+ `seamless` (previously misspelled `seemless`).
+
+ *Alex Peattie*
+
+* Fix an issue where partials with a number in the filename weren't being digested for cache dependencies.
+
+ *Bryan Ricker*
+
+* First release, ActionView extracted from ActionPack
+
+ *Piotr Sarnacki*, *Łukasz Strzałkowski*
+
+Please check [4-0-stable (ActionPack's CHANGELOG)](https://github.com/rails/rails/blob/4-0-stable/actionpack/CHANGELOG.md) for previous changes.
diff --git a/actionview/MIT-LICENSE b/actionview/MIT-LICENSE
new file mode 100644
index 0000000000..5c668d9624
--- /dev/null
+++ b/actionview/MIT-LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2004-2013 David Heinemeier Hansson
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/actionview/README.rdoc b/actionview/README.rdoc
new file mode 100644
index 0000000000..09bbfdae0b
--- /dev/null
+++ b/actionview/README.rdoc
@@ -0,0 +1,31 @@
+= Action View
+
+
+
+== Download and installation
+
+The latest version of Action View can be installed with RubyGems:
+
+ % [sudo] gem install actionview
+
+Source code can be downloaded as part of the Rails project on GitHub
+
+* https://github.com/rails/rails/tree/master/actionview
+
+
+== License
+
+Action View is released under the MIT license:
+
+* http://www.opensource.org/licenses/MIT
+
+
+== Support
+
+API documentation is at
+
+* http://api.rubyonrails.org
+
+Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
+
+* https://github.com/rails/rails/issues
diff --git a/actionview/RUNNING_UNIT_TESTS b/actionview/RUNNING_UNIT_TESTS
new file mode 100644
index 0000000000..a0c35e1810
--- /dev/null
+++ b/actionview/RUNNING_UNIT_TESTS
@@ -0,0 +1,27 @@
+== Running with Rake
+
+The easiest way to run the unit tests is through Rake. The default task runs
+the entire test suite for all classes. For more information, checkout the
+full array of rake tasks with "rake -T"
+
+Rake can be found at http://rake.rubyforge.org
+
+== Running by hand
+
+To run a single test suite
+
+ rake test TEST=path/to/test.rb
+
+which can be further narrowed down to one test:
+
+ rake test TEST=path/to/test.rb TESTOPTS="--name=test_something"
+
+== Dependency on Active Record and database setup
+
+Test cases in the test/active_record/ directory depend on having
+activerecord and sqlite installed. If Active Record is not in
+actionview/../activerecord directory, or the sqlite rubygem is not installed,
+these tests are skipped.
+
+Other tests are runnable from a fresh copy of actionview without any configuration.
+
diff --git a/actionview/Rakefile b/actionview/Rakefile
new file mode 100644
index 0000000000..1cbd35cda4
--- /dev/null
+++ b/actionview/Rakefile
@@ -0,0 +1,77 @@
+require 'rake/testtask'
+require 'rake/packagetask'
+require 'rubygems/package_task'
+
+desc "Default Task"
+task :default => :test
+
+# Run the unit tests
+
+desc "Run all unit tests"
+task :test => [:test_action_view, :test_active_record_integration]
+
+Rake::TestTask.new(:test_action_view) do |t|
+ t.libs << 'test'
+ t.test_files = Dir.glob('test/template/**/*_test.rb').sort
+ t.warning = true
+ t.verbose = true
+end
+
+namespace :test do
+ task :isolated do
+ ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
+ Dir.glob("test/{active_record,template}/**/*_test.rb").all? do |file|
+ sh(ruby, '-w', '-Ilib:test', file)
+ end or raise "Failures"
+ end
+
+ Rake::TestTask.new(:template) do |t|
+ t.libs << 'test'
+ t.pattern = 'test/template/**/*.rb'
+ end
+end
+
+desc 'ActiveRecord Integration Tests'
+Rake::TestTask.new(:test_active_record_integration) do |t|
+ t.libs << 'test'
+ t.test_files = Dir.glob("test/activerecord/*_test.rb")
+ t.warning = true
+ t.verbose = true
+end
+
+spec = eval(File.read('actionview.gemspec'))
+
+Gem::PackageTask.new(spec) do |p|
+ p.gem_spec = spec
+end
+
+desc "Release to rubygems"
+task :release => :package do
+ require 'rake/gemcutter'
+ Rake::Gemcutter::Tasks.new(spec).define
+ Rake::Task['gem:push'].invoke
+end
+
+task :lines do
+ lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
+
+ FileList["lib/**/*.rb"].each do |file_name|
+ next if file_name =~ /vendor/
+ File.open(file_name, 'r') do |f|
+ while line = f.gets
+ lines += 1
+ next if line =~ /^\s*$/
+ next if line =~ /^\s*#/
+ codelines += 1
+ end
+ end
+ puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
+
+ total_lines += lines
+ total_codelines += codelines
+
+ lines, codelines = 0, 0
+ end
+
+ puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
+end
diff --git a/actionview/actionview.gemspec b/actionview/actionview.gemspec
new file mode 100644
index 0000000000..87cb568300
--- /dev/null
+++ b/actionview/actionview.gemspec
@@ -0,0 +1,29 @@
+version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip
+
+Gem::Specification.new do |s|
+ s.platform = Gem::Platform::RUBY
+ s.name = 'actionview'
+ s.version = version
+ s.summary = 'Rendering framework putting the V in MVC (part of Rails).'
+ s.description = ''
+
+ s.required_ruby_version = '>= 1.9.3'
+
+ s.license = 'MIT'
+
+ s.author = 'David Heinemeier Hansson'
+ s.email = 'david@loudthinking.com'
+ s.homepage = 'http://www.rubyonrails.org'
+
+ s.files = Dir['CHANGELOG.md', 'README.rdoc', 'MIT-LICENSE', 'lib/**/*']
+ s.require_path = 'lib'
+ s.requirements << 'none'
+
+ s.add_dependency 'activesupport', version
+ s.add_dependency 'activemodel', version
+
+ s.add_dependency 'builder', '~> 3.1.0'
+ s.add_dependency 'erubis', '~> 2.7.0'
+
+ s.add_development_dependency 'actionpack', version
+end
diff --git a/actionpack/lib/action_view.rb b/actionview/lib/action_view.rb
index 4aafbcb655..8def4ba7c5 100644
--- a/actionpack/lib/action_view.rb
+++ b/actionview/lib/action_view.rb
@@ -23,7 +23,6 @@
require 'active_support'
require 'active_support/rails'
-require 'action_pack'
module ActionView
extend ActiveSupport::Autoload
diff --git a/actionpack/lib/action_view/base.rb b/actionview/lib/action_view/base.rb
index 08253de3f4..08253de3f4 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionview/lib/action_view/base.rb
diff --git a/actionpack/lib/action_view/buffers.rb b/actionview/lib/action_view/buffers.rb
index 361a0dccbe..361a0dccbe 100644
--- a/actionpack/lib/action_view/buffers.rb
+++ b/actionview/lib/action_view/buffers.rb
diff --git a/actionpack/lib/action_view/context.rb b/actionview/lib/action_view/context.rb
index ee263df484..ee263df484 100644
--- a/actionpack/lib/action_view/context.rb
+++ b/actionview/lib/action_view/context.rb
diff --git a/actionpack/lib/action_view/dependency_tracker.rb b/actionview/lib/action_view/dependency_tracker.rb
index b2e8334077..b2e8334077 100644
--- a/actionpack/lib/action_view/dependency_tracker.rb
+++ b/actionview/lib/action_view/dependency_tracker.rb
diff --git a/actionpack/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb
index 9324a1ac50..9324a1ac50 100644
--- a/actionpack/lib/action_view/digestor.rb
+++ b/actionview/lib/action_view/digestor.rb
diff --git a/actionpack/lib/action_view/flows.rb b/actionview/lib/action_view/flows.rb
index c0e458cd41..ba24510e56 100644
--- a/actionpack/lib/action_view/flows.rb
+++ b/actionview/lib/action_view/flows.rb
@@ -36,7 +36,7 @@ module ActionView
@root = Fiber.current.object_id
end
- # Try to get an stored content. If the content
+ # Try to get stored content. If the content
# is not available and we are inside the layout
# fiber, we set that we are waiting for the given
# key and yield.
@@ -73,4 +73,4 @@ module ActionView
Fiber.current.object_id != @root
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_view/helpers.rb b/actionview/lib/action_view/helpers.rb
index 8a78685ae1..8a78685ae1 100644
--- a/actionpack/lib/action_view/helpers.rb
+++ b/actionview/lib/action_view/helpers.rb
diff --git a/actionpack/lib/action_view/helpers/active_model_helper.rb b/actionview/lib/action_view/helpers/active_model_helper.rb
index 901f433c70..901f433c70 100644
--- a/actionpack/lib/action_view/helpers/active_model_helper.rb
+++ b/actionview/lib/action_view/helpers/active_model_helper.rb
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb
index 2b3a3c6a29..2b3a3c6a29 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb
diff --git a/actionpack/lib/action_view/helpers/asset_url_helper.rb b/actionview/lib/action_view/helpers/asset_url_helper.rb
index 0b957adb91..0b957adb91 100644
--- a/actionpack/lib/action_view/helpers/asset_url_helper.rb
+++ b/actionview/lib/action_view/helpers/asset_url_helper.rb
diff --git a/actionpack/lib/action_view/helpers/atom_feed_helper.rb b/actionview/lib/action_view/helpers/atom_feed_helper.rb
index 42b1dd8933..42b1dd8933 100644
--- a/actionpack/lib/action_view/helpers/atom_feed_helper.rb
+++ b/actionview/lib/action_view/helpers/atom_feed_helper.rb
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb
index 8fc78ea7fb..2a38e5c446 100644
--- a/actionpack/lib/action_view/helpers/cache_helper.rb
+++ b/actionview/lib/action_view/helpers/cache_helper.rb
@@ -176,20 +176,24 @@ module ActionView
# TODO: Create an object that has caching read/write on it
def fragment_for(name = {}, options = nil, &block) #:nodoc:
- if fragment = controller.read_fragment(name, options)
- fragment
- else
- # VIEW TODO: Make #capture usable outside of ERB
- # This dance is needed because Builder can't use capture
- pos = output_buffer.length
- yield
- output_safe = output_buffer.html_safe?
- fragment = output_buffer.slice!(pos..-1)
- if output_safe
- self.output_buffer = output_buffer.class.new(output_buffer)
- end
- controller.write_fragment(name, fragment, options)
+ read_fragment_for(name, options) || write_fragment_for(name, options, &block)
+ end
+
+ def read_fragment_for(name, options) #:nodoc:
+ controller.read_fragment(name, options)
+ end
+
+ def write_fragment_for(name, options) #:nodoc:
+ # VIEW TODO: Make #capture usable outside of ERB
+ # This dance is needed because Builder can't use capture
+ pos = output_buffer.length
+ yield
+ output_safe = output_buffer.html_safe?
+ fragment = output_buffer.slice!(pos..-1)
+ if output_safe
+ self.output_buffer = output_buffer.class.new(output_buffer)
end
+ controller.write_fragment(name, fragment, options)
end
end
end
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionview/lib/action_view/helpers/capture_helper.rb
index 5afe435459..5afe435459 100644
--- a/actionpack/lib/action_view/helpers/capture_helper.rb
+++ b/actionview/lib/action_view/helpers/capture_helper.rb
diff --git a/actionpack/lib/action_view/helpers/controller_helper.rb b/actionview/lib/action_view/helpers/controller_helper.rb
index 74ef25f7c1..74ef25f7c1 100644
--- a/actionpack/lib/action_view/helpers/controller_helper.rb
+++ b/actionview/lib/action_view/helpers/controller_helper.rb
diff --git a/actionpack/lib/action_view/helpers/csrf_helper.rb b/actionview/lib/action_view/helpers/csrf_helper.rb
index eeb0ed94b9..eeb0ed94b9 100644
--- a/actionpack/lib/action_view/helpers/csrf_helper.rb
+++ b/actionview/lib/action_view/helpers/csrf_helper.rb
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb
index 8fb5eb1548..8fb5eb1548 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionview/lib/action_view/helpers/date_helper.rb
diff --git a/actionpack/lib/action_view/helpers/debug_helper.rb b/actionview/lib/action_view/helpers/debug_helper.rb
index c29c1b1eea..c29c1b1eea 100644
--- a/actionpack/lib/action_view/helpers/debug_helper.rb
+++ b/actionview/lib/action_view/helpers/debug_helper.rb
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb
index f64c0ca30b..f64c0ca30b 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionview/lib/action_view/helpers/form_helper.rb
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb
index ad26505086..4e9ef94ff3 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionview/lib/action_view/helpers/form_options_helper.rb
@@ -510,15 +510,8 @@ module ActionView
# <b>Note:</b> Only the <tt><optgroup></tt> and <tt><option></tt> tags are returned, so you still have to
# wrap the output in an appropriate <tt><select></tt> tag.
def grouped_options_for_select(grouped_options, selected_key = nil, options = {})
- if options.is_a?(Hash)
- prompt = options[:prompt]
- divider = options[:divider]
- else
- prompt = options
- message = "Passing the prompt to grouped_options_for_select as an argument is deprecated. " \
- "Please use an options hash like `{ prompt: #{prompt.inspect} }`."
- ActiveSupport::Deprecation.warn message
- end
+ prompt = options[:prompt]
+ divider = options[:divider]
body = "".html_safe
@@ -653,7 +646,7 @@ module ActionView
#
# Example object structure for use with this method:
# class Post < ActiveRecord::Base
- # has_and_belongs_to_many :author
+ # has_and_belongs_to_many :authors
# end
# class Author < ActiveRecord::Base
# has_and_belongs_to_many :posts
@@ -783,7 +776,7 @@ module ActionView
# Wraps ActionView::Helpers::FormOptionsHelper#grouped_collection_select for form builders:
#
# <%= form_for @city do |f| %>
- # <%= f.grouped_collection_select :country_id, :country_id, @continents, :countries, :name, :id, :name %>
+ # <%= f.grouped_collection_select :country_id, @continents, :countries, :name, :id, :name %>
# <%= f.submit %>
# <% end %>
#
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb
index 3fa7696b83..3fa7696b83 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/form_tag_helper.rb
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionview/lib/action_view/helpers/javascript_helper.rb
index e475d5b018..e475d5b018 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionview/lib/action_view/helpers/javascript_helper.rb
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionview/lib/action_view/helpers/number_helper.rb
index fda7038a5d..fda7038a5d 100644
--- a/actionpack/lib/action_view/helpers/number_helper.rb
+++ b/actionview/lib/action_view/helpers/number_helper.rb
diff --git a/actionpack/lib/action_view/helpers/output_safety_helper.rb b/actionview/lib/action_view/helpers/output_safety_helper.rb
index 60a4478c26..60a4478c26 100644
--- a/actionpack/lib/action_view/helpers/output_safety_helper.rb
+++ b/actionview/lib/action_view/helpers/output_safety_helper.rb
diff --git a/actionpack/lib/action_view/helpers/record_tag_helper.rb b/actionview/lib/action_view/helpers/record_tag_helper.rb
index f767957fa9..f767957fa9 100644
--- a/actionpack/lib/action_view/helpers/record_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/record_tag_helper.rb
diff --git a/actionpack/lib/action_view/helpers/rendering_helper.rb b/actionview/lib/action_view/helpers/rendering_helper.rb
index 458086de96..458086de96 100644
--- a/actionpack/lib/action_view/helpers/rendering_helper.rb
+++ b/actionview/lib/action_view/helpers/rendering_helper.rb
diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionview/lib/action_view/helpers/sanitize_helper.rb
index e5cb843670..e5cb843670 100644
--- a/actionpack/lib/action_view/helpers/sanitize_helper.rb
+++ b/actionview/lib/action_view/helpers/sanitize_helper.rb
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb
index 732f35643a..732f35643a 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionview/lib/action_view/helpers/tag_helper.rb
diff --git a/actionpack/lib/action_view/helpers/tags.rb b/actionview/lib/action_view/helpers/tags.rb
index a05e16979a..a05e16979a 100644
--- a/actionpack/lib/action_view/helpers/tags.rb
+++ b/actionview/lib/action_view/helpers/tags.rb
diff --git a/actionpack/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb
index 3fe3f4e9df..3fe3f4e9df 100644
--- a/actionpack/lib/action_view/helpers/tags/base.rb
+++ b/actionview/lib/action_view/helpers/tags/base.rb
diff --git a/actionpack/lib/action_view/helpers/tags/check_box.rb b/actionview/lib/action_view/helpers/tags/check_box.rb
index 6d51f2629a..6d51f2629a 100644
--- a/actionpack/lib/action_view/helpers/tags/check_box.rb
+++ b/actionview/lib/action_view/helpers/tags/check_box.rb
diff --git a/actionpack/lib/action_view/helpers/tags/checkable.rb b/actionview/lib/action_view/helpers/tags/checkable.rb
index 052e9df662..052e9df662 100644
--- a/actionpack/lib/action_view/helpers/tags/checkable.rb
+++ b/actionview/lib/action_view/helpers/tags/checkable.rb
diff --git a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
index 52006d856b..52006d856b 100644
--- a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb
diff --git a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb b/actionview/lib/action_view/helpers/tags/collection_helpers.rb
index 388dcf1f13..388dcf1f13 100644
--- a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_helpers.rb
diff --git a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb
index 20be34c1f2..20be34c1f2 100644
--- a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb
diff --git a/actionpack/lib/action_view/helpers/tags/collection_select.rb b/actionview/lib/action_view/helpers/tags/collection_select.rb
index 6cb2b2e0d3..6cb2b2e0d3 100644
--- a/actionpack/lib/action_view/helpers/tags/collection_select.rb
+++ b/actionview/lib/action_view/helpers/tags/collection_select.rb
diff --git a/actionpack/lib/action_view/helpers/tags/color_field.rb b/actionview/lib/action_view/helpers/tags/color_field.rb
index d8fc797035..d8fc797035 100644
--- a/actionpack/lib/action_view/helpers/tags/color_field.rb
+++ b/actionview/lib/action_view/helpers/tags/color_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/date_field.rb b/actionview/lib/action_view/helpers/tags/date_field.rb
index c22be0db29..c22be0db29 100644
--- a/actionpack/lib/action_view/helpers/tags/date_field.rb
+++ b/actionview/lib/action_view/helpers/tags/date_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/date_select.rb b/actionview/lib/action_view/helpers/tags/date_select.rb
index 0c4ac40070..0c4ac40070 100644
--- a/actionpack/lib/action_view/helpers/tags/date_select.rb
+++ b/actionview/lib/action_view/helpers/tags/date_select.rb
diff --git a/actionpack/lib/action_view/helpers/tags/datetime_field.rb b/actionview/lib/action_view/helpers/tags/datetime_field.rb
index 9a2279c611..9a2279c611 100644
--- a/actionpack/lib/action_view/helpers/tags/datetime_field.rb
+++ b/actionview/lib/action_view/helpers/tags/datetime_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/datetime_local_field.rb b/actionview/lib/action_view/helpers/tags/datetime_local_field.rb
index b4a74185d1..b4a74185d1 100644
--- a/actionpack/lib/action_view/helpers/tags/datetime_local_field.rb
+++ b/actionview/lib/action_view/helpers/tags/datetime_local_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/datetime_select.rb b/actionview/lib/action_view/helpers/tags/datetime_select.rb
index 563de1840e..563de1840e 100644
--- a/actionpack/lib/action_view/helpers/tags/datetime_select.rb
+++ b/actionview/lib/action_view/helpers/tags/datetime_select.rb
diff --git a/actionpack/lib/action_view/helpers/tags/email_field.rb b/actionview/lib/action_view/helpers/tags/email_field.rb
index 7ce3ccb9bf..7ce3ccb9bf 100644
--- a/actionpack/lib/action_view/helpers/tags/email_field.rb
+++ b/actionview/lib/action_view/helpers/tags/email_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/file_field.rb b/actionview/lib/action_view/helpers/tags/file_field.rb
index 476b820d84..476b820d84 100644
--- a/actionpack/lib/action_view/helpers/tags/file_field.rb
+++ b/actionview/lib/action_view/helpers/tags/file_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb b/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb
index 2ed4712dac..2ed4712dac 100644
--- a/actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb
+++ b/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb
diff --git a/actionpack/lib/action_view/helpers/tags/hidden_field.rb b/actionview/lib/action_view/helpers/tags/hidden_field.rb
index c3757c2461..c3757c2461 100644
--- a/actionpack/lib/action_view/helpers/tags/hidden_field.rb
+++ b/actionview/lib/action_view/helpers/tags/hidden_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/label.rb b/actionview/lib/action_view/helpers/tags/label.rb
index 35d3ba8434..35d3ba8434 100644
--- a/actionpack/lib/action_view/helpers/tags/label.rb
+++ b/actionview/lib/action_view/helpers/tags/label.rb
diff --git a/actionpack/lib/action_view/helpers/tags/month_field.rb b/actionview/lib/action_view/helpers/tags/month_field.rb
index 4c0fb846ee..4c0fb846ee 100644
--- a/actionpack/lib/action_view/helpers/tags/month_field.rb
+++ b/actionview/lib/action_view/helpers/tags/month_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/number_field.rb b/actionview/lib/action_view/helpers/tags/number_field.rb
index 4f95b1b4de..4f95b1b4de 100644
--- a/actionpack/lib/action_view/helpers/tags/number_field.rb
+++ b/actionview/lib/action_view/helpers/tags/number_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/password_field.rb b/actionview/lib/action_view/helpers/tags/password_field.rb
index 6099fa6f19..6099fa6f19 100644
--- a/actionpack/lib/action_view/helpers/tags/password_field.rb
+++ b/actionview/lib/action_view/helpers/tags/password_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/radio_button.rb b/actionview/lib/action_view/helpers/tags/radio_button.rb
index 4849c537a5..4849c537a5 100644
--- a/actionpack/lib/action_view/helpers/tags/radio_button.rb
+++ b/actionview/lib/action_view/helpers/tags/radio_button.rb
diff --git a/actionpack/lib/action_view/helpers/tags/range_field.rb b/actionview/lib/action_view/helpers/tags/range_field.rb
index f98ae88043..f98ae88043 100644
--- a/actionpack/lib/action_view/helpers/tags/range_field.rb
+++ b/actionview/lib/action_view/helpers/tags/range_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/search_field.rb b/actionview/lib/action_view/helpers/tags/search_field.rb
index c09e2f1be7..c09e2f1be7 100644
--- a/actionpack/lib/action_view/helpers/tags/search_field.rb
+++ b/actionview/lib/action_view/helpers/tags/search_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/select.rb b/actionview/lib/action_view/helpers/tags/select.rb
index d64e2f68ef..d64e2f68ef 100644
--- a/actionpack/lib/action_view/helpers/tags/select.rb
+++ b/actionview/lib/action_view/helpers/tags/select.rb
diff --git a/actionpack/lib/action_view/helpers/tags/tel_field.rb b/actionview/lib/action_view/helpers/tags/tel_field.rb
index 987bb9e67a..987bb9e67a 100644
--- a/actionpack/lib/action_view/helpers/tags/tel_field.rb
+++ b/actionview/lib/action_view/helpers/tags/tel_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/text_area.rb b/actionview/lib/action_view/helpers/tags/text_area.rb
index c81156c0c8..c81156c0c8 100644
--- a/actionpack/lib/action_view/helpers/tags/text_area.rb
+++ b/actionview/lib/action_view/helpers/tags/text_area.rb
diff --git a/actionpack/lib/action_view/helpers/tags/text_field.rb b/actionview/lib/action_view/helpers/tags/text_field.rb
index baa5ff768e..baa5ff768e 100644
--- a/actionpack/lib/action_view/helpers/tags/text_field.rb
+++ b/actionview/lib/action_view/helpers/tags/text_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/time_field.rb b/actionview/lib/action_view/helpers/tags/time_field.rb
index 0e90a3aed7..0e90a3aed7 100644
--- a/actionpack/lib/action_view/helpers/tags/time_field.rb
+++ b/actionview/lib/action_view/helpers/tags/time_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/time_select.rb b/actionview/lib/action_view/helpers/tags/time_select.rb
index 0b06311d25..0b06311d25 100644
--- a/actionpack/lib/action_view/helpers/tags/time_select.rb
+++ b/actionview/lib/action_view/helpers/tags/time_select.rb
diff --git a/actionpack/lib/action_view/helpers/tags/time_zone_select.rb b/actionview/lib/action_view/helpers/tags/time_zone_select.rb
index 80d165ec7e..80d165ec7e 100644
--- a/actionpack/lib/action_view/helpers/tags/time_zone_select.rb
+++ b/actionview/lib/action_view/helpers/tags/time_zone_select.rb
diff --git a/actionpack/lib/action_view/helpers/tags/url_field.rb b/actionview/lib/action_view/helpers/tags/url_field.rb
index d76340178d..d76340178d 100644
--- a/actionpack/lib/action_view/helpers/tags/url_field.rb
+++ b/actionview/lib/action_view/helpers/tags/url_field.rb
diff --git a/actionpack/lib/action_view/helpers/tags/week_field.rb b/actionview/lib/action_view/helpers/tags/week_field.rb
index 5b3d0494e9..5b3d0494e9 100644
--- a/actionpack/lib/action_view/helpers/tags/week_field.rb
+++ b/actionview/lib/action_view/helpers/tags/week_field.rb
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionview/lib/action_view/helpers/text_helper.rb
index 147f9fd8ed..147f9fd8ed 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionview/lib/action_view/helpers/text_helper.rb
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb
index ad8eb47f1f..ad8eb47f1f 100644
--- a/actionpack/lib/action_view/helpers/translation_helper.rb
+++ b/actionview/lib/action_view/helpers/translation_helper.rb
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb
index 19e5941971..19e5941971 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionview/lib/action_view/helpers/url_helper.rb
diff --git a/actionpack/lib/action_view/locale/en.yml b/actionview/lib/action_view/locale/en.yml
index 8a56f147b8..8a56f147b8 100644
--- a/actionpack/lib/action_view/locale/en.yml
+++ b/actionview/lib/action_view/locale/en.yml
diff --git a/actionpack/lib/action_view/log_subscriber.rb b/actionview/lib/action_view/log_subscriber.rb
index fd9a543e0a..fd9a543e0a 100644
--- a/actionpack/lib/action_view/log_subscriber.rb
+++ b/actionview/lib/action_view/log_subscriber.rb
diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb
index f9d5b97fe3..f9d5b97fe3 100644
--- a/actionpack/lib/action_view/lookup_context.rb
+++ b/actionview/lib/action_view/lookup_context.rb
diff --git a/actionpack/lib/action_view/model_naming.rb b/actionview/lib/action_view/model_naming.rb
index e09ebd60df..e09ebd60df 100644
--- a/actionpack/lib/action_view/model_naming.rb
+++ b/actionview/lib/action_view/model_naming.rb
diff --git a/actionpack/lib/action_view/path_set.rb b/actionview/lib/action_view/path_set.rb
index 91ee2ea8f5..91ee2ea8f5 100644
--- a/actionpack/lib/action_view/path_set.rb
+++ b/actionview/lib/action_view/path_set.rb
diff --git a/actionpack/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb
index e80e0ed9b0..e80e0ed9b0 100644
--- a/actionpack/lib/action_view/railtie.rb
+++ b/actionview/lib/action_view/railtie.rb
diff --git a/actionpack/lib/action_view/record_identifier.rb b/actionview/lib/action_view/record_identifier.rb
index 63f645431a..63f645431a 100644
--- a/actionpack/lib/action_view/record_identifier.rb
+++ b/actionview/lib/action_view/record_identifier.rb
diff --git a/actionpack/lib/action_view/renderer/abstract_renderer.rb b/actionview/lib/action_view/renderer/abstract_renderer.rb
index 73c19a0ae2..73c19a0ae2 100644
--- a/actionpack/lib/action_view/renderer/abstract_renderer.rb
+++ b/actionview/lib/action_view/renderer/abstract_renderer.rb
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb
index 821026268a..821026268a 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionview/lib/action_view/renderer/partial_renderer.rb
diff --git a/actionpack/lib/action_view/renderer/renderer.rb b/actionview/lib/action_view/renderer/renderer.rb
index 964b18337e..964b18337e 100644
--- a/actionpack/lib/action_view/renderer/renderer.rb
+++ b/actionview/lib/action_view/renderer/renderer.rb
diff --git a/actionpack/lib/action_view/renderer/streaming_template_renderer.rb b/actionview/lib/action_view/renderer/streaming_template_renderer.rb
index 9cf6eb0c65..9cf6eb0c65 100644
--- a/actionpack/lib/action_view/renderer/streaming_template_renderer.rb
+++ b/actionview/lib/action_view/renderer/streaming_template_renderer.rb
diff --git a/actionpack/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb
index 4d5c5db80c..4d5c5db80c 100644
--- a/actionpack/lib/action_view/renderer/template_renderer.rb
+++ b/actionview/lib/action_view/renderer/template_renderer.rb
diff --git a/actionpack/lib/action_view/routing_url_for.rb b/actionview/lib/action_view/routing_url_for.rb
index f10e7e88ba..f10e7e88ba 100644
--- a/actionpack/lib/action_view/routing_url_for.rb
+++ b/actionview/lib/action_view/routing_url_for.rb
diff --git a/actionpack/lib/action_view/template.rb b/actionview/lib/action_view/template.rb
index e2c50fec47..e2c50fec47 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionview/lib/action_view/template.rb
diff --git a/actionpack/lib/action_view/template/error.rb b/actionview/lib/action_view/template/error.rb
index a89d51221e..a89d51221e 100644
--- a/actionpack/lib/action_view/template/error.rb
+++ b/actionview/lib/action_view/template/error.rb
diff --git a/actionpack/lib/action_view/template/handlers.rb b/actionview/lib/action_view/template/handlers.rb
index d9cddc0040..d9cddc0040 100644
--- a/actionpack/lib/action_view/template/handlers.rb
+++ b/actionview/lib/action_view/template/handlers.rb
diff --git a/actionpack/lib/action_view/template/handlers/builder.rb b/actionview/lib/action_view/template/handlers/builder.rb
index d90b0c6378..d90b0c6378 100644
--- a/actionpack/lib/action_view/template/handlers/builder.rb
+++ b/actionview/lib/action_view/template/handlers/builder.rb
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb
index 7d7a7af51d..c8a0059596 100644
--- a/actionpack/lib/action_view/template/handlers/erb.rb
+++ b/actionview/lib/action_view/template/handlers/erb.rb
@@ -1,4 +1,3 @@
-require 'action_dispatch/http/mime_type'
require 'erubis'
module ActionView
diff --git a/actionpack/lib/action_view/template/handlers/raw.rb b/actionview/lib/action_view/template/handlers/raw.rb
index 0c0d1fffcb..0c0d1fffcb 100644
--- a/actionpack/lib/action_view/template/handlers/raw.rb
+++ b/actionview/lib/action_view/template/handlers/raw.rb
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb
index 3304605c1a..3304605c1a 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionview/lib/action_view/template/resolver.rb
diff --git a/actionpack/lib/action_view/template/text.rb b/actionview/lib/action_view/template/text.rb
index 859c7bc3ce..859c7bc3ce 100644
--- a/actionpack/lib/action_view/template/text.rb
+++ b/actionview/lib/action_view/template/text.rb
diff --git a/actionpack/lib/action_view/template/types.rb b/actionview/lib/action_view/template/types.rb
index db77cb5d19..db77cb5d19 100644
--- a/actionpack/lib/action_view/template/types.rb
+++ b/actionview/lib/action_view/template/types.rb
diff --git a/actionpack/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb
index 3145446114..3145446114 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionview/lib/action_view/test_case.rb
diff --git a/actionpack/lib/action_view/testing/resolvers.rb b/actionview/lib/action_view/testing/resolvers.rb
index 7afa2fa613..7afa2fa613 100644
--- a/actionpack/lib/action_view/testing/resolvers.rb
+++ b/actionview/lib/action_view/testing/resolvers.rb
diff --git a/actionpack/lib/action_view/vendor/html-scanner.rb b/actionview/lib/action_view/vendor/html-scanner.rb
index 775b827529..775b827529 100644
--- a/actionpack/lib/action_view/vendor/html-scanner.rb
+++ b/actionview/lib/action_view/vendor/html-scanner.rb
diff --git a/actionpack/lib/action_view/vendor/html-scanner/html/document.rb b/actionview/lib/action_view/vendor/html-scanner/html/document.rb
index 386820300a..386820300a 100644
--- a/actionpack/lib/action_view/vendor/html-scanner/html/document.rb
+++ b/actionview/lib/action_view/vendor/html-scanner/html/document.rb
diff --git a/actionpack/lib/action_view/vendor/html-scanner/html/node.rb b/actionview/lib/action_view/vendor/html-scanner/html/node.rb
index 7e7cd4f7b6..7e7cd4f7b6 100644
--- a/actionpack/lib/action_view/vendor/html-scanner/html/node.rb
+++ b/actionview/lib/action_view/vendor/html-scanner/html/node.rb
diff --git a/actionpack/lib/action_view/vendor/html-scanner/html/sanitizer.rb b/actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb
index 30b6b8b141..30b6b8b141 100644
--- a/actionpack/lib/action_view/vendor/html-scanner/html/sanitizer.rb
+++ b/actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb
diff --git a/actionpack/lib/action_view/vendor/html-scanner/html/selector.rb b/actionview/lib/action_view/vendor/html-scanner/html/selector.rb
index 7f8609c408..7f8609c408 100644
--- a/actionpack/lib/action_view/vendor/html-scanner/html/selector.rb
+++ b/actionview/lib/action_view/vendor/html-scanner/html/selector.rb
diff --git a/actionpack/lib/action_view/vendor/html-scanner/html/tokenizer.rb b/actionview/lib/action_view/vendor/html-scanner/html/tokenizer.rb
index 8ac8d34430..8ac8d34430 100644
--- a/actionpack/lib/action_view/vendor/html-scanner/html/tokenizer.rb
+++ b/actionview/lib/action_view/vendor/html-scanner/html/tokenizer.rb
diff --git a/actionpack/lib/action_view/vendor/html-scanner/html/version.rb b/actionview/lib/action_view/vendor/html-scanner/html/version.rb
index 6d645c3e14..6d645c3e14 100644
--- a/actionpack/lib/action_view/vendor/html-scanner/html/version.rb
+++ b/actionview/lib/action_view/vendor/html-scanner/html/version.rb
diff --git a/actionview/lib/action_view/version.rb b/actionview/lib/action_view/version.rb
new file mode 100644
index 0000000000..094dd474df
--- /dev/null
+++ b/actionview/lib/action_view/version.rb
@@ -0,0 +1,11 @@
+module ActionView
+ # Returns the version of the currently loaded ActionView as a Gem::Version
+ def self.version
+ Gem::Version.new "4.1.0.beta"
+ end
+
+ module VERSION #:nodoc:
+ MAJOR, MINOR, TINY, PRE = ActionView.version.segments
+ STRING = ActionView.version.to_s
+ end
+end
diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb
new file mode 100644
index 0000000000..8213997f4e
--- /dev/null
+++ b/actionview/test/abstract_unit.rb
@@ -0,0 +1,382 @@
+require File.expand_path('../../../load_paths', __FILE__)
+
+$:.unshift(File.dirname(__FILE__) + '/lib')
+$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
+$:.unshift(File.dirname(__FILE__) + '/fixtures/alternate_helpers')
+
+ENV['TMPDIR'] = File.join(File.dirname(__FILE__), 'tmp')
+
+require 'active_support/core_ext/kernel/reporting'
+
+# These are the normal settings that will be set up by Railties
+# TODO: Have these tests support other combinations of these values
+silence_warnings do
+ Encoding.default_internal = "UTF-8"
+ Encoding.default_external = "UTF-8"
+end
+
+require 'active_support/testing/autorun'
+require 'abstract_controller'
+require 'action_controller'
+require 'action_view'
+require 'action_view/testing/resolvers'
+require 'action_dispatch'
+require 'active_support/dependencies'
+require 'active_model'
+require 'active_record'
+require 'action_controller/caching'
+
+require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late
+
+module Rails
+ class << self
+ def env
+ @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "test")
+ end
+ end
+end
+
+ActiveSupport::Dependencies.hook!
+
+Thread.abort_on_exception = true
+
+# Show backtraces for deprecated behavior for quicker cleanup.
+ActiveSupport::Deprecation.debug = true
+
+# Register danish language for testing
+I18n.backend.store_translations 'da', {}
+I18n.backend.store_translations 'pt-BR', {}
+ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort
+
+FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
+FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
+
+module RackTestUtils
+ def body_to_string(body)
+ if body.respond_to?(:each)
+ str = ""
+ body.each {|s| str << s }
+ str
+ else
+ body
+ end
+ end
+ extend self
+end
+
+module RenderERBUtils
+ def view
+ @view ||= begin
+ path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH)
+ view_paths = ActionView::PathSet.new([path])
+ ActionView::Base.new(view_paths)
+ end
+ end
+
+ def render_erb(string)
+ @virtual_path = nil
+
+ template = ActionView::Template.new(
+ string.strip,
+ "test template",
+ ActionView::Template::Handlers::ERB,
+ {})
+
+ template.render(self, {}).strip
+ end
+end
+
+SharedTestRoutes = ActionDispatch::Routing::RouteSet.new
+
+module ActionDispatch
+ module SharedRoutes
+ def before_setup
+ @routes = SharedTestRoutes
+ super
+ end
+ end
+
+ # Hold off drawing routes until all the possible controller classes
+ # have been loaded.
+ module DrawOnce
+ class << self
+ attr_accessor :drew
+ end
+ self.drew = false
+
+ def before_setup
+ super
+ return if DrawOnce.drew
+
+ SharedTestRoutes.draw do
+ get ':controller(/:action)'
+ end
+
+ ActionDispatch::IntegrationTest.app.routes.draw do
+ get ':controller(/:action)'
+ end
+
+ DrawOnce.drew = true
+ end
+ end
+end
+
+module ActiveSupport
+ class TestCase
+ include ActionDispatch::DrawOnce
+ end
+end
+
+class RoutedRackApp
+ attr_reader :routes
+
+ def initialize(routes, &blk)
+ @routes = routes
+ @stack = ActionDispatch::MiddlewareStack.new(&blk).build(@routes)
+ end
+
+ def call(env)
+ @stack.call(env)
+ end
+end
+
+class BasicController
+ attr_accessor :request
+
+ def config
+ @config ||= ActiveSupport::InheritableOptions.new(ActionController::Base.config).tap do |config|
+ # VIEW TODO: View tests should not require a controller
+ public_dir = File.expand_path("../fixtures/public", __FILE__)
+ config.assets_dir = public_dir
+ config.javascripts_dir = "#{public_dir}/javascripts"
+ config.stylesheets_dir = "#{public_dir}/stylesheets"
+ config.assets = ActiveSupport::InheritableOptions.new({ :prefix => "assets" })
+ config
+ end
+ end
+end
+
+class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
+ include ActionDispatch::SharedRoutes
+
+ def self.build_app(routes = nil)
+ RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
+ middleware.use "ActionDispatch::ShowExceptions", ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public")
+ middleware.use "ActionDispatch::DebugExceptions"
+ middleware.use "ActionDispatch::Callbacks"
+ middleware.use "ActionDispatch::ParamsParser"
+ middleware.use "ActionDispatch::Cookies"
+ middleware.use "ActionDispatch::Flash"
+ middleware.use "Rack::Head"
+ yield(middleware) if block_given?
+ end
+ end
+
+ self.app = build_app
+
+ # Stub Rails dispatcher so it does not get controller references and
+ # simply return the controller#action as Rack::Body.
+ class StubDispatcher < ::ActionDispatch::Routing::RouteSet::Dispatcher
+ protected
+ def controller_reference(controller_param)
+ controller_param
+ end
+
+ def dispatch(controller, action, env)
+ [200, {'Content-Type' => 'text/html'}, ["#{controller}##{action}"]]
+ end
+ end
+
+ def self.stub_controllers
+ old_dispatcher = ActionDispatch::Routing::RouteSet::Dispatcher
+ ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
+ ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, StubDispatcher }
+ yield ActionDispatch::Routing::RouteSet.new
+ ensure
+ ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
+ ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, old_dispatcher }
+ end
+
+ def with_routing(&block)
+ temporary_routes = ActionDispatch::Routing::RouteSet.new
+ old_app, self.class.app = self.class.app, self.class.build_app(temporary_routes)
+ old_routes = SharedTestRoutes
+ silence_warnings { Object.const_set(:SharedTestRoutes, temporary_routes) }
+
+ yield temporary_routes
+ ensure
+ self.class.app = old_app
+ silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) }
+ end
+
+ def with_autoload_path(path)
+ path = File.join(File.dirname(__FILE__), "fixtures", path)
+ if ActiveSupport::Dependencies.autoload_paths.include?(path)
+ yield
+ else
+ begin
+ ActiveSupport::Dependencies.autoload_paths << path
+ yield
+ ensure
+ ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
+ ActiveSupport::Dependencies.clear
+ end
+ end
+ end
+end
+
+# Temporary base class
+class Rack::TestCase < ActionDispatch::IntegrationTest
+ def self.testing(klass = nil)
+ if klass
+ @testing = "/#{klass.name.underscore}".sub!(/_controller$/, '')
+ else
+ @testing
+ end
+ end
+
+ def get(thing, *args)
+ if thing.is_a?(Symbol)
+ super("#{self.class.testing}/#{thing}", *args)
+ else
+ super
+ end
+ end
+
+ def assert_body(body)
+ assert_equal body, Array(response.body).join
+ end
+
+ def assert_status(code)
+ assert_equal code, response.status
+ end
+
+ def assert_response(body, status = 200, headers = {})
+ assert_body body
+ assert_status status
+ headers.each do |header, value|
+ assert_header header, value
+ end
+ end
+
+ def assert_content_type(type)
+ assert_equal type, response.headers["Content-Type"]
+ end
+
+ def assert_header(name, value)
+ assert_equal value, response.headers[name]
+ end
+end
+
+module ActionController
+ class Base
+ include ActionController::Testing
+ # This stub emulates the Railtie including the URL helpers from a Rails application
+ include SharedTestRoutes.url_helpers
+ include SharedTestRoutes.mounted_helpers
+
+ self.view_paths = FIXTURE_LOAD_PATH
+
+ def self.test_routes(&block)
+ routes = ActionDispatch::Routing::RouteSet.new
+ routes.draw(&block)
+ include routes.url_helpers
+ end
+ end
+
+ class TestCase
+ include ActionDispatch::TestProcess
+ include ActionDispatch::SharedRoutes
+ end
+end
+
+class ::ApplicationController < ActionController::Base
+end
+
+module ActionView
+ class TestCase
+ # Must repeat the setup because AV::TestCase is a duplication
+ # of AC::TestCase
+ include ActionDispatch::SharedRoutes
+ end
+end
+
+class Workshop
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+ attr_accessor :id
+
+ def initialize(id)
+ @id = id
+ end
+
+ def persisted?
+ id.present?
+ end
+
+ def to_s
+ id.to_s
+ end
+end
+
+module ActionDispatch
+ class DebugExceptions
+ private
+ remove_method :stderr_logger
+ # Silence logger
+ def stderr_logger
+ nil
+ end
+ end
+end
+
+module ActionDispatch
+ module RoutingVerbs
+ def get(uri_or_host, path = nil)
+ host = uri_or_host.host unless path
+ path ||= uri_or_host.path
+
+ params = {'PATH_INFO' => path,
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_HOST' => host}
+
+ routes.call(params)[2].join
+ end
+ end
+end
+
+module RoutingTestHelpers
+ def url_for(set, options, recall = nil)
+ set.send(:url_for, options.merge(:only_path => true, :_recall => recall))
+ end
+end
+
+class ResourcesController < ActionController::Base
+ def index() render :nothing => true end
+ alias_method :show, :index
+end
+
+class ThreadsController < ResourcesController; end
+class MessagesController < ResourcesController; end
+class CommentsController < ResourcesController; end
+class ReviewsController < ResourcesController; end
+class AuthorsController < ResourcesController; end
+class LogosController < ResourcesController; end
+
+class AccountsController < ResourcesController; end
+class AdminController < ResourcesController; end
+class ProductsController < ResourcesController; end
+class ImagesController < ResourcesController; end
+class PreferencesController < ResourcesController; end
+
+module Backoffice
+ class ProductsController < ResourcesController; end
+ class TagsController < ResourcesController; end
+ class ManufacturersController < ResourcesController; end
+ class ImagesController < ResourcesController; end
+
+ module Admin
+ class ProductsController < ResourcesController; end
+ class ImagesController < ResourcesController; end
+ end
+end
diff --git a/actionview/test/active_record_unit.rb b/actionview/test/active_record_unit.rb
new file mode 100644
index 0000000000..95fbb112c0
--- /dev/null
+++ b/actionview/test/active_record_unit.rb
@@ -0,0 +1,91 @@
+require 'abstract_unit'
+
+# Define the essentials
+class ActiveRecordTestConnector
+ cattr_accessor :able_to_connect
+ cattr_accessor :connected
+
+ # Set our defaults
+ self.connected = false
+ self.able_to_connect = true
+end
+
+# Try to grab AR
+unless defined?(ActiveRecord) && defined?(FixtureSet)
+ begin
+ PATH_TO_AR = "#{File.dirname(__FILE__)}/../../activerecord/lib"
+ raise LoadError, "#{PATH_TO_AR} doesn't exist" unless File.directory?(PATH_TO_AR)
+ $LOAD_PATH.unshift PATH_TO_AR
+ require 'active_record'
+ rescue LoadError => e
+ $stderr.print "Failed to load Active Record. Skipping Active Record assertion tests: #{e}"
+ ActiveRecordTestConnector.able_to_connect = false
+ end
+end
+$stderr.flush
+
+
+# Define the rest of the connector
+class ActiveRecordTestConnector
+ class << self
+ def setup
+ unless self.connected || !self.able_to_connect
+ setup_connection
+ load_schema
+ require_fixture_models
+ self.connected = true
+ end
+ rescue Exception => e # errors from ActiveRecord setup
+ $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}"
+ #$stderr.puts " #{e.backtrace.join("\n ")}\n"
+ self.able_to_connect = false
+ end
+
+ private
+ def setup_connection
+ if Object.const_defined?(:ActiveRecord)
+ defaults = { :database => ':memory:' }
+ adapter = defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'
+ options = defaults.merge :adapter => adapter, :timeout => 500
+ ActiveRecord::Base.establish_connection(options)
+ ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options }
+ ActiveRecord::Base.connection
+
+ Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE)
+ else
+ raise "Can't setup connection since ActiveRecord isn't loaded."
+ end
+ end
+
+ # Load actionpack sqlite tables
+ def load_schema
+ File.read(File.dirname(__FILE__) + "/fixtures/db_definitions/sqlite.sql").split(';').each do |sql|
+ ActiveRecord::Base.connection.execute(sql) unless sql.blank?
+ end
+ end
+
+ def require_fixture_models
+ Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f}
+ end
+ end
+end
+
+class ActiveRecordTestCase < ActionController::TestCase
+ include ActiveRecord::TestFixtures
+
+ # Set our fixture path
+ if ActiveRecordTestConnector.able_to_connect
+ self.fixture_path = [FIXTURE_LOAD_PATH]
+ self.use_transactional_fixtures = false
+ end
+
+ def self.fixtures(*args)
+ super if ActiveRecordTestConnector.connected
+ end
+
+ def run(*args)
+ super if ActiveRecordTestConnector.connected
+ end
+end
+
+ActiveRecordTestConnector.setup
diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionview/test/activerecord/controller_runtime_test.rb
index 368bec1c70..368bec1c70 100644
--- a/actionpack/test/activerecord/controller_runtime_test.rb
+++ b/actionview/test/activerecord/controller_runtime_test.rb
diff --git a/actionpack/test/activerecord/form_helper_activerecord_test.rb b/actionview/test/activerecord/form_helper_activerecord_test.rb
index 2e302c65a7..2e302c65a7 100644
--- a/actionpack/test/activerecord/form_helper_activerecord_test.rb
+++ b/actionview/test/activerecord/form_helper_activerecord_test.rb
diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb
index afb714484b..afb714484b 100644
--- a/actionpack/test/activerecord/polymorphic_routes_test.rb
+++ b/actionview/test/activerecord/polymorphic_routes_test.rb
diff --git a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb b/actionview/test/activerecord/render_partial_with_record_identification_test.rb
index 409370104d..409370104d 100644
--- a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
+++ b/actionview/test/activerecord/render_partial_with_record_identification_test.rb
diff --git a/actionpack/test/fixtures/_top_level_partial.html.erb b/actionview/test/fixtures/_top_level_partial.html.erb
index 0b1c2e46e0..0b1c2e46e0 100644
--- a/actionpack/test/fixtures/_top_level_partial.html.erb
+++ b/actionview/test/fixtures/_top_level_partial.html.erb
diff --git a/actionview/test/fixtures/_top_level_partial_only.erb b/actionview/test/fixtures/_top_level_partial_only.erb
new file mode 100644
index 0000000000..44f25b61d0
--- /dev/null
+++ b/actionview/test/fixtures/_top_level_partial_only.erb
@@ -0,0 +1 @@
+top level partial \ No newline at end of file
diff --git a/actionpack/test/fixtures/blog_public/.gitignore b/actionview/test/fixtures/blog_public/.gitignore
index 312e635ee6..312e635ee6 100644
--- a/actionpack/test/fixtures/blog_public/.gitignore
+++ b/actionview/test/fixtures/blog_public/.gitignore
diff --git a/actionpack/test/fixtures/blog_public/blog.html b/actionview/test/fixtures/blog_public/blog.html
index 79ad44c010..79ad44c010 100644
--- a/actionpack/test/fixtures/blog_public/blog.html
+++ b/actionview/test/fixtures/blog_public/blog.html
diff --git a/actionpack/test/fixtures/blog_public/index.html b/actionview/test/fixtures/blog_public/index.html
index 2de3825481..2de3825481 100644
--- a/actionpack/test/fixtures/blog_public/index.html
+++ b/actionview/test/fixtures/blog_public/index.html
diff --git a/actionpack/test/fixtures/blog_public/subdir/index.html b/actionview/test/fixtures/blog_public/subdir/index.html
index 517bded335..517bded335 100644
--- a/actionpack/test/fixtures/blog_public/subdir/index.html
+++ b/actionview/test/fixtures/blog_public/subdir/index.html
diff --git a/actionpack/test/fixtures/comments/empty.de.html.erb b/actionview/test/fixtures/comments/empty.de.html.erb
index cffd90dd26..cffd90dd26 100644
--- a/actionpack/test/fixtures/comments/empty.de.html.erb
+++ b/actionview/test/fixtures/comments/empty.de.html.erb
diff --git a/actionpack/test/fixtures/comments/empty.html.builder b/actionview/test/fixtures/comments/empty.html.builder
index 2b0c7207a3..2b0c7207a3 100644
--- a/actionpack/test/fixtures/comments/empty.html.builder
+++ b/actionview/test/fixtures/comments/empty.html.builder
diff --git a/actionpack/test/fixtures/comments/empty.html.erb b/actionview/test/fixtures/comments/empty.html.erb
index 827f3861de..827f3861de 100644
--- a/actionpack/test/fixtures/comments/empty.html.erb
+++ b/actionview/test/fixtures/comments/empty.html.erb
diff --git a/actionpack/test/fixtures/comments/empty.xml.erb b/actionview/test/fixtures/comments/empty.xml.erb
index db1027cd7d..db1027cd7d 100644
--- a/actionpack/test/fixtures/comments/empty.xml.erb
+++ b/actionview/test/fixtures/comments/empty.xml.erb
diff --git a/actionpack/test/fixtures/companies.yml b/actionview/test/fixtures/companies.yml
index ed2992e0b1..ed2992e0b1 100644
--- a/actionpack/test/fixtures/companies.yml
+++ b/actionview/test/fixtures/companies.yml
diff --git a/actionview/test/fixtures/company.rb b/actionview/test/fixtures/company.rb
new file mode 100644
index 0000000000..f3ac3642fa
--- /dev/null
+++ b/actionview/test/fixtures/company.rb
@@ -0,0 +1,9 @@
+class Company < ActiveRecord::Base
+ has_one :mascot
+ self.sequence_name = :companies_nonstd_seq
+
+ validates_presence_of :name
+ def validate
+ errors.add('rating', 'rating should not be 2') if rating == 2
+ end
+end
diff --git a/actionpack/test/fixtures/custom_pattern/another.html.erb b/actionview/test/fixtures/custom_pattern/another.html.erb
index 6d7f3bafbb..6d7f3bafbb 100644
--- a/actionpack/test/fixtures/custom_pattern/another.html.erb
+++ b/actionview/test/fixtures/custom_pattern/another.html.erb
diff --git a/actionpack/test/fixtures/custom_pattern/html/another.erb b/actionview/test/fixtures/custom_pattern/html/another.erb
index dbd7e96ab6..dbd7e96ab6 100644
--- a/actionpack/test/fixtures/custom_pattern/html/another.erb
+++ b/actionview/test/fixtures/custom_pattern/html/another.erb
diff --git a/actionpack/test/fixtures/custom_pattern/html/path.erb b/actionview/test/fixtures/custom_pattern/html/path.erb
index 6d7f3bafbb..6d7f3bafbb 100644
--- a/actionpack/test/fixtures/custom_pattern/html/path.erb
+++ b/actionview/test/fixtures/custom_pattern/html/path.erb
diff --git a/actionview/test/fixtures/customers/_customer.html.erb b/actionview/test/fixtures/customers/_customer.html.erb
new file mode 100644
index 0000000000..483571e22a
--- /dev/null
+++ b/actionview/test/fixtures/customers/_customer.html.erb
@@ -0,0 +1 @@
+<%= greeting %>: <%= customer.name %> \ No newline at end of file
diff --git a/actionpack/test/fixtures/db_definitions/sqlite.sql b/actionview/test/fixtures/db_definitions/sqlite.sql
index 99df4b3e61..99df4b3e61 100644
--- a/actionpack/test/fixtures/db_definitions/sqlite.sql
+++ b/actionview/test/fixtures/db_definitions/sqlite.sql
diff --git a/actionpack/test/fixtures/developer.rb b/actionview/test/fixtures/developer.rb
index 4941463015..4941463015 100644
--- a/actionpack/test/fixtures/developer.rb
+++ b/actionview/test/fixtures/developer.rb
diff --git a/actionpack/test/fixtures/developers.yml b/actionview/test/fixtures/developers.yml
index 3656564f63..3656564f63 100644
--- a/actionpack/test/fixtures/developers.yml
+++ b/actionview/test/fixtures/developers.yml
diff --git a/actionpack/test/fixtures/developers/_developer.erb b/actionview/test/fixtures/developers/_developer.erb
index 904a3137e7..904a3137e7 100644
--- a/actionpack/test/fixtures/developers/_developer.erb
+++ b/actionview/test/fixtures/developers/_developer.erb
diff --git a/actionpack/test/fixtures/developers_projects.yml b/actionview/test/fixtures/developers_projects.yml
index cee359c7cf..cee359c7cf 100644
--- a/actionpack/test/fixtures/developers_projects.yml
+++ b/actionview/test/fixtures/developers_projects.yml
diff --git a/actionpack/test/fixtures/digestor/comments/_comment.html.erb b/actionview/test/fixtures/digestor/comments/_comment.html.erb
index f172e749da..f172e749da 100644
--- a/actionpack/test/fixtures/digestor/comments/_comment.html.erb
+++ b/actionview/test/fixtures/digestor/comments/_comment.html.erb
diff --git a/actionpack/test/fixtures/digestor/comments/_comments.html.erb b/actionview/test/fixtures/digestor/comments/_comments.html.erb
index c28646a283..c28646a283 100644
--- a/actionpack/test/fixtures/digestor/comments/_comments.html.erb
+++ b/actionview/test/fixtures/digestor/comments/_comments.html.erb
diff --git a/actionpack/test/fixtures/digestor/events/_event.html.erb b/actionview/test/fixtures/digestor/events/_event.html.erb
index e69de29bb2..e69de29bb2 100644
--- a/actionpack/test/fixtures/digestor/events/_event.html.erb
+++ b/actionview/test/fixtures/digestor/events/_event.html.erb
diff --git a/actionpack/test/fixtures/digestor/level/below/_header.html.erb b/actionview/test/fixtures/digestor/level/below/_header.html.erb
index e69de29bb2..e69de29bb2 100644
--- a/actionpack/test/fixtures/digestor/level/below/_header.html.erb
+++ b/actionview/test/fixtures/digestor/level/below/_header.html.erb
diff --git a/actionpack/test/fixtures/digestor/level/below/index.html.erb b/actionview/test/fixtures/digestor/level/below/index.html.erb
index b92f49a8f8..b92f49a8f8 100644
--- a/actionpack/test/fixtures/digestor/level/below/index.html.erb
+++ b/actionview/test/fixtures/digestor/level/below/index.html.erb
diff --git a/actionpack/test/fixtures/digestor/messages/_form.html.erb b/actionview/test/fixtures/digestor/messages/_form.html.erb
index e69de29bb2..e69de29bb2 100644
--- a/actionpack/test/fixtures/digestor/messages/_form.html.erb
+++ b/actionview/test/fixtures/digestor/messages/_form.html.erb
diff --git a/actionpack/test/fixtures/digestor/messages/_header.html.erb b/actionview/test/fixtures/digestor/messages/_header.html.erb
index e69de29bb2..e69de29bb2 100644
--- a/actionpack/test/fixtures/digestor/messages/_header.html.erb
+++ b/actionview/test/fixtures/digestor/messages/_header.html.erb
diff --git a/actionpack/test/fixtures/digestor/messages/_message.html.erb b/actionview/test/fixtures/digestor/messages/_message.html.erb
index 406a0fb848..406a0fb848 100644
--- a/actionpack/test/fixtures/digestor/messages/_message.html.erb
+++ b/actionview/test/fixtures/digestor/messages/_message.html.erb
diff --git a/actionpack/test/fixtures/digestor/messages/actions/_move.html.erb b/actionview/test/fixtures/digestor/messages/actions/_move.html.erb
index e69de29bb2..e69de29bb2 100644
--- a/actionpack/test/fixtures/digestor/messages/actions/_move.html.erb
+++ b/actionview/test/fixtures/digestor/messages/actions/_move.html.erb
diff --git a/actionpack/test/fixtures/digestor/messages/edit.html.erb b/actionview/test/fixtures/digestor/messages/edit.html.erb
index a9e0a88e32..a9e0a88e32 100644
--- a/actionpack/test/fixtures/digestor/messages/edit.html.erb
+++ b/actionview/test/fixtures/digestor/messages/edit.html.erb
diff --git a/actionpack/test/fixtures/digestor/messages/index.html.erb b/actionview/test/fixtures/digestor/messages/index.html.erb
index 1937b652e4..1937b652e4 100644
--- a/actionpack/test/fixtures/digestor/messages/index.html.erb
+++ b/actionview/test/fixtures/digestor/messages/index.html.erb
diff --git a/actionpack/test/fixtures/digestor/messages/show.html.erb b/actionview/test/fixtures/digestor/messages/show.html.erb
index 130e67109e..42aa2363dd 100644
--- a/actionpack/test/fixtures/digestor/messages/show.html.erb
+++ b/actionview/test/fixtures/digestor/messages/show.html.erb
@@ -6,9 +6,9 @@
<%= render @message.history.events %>
-<%# render "something_missing" %>
-<%# render "something_missing_1" %>
+<%# render "something_missing" %>
+<%# render "something_missing_1" %>
<%
# Template Dependency: messages/form
-%>
+%> \ No newline at end of file
diff --git a/actionpack/test/fixtures/fun/games/_game.erb b/actionview/test/fixtures/fun/games/_game.erb
index f0f542ff92..f0f542ff92 100644
--- a/actionpack/test/fixtures/fun/games/_game.erb
+++ b/actionview/test/fixtures/fun/games/_game.erb
diff --git a/actionview/test/fixtures/fun/games/hello_world.erb b/actionview/test/fixtures/fun/games/hello_world.erb
new file mode 100644
index 0000000000..1ebfbe2539
--- /dev/null
+++ b/actionview/test/fixtures/fun/games/hello_world.erb
@@ -0,0 +1 @@
+Living in a nested world \ No newline at end of file
diff --git a/actionpack/test/fixtures/fun/serious/games/_game.erb b/actionview/test/fixtures/fun/serious/games/_game.erb
index 523bc55bd7..523bc55bd7 100644
--- a/actionpack/test/fixtures/fun/serious/games/_game.erb
+++ b/actionview/test/fixtures/fun/serious/games/_game.erb
diff --git a/actionview/test/fixtures/functional_caching/fragment_cached_without_digest.html.erb b/actionview/test/fixtures/functional_caching/fragment_cached_without_digest.html.erb
new file mode 100644
index 0000000000..3125583a28
--- /dev/null
+++ b/actionview/test/fixtures/functional_caching/fragment_cached_without_digest.html.erb
@@ -0,0 +1,3 @@
+<body>
+<%= cache 'nodigest', skip_digest: true do %><p>ERB</p><% end %>
+</body>
diff --git a/actionpack/test/fixtures/games/_game.erb b/actionview/test/fixtures/games/_game.erb
index 1aeb81fcba..1aeb81fcba 100644
--- a/actionpack/test/fixtures/games/_game.erb
+++ b/actionview/test/fixtures/games/_game.erb
diff --git a/actionview/test/fixtures/good_customers/_good_customer.html.erb b/actionview/test/fixtures/good_customers/_good_customer.html.erb
new file mode 100644
index 0000000000..a2d97ebc6d
--- /dev/null
+++ b/actionview/test/fixtures/good_customers/_good_customer.html.erb
@@ -0,0 +1 @@
+<%= greeting %> good customer: <%= good_customer.name %><%= good_customer_counter %> \ No newline at end of file
diff --git a/actionpack/test/fixtures/happy_path/render_action/hello_world.erb b/actionview/test/fixtures/happy_path/render_action/hello_world.erb
index 6769dd60bd..6769dd60bd 100644
--- a/actionpack/test/fixtures/happy_path/render_action/hello_world.erb
+++ b/actionview/test/fixtures/happy_path/render_action/hello_world.erb
diff --git a/actionpack/test/fixtures/layout_tests/alt/hello.erb b/actionview/test/fixtures/layout_tests/alt/hello.erb
index 1055c36659..1055c36659 100644
--- a/actionpack/test/fixtures/layout_tests/alt/hello.erb
+++ b/actionview/test/fixtures/layout_tests/alt/hello.erb
diff --git a/actionpack/test/fixtures/layouts/_column.html.erb b/actionview/test/fixtures/layouts/_column.html.erb
index 96db002b8a..96db002b8a 100644
--- a/actionpack/test/fixtures/layouts/_column.html.erb
+++ b/actionview/test/fixtures/layouts/_column.html.erb
diff --git a/actionview/test/fixtures/layouts/_customers.erb b/actionview/test/fixtures/layouts/_customers.erb
new file mode 100644
index 0000000000..ae63f13cd3
--- /dev/null
+++ b/actionview/test/fixtures/layouts/_customers.erb
@@ -0,0 +1 @@
+<title><%= yield Struct.new(:name).new("David") %></title> \ No newline at end of file
diff --git a/actionpack/test/fixtures/layouts/_partial_and_yield.erb b/actionview/test/fixtures/layouts/_partial_and_yield.erb
index 74cc428ffa..74cc428ffa 100644
--- a/actionpack/test/fixtures/layouts/_partial_and_yield.erb
+++ b/actionview/test/fixtures/layouts/_partial_and_yield.erb
diff --git a/actionpack/test/fixtures/layouts/_yield_only.erb b/actionview/test/fixtures/layouts/_yield_only.erb
index 37f0bddbd7..37f0bddbd7 100644
--- a/actionpack/test/fixtures/layouts/_yield_only.erb
+++ b/actionview/test/fixtures/layouts/_yield_only.erb
diff --git a/actionpack/test/fixtures/layouts/_yield_with_params.erb b/actionview/test/fixtures/layouts/_yield_with_params.erb
index 68e6557fb8..68e6557fb8 100644
--- a/actionpack/test/fixtures/layouts/_yield_with_params.erb
+++ b/actionview/test/fixtures/layouts/_yield_with_params.erb
diff --git a/actionpack/test/fixtures/layouts/streaming.erb b/actionview/test/fixtures/layouts/streaming.erb
index d3f896a6ca..d3f896a6ca 100644
--- a/actionpack/test/fixtures/layouts/streaming.erb
+++ b/actionview/test/fixtures/layouts/streaming.erb
diff --git a/actionview/test/fixtures/layouts/yield.erb b/actionview/test/fixtures/layouts/yield.erb
new file mode 100644
index 0000000000..482dc9022e
--- /dev/null
+++ b/actionview/test/fixtures/layouts/yield.erb
@@ -0,0 +1,2 @@
+<title><%= yield :title %></title>
+<%= yield %>
diff --git a/actionpack/test/fixtures/layouts/yield_with_render_inline_inside.erb b/actionview/test/fixtures/layouts/yield_with_render_inline_inside.erb
index 7298d79690..7298d79690 100644
--- a/actionpack/test/fixtures/layouts/yield_with_render_inline_inside.erb
+++ b/actionview/test/fixtures/layouts/yield_with_render_inline_inside.erb
diff --git a/actionpack/test/fixtures/layouts/yield_with_render_partial_inside.erb b/actionview/test/fixtures/layouts/yield_with_render_partial_inside.erb
index 74cc428ffa..74cc428ffa 100644
--- a/actionpack/test/fixtures/layouts/yield_with_render_partial_inside.erb
+++ b/actionview/test/fixtures/layouts/yield_with_render_partial_inside.erb
diff --git a/actionpack/test/fixtures/mascot.rb b/actionview/test/fixtures/mascot.rb
index f9f1448b8f..f9f1448b8f 100644
--- a/actionpack/test/fixtures/mascot.rb
+++ b/actionview/test/fixtures/mascot.rb
diff --git a/actionpack/test/fixtures/mascots.yml b/actionview/test/fixtures/mascots.yml
index 17b7dff454..17b7dff454 100644
--- a/actionpack/test/fixtures/mascots.yml
+++ b/actionview/test/fixtures/mascots.yml
diff --git a/actionpack/test/fixtures/mascots/_mascot.html.erb b/actionview/test/fixtures/mascots/_mascot.html.erb
index 432773a1da..432773a1da 100644
--- a/actionpack/test/fixtures/mascots/_mascot.html.erb
+++ b/actionview/test/fixtures/mascots/_mascot.html.erb
diff --git a/actionview/test/fixtures/multipart/bracketed_utf8_param b/actionview/test/fixtures/multipart/bracketed_utf8_param
new file mode 100644
index 0000000000..df9cecea08
--- /dev/null
+++ b/actionview/test/fixtures/multipart/bracketed_utf8_param
@@ -0,0 +1,5 @@
+--AaB03x
+Content-Disposition: form-data; name="Iñtërnâtiônàlizætiøn_name[Iñtërnâtiônàlizætiøn_nested_name]"
+
+Iñtërnâtiônàlizætiøn_value
+--AaB03x--
diff --git a/actionview/test/fixtures/multipart/single_utf8_param b/actionview/test/fixtures/multipart/single_utf8_param
new file mode 100644
index 0000000000..1d9fae7b17
--- /dev/null
+++ b/actionview/test/fixtures/multipart/single_utf8_param
@@ -0,0 +1,5 @@
+--AaB03x
+Content-Disposition: form-data; name="Iñtërnâtiônàlizætiøn_name"
+
+Iñtërnâtiônàlizætiøn_value
+--AaB03x--
diff --git a/actionpack/test/fixtures/plain_text.raw b/actionview/test/fixtures/plain_text.raw
index b13985337f..b13985337f 100644
--- a/actionpack/test/fixtures/plain_text.raw
+++ b/actionview/test/fixtures/plain_text.raw
diff --git a/actionpack/test/fixtures/plain_text_with_characters.raw b/actionview/test/fixtures/plain_text_with_characters.raw
index 1e86e44fb4..1e86e44fb4 100644
--- a/actionpack/test/fixtures/plain_text_with_characters.raw
+++ b/actionview/test/fixtures/plain_text_with_characters.raw
diff --git a/actionpack/test/fixtures/project.rb b/actionview/test/fixtures/project.rb
index c124a9e605..c124a9e605 100644
--- a/actionpack/test/fixtures/project.rb
+++ b/actionview/test/fixtures/project.rb
diff --git a/actionpack/test/fixtures/projects.yml b/actionview/test/fixtures/projects.yml
index 02800c7824..02800c7824 100644
--- a/actionpack/test/fixtures/projects.yml
+++ b/actionview/test/fixtures/projects.yml
diff --git a/actionpack/test/fixtures/projects/_project.erb b/actionview/test/fixtures/projects/_project.erb
index 480c4c2af3..480c4c2af3 100644
--- a/actionpack/test/fixtures/projects/_project.erb
+++ b/actionview/test/fixtures/projects/_project.erb
diff --git a/actionpack/test/fixtures/public/.gitignore b/actionview/test/fixtures/public/.gitignore
index 312e635ee6..312e635ee6 100644
--- a/actionpack/test/fixtures/public/.gitignore
+++ b/actionview/test/fixtures/public/.gitignore
diff --git a/actionpack/test/fixtures/public/elsewhere/cools.js b/actionview/test/fixtures/public/elsewhere/cools.js
index 6e12fe29c4..6e12fe29c4 100644
--- a/actionpack/test/fixtures/public/elsewhere/cools.js
+++ b/actionview/test/fixtures/public/elsewhere/cools.js
diff --git a/actionpack/test/fixtures/public/elsewhere/file.css b/actionview/test/fixtures/public/elsewhere/file.css
index 6aea0733b1..6aea0733b1 100644
--- a/actionpack/test/fixtures/public/elsewhere/file.css
+++ b/actionview/test/fixtures/public/elsewhere/file.css
diff --git a/actionview/test/fixtures/public/foo/baz.css b/actionview/test/fixtures/public/foo/baz.css
new file mode 100644
index 0000000000..b5173fbef2
--- /dev/null
+++ b/actionview/test/fixtures/public/foo/baz.css
@@ -0,0 +1,3 @@
+body {
+background: #000;
+}
diff --git a/actionpack/test/fixtures/public/javascripts/application.js b/actionview/test/fixtures/public/javascripts/application.js
index 9702692980..9702692980 100644
--- a/actionpack/test/fixtures/public/javascripts/application.js
+++ b/actionview/test/fixtures/public/javascripts/application.js
diff --git a/actionpack/test/fixtures/public/javascripts/bank.js b/actionview/test/fixtures/public/javascripts/bank.js
index 4a1bee7182..4a1bee7182 100644
--- a/actionpack/test/fixtures/public/javascripts/bank.js
+++ b/actionview/test/fixtures/public/javascripts/bank.js
diff --git a/actionpack/test/fixtures/public/javascripts/common.javascript b/actionview/test/fixtures/public/javascripts/common.javascript
index 2ae1929056..2ae1929056 100644
--- a/actionpack/test/fixtures/public/javascripts/common.javascript
+++ b/actionview/test/fixtures/public/javascripts/common.javascript
diff --git a/actionpack/test/fixtures/public/javascripts/controls.js b/actionview/test/fixtures/public/javascripts/controls.js
index 88168d9f13..88168d9f13 100644
--- a/actionpack/test/fixtures/public/javascripts/controls.js
+++ b/actionview/test/fixtures/public/javascripts/controls.js
diff --git a/actionpack/test/fixtures/public/javascripts/dragdrop.js b/actionview/test/fixtures/public/javascripts/dragdrop.js
index c07061ac0c..c07061ac0c 100644
--- a/actionpack/test/fixtures/public/javascripts/dragdrop.js
+++ b/actionview/test/fixtures/public/javascripts/dragdrop.js
diff --git a/actionpack/test/fixtures/public/javascripts/effects.js b/actionview/test/fixtures/public/javascripts/effects.js
index b555d63034..b555d63034 100644
--- a/actionpack/test/fixtures/public/javascripts/effects.js
+++ b/actionview/test/fixtures/public/javascripts/effects.js
diff --git a/actionpack/test/fixtures/public/javascripts/prototype.js b/actionview/test/fixtures/public/javascripts/prototype.js
index 9780064a0e..9780064a0e 100644
--- a/actionpack/test/fixtures/public/javascripts/prototype.js
+++ b/actionview/test/fixtures/public/javascripts/prototype.js
diff --git a/actionpack/test/fixtures/public/javascripts/robber.js b/actionview/test/fixtures/public/javascripts/robber.js
index eb82fcbdf4..eb82fcbdf4 100644
--- a/actionpack/test/fixtures/public/javascripts/robber.js
+++ b/actionview/test/fixtures/public/javascripts/robber.js
diff --git a/actionpack/test/fixtures/public/javascripts/subdir/subdir.js b/actionview/test/fixtures/public/javascripts/subdir/subdir.js
index 9d23a67aa1..9d23a67aa1 100644
--- a/actionpack/test/fixtures/public/javascripts/subdir/subdir.js
+++ b/actionview/test/fixtures/public/javascripts/subdir/subdir.js
diff --git a/actionpack/test/fixtures/public/javascripts/version.1.0.js b/actionview/test/fixtures/public/javascripts/version.1.0.js
index cfd5fce70e..cfd5fce70e 100644
--- a/actionpack/test/fixtures/public/javascripts/version.1.0.js
+++ b/actionview/test/fixtures/public/javascripts/version.1.0.js
diff --git a/actionpack/test/fixtures/public/stylesheets/bank.css b/actionview/test/fixtures/public/stylesheets/bank.css
index ea161b12b2..ea161b12b2 100644
--- a/actionpack/test/fixtures/public/stylesheets/bank.css
+++ b/actionview/test/fixtures/public/stylesheets/bank.css
diff --git a/actionpack/test/fixtures/public/stylesheets/random.styles b/actionview/test/fixtures/public/stylesheets/random.styles
index d4eeead95c..d4eeead95c 100644
--- a/actionpack/test/fixtures/public/stylesheets/random.styles
+++ b/actionview/test/fixtures/public/stylesheets/random.styles
diff --git a/actionpack/test/fixtures/public/stylesheets/robber.css b/actionview/test/fixtures/public/stylesheets/robber.css
index 0fdd00a6a5..0fdd00a6a5 100644
--- a/actionpack/test/fixtures/public/stylesheets/robber.css
+++ b/actionview/test/fixtures/public/stylesheets/robber.css
diff --git a/actionpack/test/fixtures/public/stylesheets/subdir/subdir.css b/actionview/test/fixtures/public/stylesheets/subdir/subdir.css
index 241152a905..241152a905 100644
--- a/actionpack/test/fixtures/public/stylesheets/subdir/subdir.css
+++ b/actionview/test/fixtures/public/stylesheets/subdir/subdir.css
diff --git a/actionpack/test/fixtures/public/stylesheets/version.1.0.css b/actionview/test/fixtures/public/stylesheets/version.1.0.css
index 30f5f9ba6e..30f5f9ba6e 100644
--- a/actionpack/test/fixtures/public/stylesheets/version.1.0.css
+++ b/actionview/test/fixtures/public/stylesheets/version.1.0.css
diff --git a/actionpack/test/fixtures/replies.yml b/actionview/test/fixtures/replies.yml
index 2a3454b8bf..2a3454b8bf 100644
--- a/actionpack/test/fixtures/replies.yml
+++ b/actionview/test/fixtures/replies.yml
diff --git a/actionpack/test/fixtures/replies/_reply.erb b/actionview/test/fixtures/replies/_reply.erb
index 68baf548d8..68baf548d8 100644
--- a/actionpack/test/fixtures/replies/_reply.erb
+++ b/actionview/test/fixtures/replies/_reply.erb
diff --git a/actionpack/test/fixtures/reply.rb b/actionview/test/fixtures/reply.rb
index 047522c55b..047522c55b 100644
--- a/actionpack/test/fixtures/reply.rb
+++ b/actionview/test/fixtures/reply.rb
diff --git a/actionview/test/fixtures/respond_to/using_defaults_with_all.html.erb b/actionview/test/fixtures/respond_to/using_defaults_with_all.html.erb
new file mode 100644
index 0000000000..9f1f855269
--- /dev/null
+++ b/actionview/test/fixtures/respond_to/using_defaults_with_all.html.erb
@@ -0,0 +1 @@
+HTML!
diff --git a/actionview/test/fixtures/ruby_template.ruby b/actionview/test/fixtures/ruby_template.ruby
new file mode 100644
index 0000000000..5097bce47c
--- /dev/null
+++ b/actionview/test/fixtures/ruby_template.ruby
@@ -0,0 +1,2 @@
+body = ""
+body << ["Hello", "from", "Ruby", "code"].join(" ")
diff --git a/actionpack/test/fixtures/scope/test/modgreet.erb b/actionview/test/fixtures/scope/test/modgreet.erb
index 8947726e89..8947726e89 100644
--- a/actionpack/test/fixtures/scope/test/modgreet.erb
+++ b/actionview/test/fixtures/scope/test/modgreet.erb
diff --git a/actionview/test/fixtures/shared.html.erb b/actionview/test/fixtures/shared.html.erb
new file mode 100644
index 0000000000..af262fc9f8
--- /dev/null
+++ b/actionview/test/fixtures/shared.html.erb
@@ -0,0 +1 @@
+Elastica \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/_200.html.erb b/actionview/test/fixtures/test/_200.html.erb
index c9f45675dc..c9f45675dc 100644
--- a/actionpack/test/fixtures/test/_200.html.erb
+++ b/actionview/test/fixtures/test/_200.html.erb
diff --git a/actionpack/test/fixtures/test/_b_layout_for_partial.html.erb b/actionview/test/fixtures/test/_b_layout_for_partial.html.erb
index e918ba8f83..e918ba8f83 100644
--- a/actionpack/test/fixtures/test/_b_layout_for_partial.html.erb
+++ b/actionview/test/fixtures/test/_b_layout_for_partial.html.erb
diff --git a/actionpack/test/fixtures/test/_b_layout_for_partial_with_object.html.erb b/actionview/test/fixtures/test/_b_layout_for_partial_with_object.html.erb
index bdd53014cd..bdd53014cd 100644
--- a/actionpack/test/fixtures/test/_b_layout_for_partial_with_object.html.erb
+++ b/actionview/test/fixtures/test/_b_layout_for_partial_with_object.html.erb
diff --git a/actionpack/test/fixtures/test/_b_layout_for_partial_with_object_counter.html.erb b/actionview/test/fixtures/test/_b_layout_for_partial_with_object_counter.html.erb
index 44d6121297..44d6121297 100644
--- a/actionpack/test/fixtures/test/_b_layout_for_partial_with_object_counter.html.erb
+++ b/actionview/test/fixtures/test/_b_layout_for_partial_with_object_counter.html.erb
diff --git a/actionview/test/fixtures/test/_changing_priority.html.erb b/actionview/test/fixtures/test/_changing_priority.html.erb
new file mode 100644
index 0000000000..3225efc49a
--- /dev/null
+++ b/actionview/test/fixtures/test/_changing_priority.html.erb
@@ -0,0 +1 @@
+HTML \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_changing_priority.json.erb b/actionview/test/fixtures/test/_changing_priority.json.erb
new file mode 100644
index 0000000000..7fa41dce66
--- /dev/null
+++ b/actionview/test/fixtures/test/_changing_priority.json.erb
@@ -0,0 +1 @@
+JSON \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/_content_tag_nested_in_content_tag.erb b/actionview/test/fixtures/test/_content_tag_nested_in_content_tag.erb
index 2f21a75dd9..2f21a75dd9 100644
--- a/actionpack/test/fixtures/test/_content_tag_nested_in_content_tag.erb
+++ b/actionview/test/fixtures/test/_content_tag_nested_in_content_tag.erb
diff --git a/actionview/test/fixtures/test/_counter.html.erb b/actionview/test/fixtures/test/_counter.html.erb
new file mode 100644
index 0000000000..fd245bfc70
--- /dev/null
+++ b/actionview/test/fixtures/test/_counter.html.erb
@@ -0,0 +1 @@
+<%= counter_counter %> \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_customer.erb b/actionview/test/fixtures/test/_customer.erb
new file mode 100644
index 0000000000..d8220afeda
--- /dev/null
+++ b/actionview/test/fixtures/test/_customer.erb
@@ -0,0 +1 @@
+Hello: <%= customer.name rescue "Anonymous" %> \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_customer_greeting.erb b/actionview/test/fixtures/test/_customer_greeting.erb
new file mode 100644
index 0000000000..6acbcb20c4
--- /dev/null
+++ b/actionview/test/fixtures/test/_customer_greeting.erb
@@ -0,0 +1 @@
+<%= greeting %>: <%= customer_greeting.name %> \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_customer_with_var.erb b/actionview/test/fixtures/test/_customer_with_var.erb
new file mode 100644
index 0000000000..00047dd20e
--- /dev/null
+++ b/actionview/test/fixtures/test/_customer_with_var.erb
@@ -0,0 +1 @@
+<%= customer.name %> <%= customer.name %> <%= customer.name %> \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_directory/_partial_with_locales.html.erb b/actionview/test/fixtures/test/_directory/_partial_with_locales.html.erb
new file mode 100644
index 0000000000..1cc8d41475
--- /dev/null
+++ b/actionview/test/fixtures/test/_directory/_partial_with_locales.html.erb
@@ -0,0 +1 @@
+Hello <%= name %>
diff --git a/actionview/test/fixtures/test/_first_json_partial.json.erb b/actionview/test/fixtures/test/_first_json_partial.json.erb
new file mode 100644
index 0000000000..790ee896db
--- /dev/null
+++ b/actionview/test/fixtures/test/_first_json_partial.json.erb
@@ -0,0 +1 @@
+<%= render :partial => "test/second_json_partial" %> \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/_from_helper.erb b/actionview/test/fixtures/test/_from_helper.erb
index 16de7c0f8a..16de7c0f8a 100644
--- a/actionpack/test/fixtures/test/_from_helper.erb
+++ b/actionview/test/fixtures/test/_from_helper.erb
diff --git a/actionview/test/fixtures/test/_json_change_priority.json.erb b/actionview/test/fixtures/test/_json_change_priority.json.erb
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/actionview/test/fixtures/test/_json_change_priority.json.erb
diff --git a/actionpack/test/fixtures/test/_label_with_block.erb b/actionview/test/fixtures/test/_label_with_block.erb
index 40117e594e..40117e594e 100644
--- a/actionpack/test/fixtures/test/_label_with_block.erb
+++ b/actionview/test/fixtures/test/_label_with_block.erb
diff --git a/actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb b/actionview/test/fixtures/test/_layout_for_block_with_args.html.erb
index 307533208d..307533208d 100644
--- a/actionpack/test/fixtures/test/_layout_for_block_with_args.html.erb
+++ b/actionview/test/fixtures/test/_layout_for_block_with_args.html.erb
diff --git a/actionview/test/fixtures/test/_layout_for_partial.html.erb b/actionview/test/fixtures/test/_layout_for_partial.html.erb
new file mode 100644
index 0000000000..666efadbb6
--- /dev/null
+++ b/actionview/test/fixtures/test/_layout_for_partial.html.erb
@@ -0,0 +1,3 @@
+Before (<%= name %>)
+<%= yield %>
+After \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb b/actionview/test/fixtures/test/_layout_with_partial_and_yield.html.erb
index 820e7db789..820e7db789 100644
--- a/actionpack/test/fixtures/test/_layout_with_partial_and_yield.html.erb
+++ b/actionview/test/fixtures/test/_layout_with_partial_and_yield.html.erb
diff --git a/actionpack/test/fixtures/test/_local_inspector.html.erb b/actionview/test/fixtures/test/_local_inspector.html.erb
index e6765c0882..e6765c0882 100644
--- a/actionpack/test/fixtures/test/_local_inspector.html.erb
+++ b/actionview/test/fixtures/test/_local_inspector.html.erb
diff --git a/actionpack/test/fixtures/test/_object_inspector.erb b/actionview/test/fixtures/test/_object_inspector.erb
index 53af593821..53af593821 100644
--- a/actionpack/test/fixtures/test/_object_inspector.erb
+++ b/actionview/test/fixtures/test/_object_inspector.erb
diff --git a/actionpack/test/fixtures/test/_one.html.erb b/actionview/test/fixtures/test/_one.html.erb
index f796291cb4..f796291cb4 100644
--- a/actionpack/test/fixtures/test/_one.html.erb
+++ b/actionview/test/fixtures/test/_one.html.erb
diff --git a/actionview/test/fixtures/test/_partial.erb b/actionview/test/fixtures/test/_partial.erb
new file mode 100644
index 0000000000..e466dcbd8e
--- /dev/null
+++ b/actionview/test/fixtures/test/_partial.erb
@@ -0,0 +1 @@
+invalid \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_partial.html.erb b/actionview/test/fixtures/test/_partial.html.erb
new file mode 100644
index 0000000000..e39f6c9827
--- /dev/null
+++ b/actionview/test/fixtures/test/_partial.html.erb
@@ -0,0 +1 @@
+partial html \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_partial.js.erb b/actionview/test/fixtures/test/_partial.js.erb
new file mode 100644
index 0000000000..b350cdd7ef
--- /dev/null
+++ b/actionview/test/fixtures/test/_partial.js.erb
@@ -0,0 +1 @@
+partial js \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_partial_for_use_in_layout.html.erb b/actionview/test/fixtures/test/_partial_for_use_in_layout.html.erb
new file mode 100644
index 0000000000..3a03a64e31
--- /dev/null
+++ b/actionview/test/fixtures/test/_partial_for_use_in_layout.html.erb
@@ -0,0 +1 @@
+Inside from partial (<%= name %>) \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_partial_name_local_variable.erb b/actionview/test/fixtures/test/_partial_name_local_variable.erb
new file mode 100644
index 0000000000..cc3a91c89f
--- /dev/null
+++ b/actionview/test/fixtures/test/_partial_name_local_variable.erb
@@ -0,0 +1 @@
+<%= partial_name_local_variable %>
diff --git a/actionview/test/fixtures/test/_partial_only.erb b/actionview/test/fixtures/test/_partial_only.erb
new file mode 100644
index 0000000000..a44b3eed40
--- /dev/null
+++ b/actionview/test/fixtures/test/_partial_only.erb
@@ -0,0 +1 @@
+only partial \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/_partial_with_layout.erb b/actionview/test/fixtures/test/_partial_with_layout.erb
index 2a50c834fe..2a50c834fe 100644
--- a/actionpack/test/fixtures/test/_partial_with_layout.erb
+++ b/actionview/test/fixtures/test/_partial_with_layout.erb
diff --git a/actionpack/test/fixtures/test/_partial_with_layout_block_content.erb b/actionview/test/fixtures/test/_partial_with_layout_block_content.erb
index 65dafd93a8..65dafd93a8 100644
--- a/actionpack/test/fixtures/test/_partial_with_layout_block_content.erb
+++ b/actionview/test/fixtures/test/_partial_with_layout_block_content.erb
diff --git a/actionpack/test/fixtures/test/_partial_with_layout_block_partial.erb b/actionview/test/fixtures/test/_partial_with_layout_block_partial.erb
index 444197a7d0..444197a7d0 100644
--- a/actionpack/test/fixtures/test/_partial_with_layout_block_partial.erb
+++ b/actionview/test/fixtures/test/_partial_with_layout_block_partial.erb
diff --git a/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb b/actionview/test/fixtures/test/_partial_with_only_html_version.html.erb
index 00e6b6d6da..00e6b6d6da 100644
--- a/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb
+++ b/actionview/test/fixtures/test/_partial_with_only_html_version.html.erb
diff --git a/actionview/test/fixtures/test/_partial_with_partial.erb b/actionview/test/fixtures/test/_partial_with_partial.erb
new file mode 100644
index 0000000000..ee0d5037b6
--- /dev/null
+++ b/actionview/test/fixtures/test/_partial_with_partial.erb
@@ -0,0 +1,2 @@
+<%= render 'test/partial' %>
+partial with partial
diff --git a/actionpack/test/fixtures/test/_raise.html.erb b/actionview/test/fixtures/test/_raise.html.erb
index 68b08181d3..68b08181d3 100644
--- a/actionpack/test/fixtures/test/_raise.html.erb
+++ b/actionview/test/fixtures/test/_raise.html.erb
diff --git a/actionview/test/fixtures/test/_raise_indentation.html.erb b/actionview/test/fixtures/test/_raise_indentation.html.erb
new file mode 100644
index 0000000000..f9a93728fe
--- /dev/null
+++ b/actionview/test/fixtures/test/_raise_indentation.html.erb
@@ -0,0 +1,13 @@
+<p>First paragraph</p>
+<p>Second paragraph</p>
+<p>Third paragraph</p>
+<p>Fourth paragraph</p>
+<p>Fifth paragraph</p>
+<p>Sixth paragraph</p>
+<p>Seventh paragraph</p>
+<p>Eight paragraph</p>
+<p>Ninth paragraph</p>
+<p>Tenth paragraph</p>
+<%= raise "error here!" %>
+<p>Eleventh paragraph</p>
+<p>Twelfth paragraph</p> \ No newline at end of file
diff --git a/actionview/test/fixtures/test/_second_json_partial.json.erb b/actionview/test/fixtures/test/_second_json_partial.json.erb
new file mode 100644
index 0000000000..5ebb7f1afd
--- /dev/null
+++ b/actionview/test/fixtures/test/_second_json_partial.json.erb
@@ -0,0 +1 @@
+Third level \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/_two.html.erb b/actionview/test/fixtures/test/_two.html.erb
index 5ab2f8a432..5ab2f8a432 100644
--- a/actionpack/test/fixtures/test/_two.html.erb
+++ b/actionview/test/fixtures/test/_two.html.erb
diff --git a/actionpack/test/fixtures/test/_utf8_partial.html.erb b/actionview/test/fixtures/test/_utf8_partial.html.erb
index 8d717fd427..8d717fd427 100644
--- a/actionpack/test/fixtures/test/_utf8_partial.html.erb
+++ b/actionview/test/fixtures/test/_utf8_partial.html.erb
diff --git a/actionpack/test/fixtures/test/_utf8_partial_magic.html.erb b/actionview/test/fixtures/test/_utf8_partial_magic.html.erb
index 4e2224610a..4e2224610a 100644
--- a/actionpack/test/fixtures/test/_utf8_partial_magic.html.erb
+++ b/actionview/test/fixtures/test/_utf8_partial_magic.html.erb
diff --git a/actionpack/test/fixtures/test/basic.html.erb b/actionview/test/fixtures/test/basic.html.erb
index ea696d7e01..ea696d7e01 100644
--- a/actionpack/test/fixtures/test/basic.html.erb
+++ b/actionview/test/fixtures/test/basic.html.erb
diff --git a/actionview/test/fixtures/test/calling_partial_with_layout.html.erb b/actionview/test/fixtures/test/calling_partial_with_layout.html.erb
new file mode 100644
index 0000000000..ac44bc0d81
--- /dev/null
+++ b/actionview/test/fixtures/test/calling_partial_with_layout.html.erb
@@ -0,0 +1 @@
+<%= render(:layout => "layout_for_partial", :partial => "partial_for_use_in_layout", :locals => { :name => "David" }) %> \ No newline at end of file
diff --git a/actionview/test/fixtures/test/change_priority.html.erb b/actionview/test/fixtures/test/change_priority.html.erb
new file mode 100644
index 0000000000..5618977d05
--- /dev/null
+++ b/actionview/test/fixtures/test/change_priority.html.erb
@@ -0,0 +1,2 @@
+<%= render :partial => "test/json_change_priority", formats: :json %>
+HTML Template, but <%= render :partial => "test/changing_priority" %> partial \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/dont_pick_me b/actionview/test/fixtures/test/dont_pick_me
index 0157c9e503..0157c9e503 100644
--- a/actionpack/test/fixtures/test/dont_pick_me
+++ b/actionview/test/fixtures/test/dont_pick_me
diff --git a/actionview/test/fixtures/test/dot.directory/render_file_with_ivar.erb b/actionview/test/fixtures/test/dot.directory/render_file_with_ivar.erb
new file mode 100644
index 0000000000..8b8a449236
--- /dev/null
+++ b/actionview/test/fixtures/test/dot.directory/render_file_with_ivar.erb
@@ -0,0 +1 @@
+The secret is <%= @secret %>
diff --git a/actionview/test/fixtures/test/greeting.xml.erb b/actionview/test/fixtures/test/greeting.xml.erb
new file mode 100644
index 0000000000..62fb0293f0
--- /dev/null
+++ b/actionview/test/fixtures/test/greeting.xml.erb
@@ -0,0 +1 @@
+<p>This is grand!</p>
diff --git a/actionview/test/fixtures/test/hello.builder b/actionview/test/fixtures/test/hello.builder
new file mode 100644
index 0000000000..a471553941
--- /dev/null
+++ b/actionview/test/fixtures/test/hello.builder
@@ -0,0 +1,4 @@
+xml.html do
+ xml.p "Hello #{@name}"
+ xml << render(:file => "test/greeting")
+end \ No newline at end of file
diff --git a/actionview/test/fixtures/test/hello/hello.erb b/actionview/test/fixtures/test/hello/hello.erb
new file mode 100644
index 0000000000..6769dd60bd
--- /dev/null
+++ b/actionview/test/fixtures/test/hello/hello.erb
@@ -0,0 +1 @@
+Hello world! \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/hello_world.da.html.erb b/actionview/test/fixtures/test/hello_world.da.html.erb
index 10ec443291..10ec443291 100644
--- a/actionpack/test/fixtures/test/hello_world.da.html.erb
+++ b/actionview/test/fixtures/test/hello_world.da.html.erb
diff --git a/actionview/test/fixtures/test/hello_world.erb b/actionview/test/fixtures/test/hello_world.erb
new file mode 100644
index 0000000000..6769dd60bd
--- /dev/null
+++ b/actionview/test/fixtures/test/hello_world.erb
@@ -0,0 +1 @@
+Hello world! \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/hello_world.erb~ b/actionview/test/fixtures/test/hello_world.erb~
index 21934a1c95..21934a1c95 100644
--- a/actionpack/test/fixtures/test/hello_world.erb~
+++ b/actionview/test/fixtures/test/hello_world.erb~
diff --git a/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb b/actionview/test/fixtures/test/hello_world.pt-BR.html.erb
index 773b3c8c6e..773b3c8c6e 100644
--- a/actionpack/test/fixtures/test/hello_world.pt-BR.html.erb
+++ b/actionview/test/fixtures/test/hello_world.pt-BR.html.erb
diff --git a/actionview/test/fixtures/test/hello_world_with_partial.html.erb b/actionview/test/fixtures/test/hello_world_with_partial.html.erb
new file mode 100644
index 0000000000..ec31545356
--- /dev/null
+++ b/actionview/test/fixtures/test/hello_world_with_partial.html.erb
@@ -0,0 +1,2 @@
+Hello world!
+<%= render '/test/partial' %>
diff --git a/actionview/test/fixtures/test/html_template.html.erb b/actionview/test/fixtures/test/html_template.html.erb
new file mode 100644
index 0000000000..1bbc2b7f09
--- /dev/null
+++ b/actionview/test/fixtures/test/html_template.html.erb
@@ -0,0 +1 @@
+<%= render :partial => "test/first_json_partial", formats: :json %> \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/layout_render_file.erb b/actionview/test/fixtures/test/layout_render_file.erb
index 2f8e921c5f..2f8e921c5f 100644
--- a/actionpack/test/fixtures/test/layout_render_file.erb
+++ b/actionview/test/fixtures/test/layout_render_file.erb
diff --git a/actionpack/test/fixtures/test/layout_render_object.erb b/actionview/test/fixtures/test/layout_render_object.erb
index acc4453c08..acc4453c08 100644
--- a/actionpack/test/fixtures/test/layout_render_object.erb
+++ b/actionview/test/fixtures/test/layout_render_object.erb
diff --git a/actionview/test/fixtures/test/list.erb b/actionview/test/fixtures/test/list.erb
new file mode 100644
index 0000000000..0a4bda58ee
--- /dev/null
+++ b/actionview/test/fixtures/test/list.erb
@@ -0,0 +1 @@
+<%= @test_unchanged = 'goodbye' %><%= render :partial => 'customer', :collection => @customers %><%= @test_unchanged %>
diff --git a/actionpack/test/fixtures/test/malformed/malformed.en.html.erb~ b/actionview/test/fixtures/test/malformed/malformed.en.html.erb~
index d009950384..d009950384 100644
--- a/actionpack/test/fixtures/test/malformed/malformed.en.html.erb~
+++ b/actionview/test/fixtures/test/malformed/malformed.en.html.erb~
diff --git a/actionpack/test/fixtures/test/malformed/malformed.erb~ b/actionview/test/fixtures/test/malformed/malformed.erb~
index d009950384..d009950384 100644
--- a/actionpack/test/fixtures/test/malformed/malformed.erb~
+++ b/actionview/test/fixtures/test/malformed/malformed.erb~
diff --git a/actionpack/test/fixtures/test/malformed/malformed.html.erb~ b/actionview/test/fixtures/test/malformed/malformed.html.erb~
index d009950384..d009950384 100644
--- a/actionpack/test/fixtures/test/malformed/malformed.html.erb~
+++ b/actionview/test/fixtures/test/malformed/malformed.html.erb~
diff --git a/actionview/test/fixtures/test/malformed/malformed~ b/actionview/test/fixtures/test/malformed/malformed~
new file mode 100644
index 0000000000..d009950384
--- /dev/null
+++ b/actionview/test/fixtures/test/malformed/malformed~
@@ -0,0 +1 @@
+Don't render me! \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/nested_layout.erb b/actionview/test/fixtures/test/nested_layout.erb
index 6078f74b4c..6078f74b4c 100644
--- a/actionpack/test/fixtures/test/nested_layout.erb
+++ b/actionview/test/fixtures/test/nested_layout.erb
diff --git a/actionpack/test/fixtures/test/nested_streaming.erb b/actionview/test/fixtures/test/nested_streaming.erb
index 55525e0c92..55525e0c92 100644
--- a/actionpack/test/fixtures/test/nested_streaming.erb
+++ b/actionview/test/fixtures/test/nested_streaming.erb
diff --git a/actionpack/test/fixtures/test/one.html.erb b/actionview/test/fixtures/test/one.html.erb
index 0151874809..0151874809 100644
--- a/actionpack/test/fixtures/test/one.html.erb
+++ b/actionview/test/fixtures/test/one.html.erb
diff --git a/actionview/test/fixtures/test/render_file_with_ivar.erb b/actionview/test/fixtures/test/render_file_with_ivar.erb
new file mode 100644
index 0000000000..8b8a449236
--- /dev/null
+++ b/actionview/test/fixtures/test/render_file_with_ivar.erb
@@ -0,0 +1 @@
+The secret is <%= @secret %>
diff --git a/actionview/test/fixtures/test/render_file_with_locals.erb b/actionview/test/fixtures/test/render_file_with_locals.erb
new file mode 100644
index 0000000000..ebe09faee6
--- /dev/null
+++ b/actionview/test/fixtures/test/render_file_with_locals.erb
@@ -0,0 +1 @@
+The secret is <%= secret %>
diff --git a/actionview/test/fixtures/test/render_file_with_locals_and_default.erb b/actionview/test/fixtures/test/render_file_with_locals_and_default.erb
new file mode 100644
index 0000000000..9b4900acc5
--- /dev/null
+++ b/actionview/test/fixtures/test/render_file_with_locals_and_default.erb
@@ -0,0 +1 @@
+<%= secret ||= 'one' %> \ No newline at end of file
diff --git a/actionview/test/fixtures/test/render_partial_inside_directory.html.erb b/actionview/test/fixtures/test/render_partial_inside_directory.html.erb
new file mode 100644
index 0000000000..1461b95186
--- /dev/null
+++ b/actionview/test/fixtures/test/render_partial_inside_directory.html.erb
@@ -0,0 +1 @@
+<%= render partial: 'test/_directory/partial_with_locales', locals: {'name' => 'Jane'} %>
diff --git a/actionview/test/fixtures/test/render_two_partials.html.erb b/actionview/test/fixtures/test/render_two_partials.html.erb
new file mode 100644
index 0000000000..3db6025860
--- /dev/null
+++ b/actionview/test/fixtures/test/render_two_partials.html.erb
@@ -0,0 +1,2 @@
+<%= render :partial => 'partial', :locals => {'first' => '1'} %>
+<%= render :partial => 'partial', :locals => {'second' => '2'} %>
diff --git a/actionpack/test/fixtures/test/streaming.erb b/actionview/test/fixtures/test/streaming.erb
index fb9b8b1ade..fb9b8b1ade 100644
--- a/actionpack/test/fixtures/test/streaming.erb
+++ b/actionview/test/fixtures/test/streaming.erb
diff --git a/actionpack/test/fixtures/test/streaming_buster.erb b/actionview/test/fixtures/test/streaming_buster.erb
index 4221d56dcc..4221d56dcc 100644
--- a/actionpack/test/fixtures/test/streaming_buster.erb
+++ b/actionview/test/fixtures/test/streaming_buster.erb
diff --git a/actionpack/test/fixtures/test/sub_template_raise.html.erb b/actionview/test/fixtures/test/sub_template_raise.html.erb
index f38c0bda90..f38c0bda90 100644
--- a/actionpack/test/fixtures/test/sub_template_raise.html.erb
+++ b/actionview/test/fixtures/test/sub_template_raise.html.erb
diff --git a/actionpack/test/fixtures/test/template.erb b/actionview/test/fixtures/test/template.erb
index 785afa8f6a..785afa8f6a 100644
--- a/actionpack/test/fixtures/test/template.erb
+++ b/actionview/test/fixtures/test/template.erb
diff --git a/actionpack/test/fixtures/test/update_element_with_capture.erb b/actionview/test/fixtures/test/update_element_with_capture.erb
index fa3ef200f9..fa3ef200f9 100644
--- a/actionpack/test/fixtures/test/update_element_with_capture.erb
+++ b/actionview/test/fixtures/test/update_element_with_capture.erb
diff --git a/actionpack/test/fixtures/test/utf8.html.erb b/actionview/test/fixtures/test/utf8.html.erb
index ac98c2f012..ac98c2f012 100644
--- a/actionpack/test/fixtures/test/utf8.html.erb
+++ b/actionview/test/fixtures/test/utf8.html.erb
diff --git a/actionpack/test/fixtures/test/utf8_magic.html.erb b/actionview/test/fixtures/test/utf8_magic.html.erb
index 257279c29f..257279c29f 100644
--- a/actionpack/test/fixtures/test/utf8_magic.html.erb
+++ b/actionview/test/fixtures/test/utf8_magic.html.erb
diff --git a/actionpack/test/fixtures/test/utf8_magic_with_bare_partial.html.erb b/actionview/test/fixtures/test/utf8_magic_with_bare_partial.html.erb
index cb22692f9a..cb22692f9a 100644
--- a/actionpack/test/fixtures/test/utf8_magic_with_bare_partial.html.erb
+++ b/actionview/test/fixtures/test/utf8_magic_with_bare_partial.html.erb
diff --git a/actionpack/test/fixtures/topic.rb b/actionview/test/fixtures/topic.rb
index 9fa9746535..9fa9746535 100644
--- a/actionpack/test/fixtures/topic.rb
+++ b/actionview/test/fixtures/topic.rb
diff --git a/actionpack/test/fixtures/topics.yml b/actionview/test/fixtures/topics.yml
index 7fdd49d54e..7fdd49d54e 100644
--- a/actionpack/test/fixtures/topics.yml
+++ b/actionview/test/fixtures/topics.yml
diff --git a/actionpack/test/fixtures/topics/_topic.html.erb b/actionview/test/fixtures/topics/_topic.html.erb
index 98659ca098..98659ca098 100644
--- a/actionpack/test/fixtures/topics/_topic.html.erb
+++ b/actionview/test/fixtures/topics/_topic.html.erb
diff --git a/actionpack/test/fixtures/translations/templates/array.erb b/actionview/test/fixtures/translations/templates/array.erb
index d86045a172..d86045a172 100644
--- a/actionpack/test/fixtures/translations/templates/array.erb
+++ b/actionview/test/fixtures/translations/templates/array.erb
diff --git a/actionpack/test/fixtures/translations/templates/default.erb b/actionview/test/fixtures/translations/templates/default.erb
index 8b70031071..8b70031071 100644
--- a/actionpack/test/fixtures/translations/templates/default.erb
+++ b/actionview/test/fixtures/translations/templates/default.erb
diff --git a/actionpack/test/fixtures/translations/templates/found.erb b/actionview/test/fixtures/translations/templates/found.erb
index 080c9c0aee..080c9c0aee 100644
--- a/actionpack/test/fixtures/translations/templates/found.erb
+++ b/actionview/test/fixtures/translations/templates/found.erb
diff --git a/actionpack/test/fixtures/translations/templates/missing.erb b/actionview/test/fixtures/translations/templates/missing.erb
index 0f3f17f8ef..0f3f17f8ef 100644
--- a/actionpack/test/fixtures/translations/templates/missing.erb
+++ b/actionview/test/fixtures/translations/templates/missing.erb
diff --git a/actionpack/test/fixtures/with_format.json.erb b/actionview/test/fixtures/with_format.json.erb
index a7f480ab1d..a7f480ab1d 100644
--- a/actionpack/test/fixtures/with_format.json.erb
+++ b/actionview/test/fixtures/with_format.json.erb
diff --git a/actionview/test/lib/controller/fake_controllers.rb b/actionview/test/lib/controller/fake_controllers.rb
new file mode 100644
index 0000000000..1a2863b689
--- /dev/null
+++ b/actionview/test/lib/controller/fake_controllers.rb
@@ -0,0 +1,35 @@
+class ContentController < ActionController::Base; end
+
+module Admin
+ class AccountsController < ActionController::Base; end
+ class PostsController < ActionController::Base; end
+ class StuffController < ActionController::Base; end
+ class UserController < ActionController::Base; end
+ class UsersController < ActionController::Base; end
+end
+
+module Api
+ class UsersController < ActionController::Base; end
+ class ProductsController < ActionController::Base; end
+end
+
+class AccountController < ActionController::Base; end
+class ArchiveController < ActionController::Base; end
+class ArticlesController < ActionController::Base; end
+class BarController < ActionController::Base; end
+class BlogController < ActionController::Base; end
+class BooksController < ActionController::Base; end
+class CarsController < ActionController::Base; end
+class CcController < ActionController::Base; end
+class CController < ActionController::Base; end
+class FooController < ActionController::Base; end
+class GeocodeController < ActionController::Base; end
+class NewsController < ActionController::Base; end
+class NotesController < ActionController::Base; end
+class PagesController < ActionController::Base; end
+class PeopleController < ActionController::Base; end
+class PostsController < ActionController::Base; end
+class SubpathBooksController < ActionController::Base; end
+class SymbolsController < ActionController::Base; end
+class UserController < ActionController::Base; end
+class UsersController < ActionController::Base; end
diff --git a/actionview/test/lib/controller/fake_models.rb b/actionview/test/lib/controller/fake_models.rb
new file mode 100644
index 0000000000..a463a08bb6
--- /dev/null
+++ b/actionview/test/lib/controller/fake_models.rb
@@ -0,0 +1,185 @@
+require "active_model"
+
+class Customer < Struct.new(:name, :id)
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ undef_method :to_json
+
+ def to_xml(options={})
+ if options[:builder]
+ options[:builder].name name
+ else
+ "<name>#{name}</name>"
+ end
+ end
+
+ def to_js(options={})
+ "name: #{name.inspect}"
+ end
+ alias :to_text :to_js
+
+ def errors
+ []
+ end
+
+ def persisted?
+ id.present?
+ end
+end
+
+class GoodCustomer < Customer
+end
+
+class Post < Struct.new(:title, :author_name, :body, :secret, :persisted, :written_on, :cost)
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+ extend ActiveModel::Translation
+
+ alias_method :secret?, :secret
+ alias_method :persisted?, :persisted
+
+ def initialize(*args)
+ super
+ @persisted = false
+ end
+
+ attr_accessor :author
+ def author_attributes=(attributes); end
+
+ attr_accessor :comments, :comment_ids
+ def comments_attributes=(attributes); end
+
+ attr_accessor :tags
+ def tags_attributes=(attributes); end
+end
+
+class Comment
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ attr_reader :id
+ attr_reader :post_id
+ def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end
+ def to_key; id ? [id] : nil end
+ def save; @id = 1; @post_id = 1 end
+ def persisted?; @id.present? end
+ def to_param; @id.to_s; end
+ def name
+ @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}"
+ end
+
+ attr_accessor :relevances
+ def relevances_attributes=(attributes); end
+
+ attr_accessor :body
+end
+
+class Tag
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ attr_reader :id
+ attr_reader :post_id
+ def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end
+ def to_key; id ? [id] : nil end
+ def save; @id = 1; @post_id = 1 end
+ def persisted?; @id.present? end
+ def to_param; @id; end
+ def value
+ @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}"
+ end
+
+ attr_accessor :relevances
+ def relevances_attributes=(attributes); end
+
+end
+
+class CommentRelevance
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ attr_reader :id
+ attr_reader :comment_id
+ def initialize(id = nil, comment_id = nil); @id, @comment_id = id, comment_id end
+ def to_key; id ? [id] : nil end
+ def save; @id = 1; @comment_id = 1 end
+ def persisted?; @id.present? end
+ def to_param; @id; end
+ def value
+ @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}"
+ end
+end
+
+class Sheep
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ attr_reader :id
+ def to_key; id ? [id] : nil end
+ def save; @id = 1 end
+ def new_record?; @id.nil? end
+ def name
+ @id.nil? ? 'new sheep' : "sheep ##{@id}"
+ end
+end
+
+class TagRelevance
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ attr_reader :id
+ attr_reader :tag_id
+ def initialize(id = nil, tag_id = nil); @id, @tag_id = id, tag_id end
+ def to_key; id ? [id] : nil end
+ def save; @id = 1; @tag_id = 1 end
+ def persisted?; @id.present? end
+ def to_param; @id; end
+ def value
+ @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}"
+ end
+end
+
+class Author < Comment
+ attr_accessor :post
+ def post_attributes=(attributes); end
+end
+
+class HashBackedAuthor < Hash
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ def persisted?; false; end
+
+ def name
+ "hash backed author"
+ end
+end
+
+module Blog
+ def self.use_relative_model_naming?
+ true
+ end
+
+ class Post < Struct.new(:title, :id)
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ def persisted?
+ id.present?
+ end
+ end
+end
+
+class ArelLike
+ def to_ary
+ true
+ end
+ def each
+ a = Array.new(2) { |id| Comment.new(id + 1) }
+ a.each { |i| yield i }
+ end
+end
+
+class Car < Struct.new(:color)
+end
diff --git a/actionpack/test/template/active_model_helper_test.rb b/actionview/test/template/active_model_helper_test.rb
index 86bccdfade..86bccdfade 100644
--- a/actionpack/test/template/active_model_helper_test.rb
+++ b/actionview/test/template/active_model_helper_test.rb
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionview/test/template/asset_tag_helper_test.rb
index 214a13654e..214a13654e 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionview/test/template/asset_tag_helper_test.rb
diff --git a/actionpack/test/template/atom_feed_helper_test.rb b/actionview/test/template/atom_feed_helper_test.rb
index 63b5ac0fab..63b5ac0fab 100644
--- a/actionpack/test/template/atom_feed_helper_test.rb
+++ b/actionview/test/template/atom_feed_helper_test.rb
diff --git a/actionpack/test/template/capture_helper_test.rb b/actionview/test/template/capture_helper_test.rb
index 938f1c3e54..938f1c3e54 100644
--- a/actionpack/test/template/capture_helper_test.rb
+++ b/actionview/test/template/capture_helper_test.rb
diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionview/test/template/compiled_templates_test.rb
index f5dc2fbb33..2336321f3e 100644
--- a/actionpack/test/template/compiled_templates_test.rb
+++ b/actionview/test/template/compiled_templates_test.rb
@@ -1,5 +1,4 @@
require 'abstract_unit'
-require 'controller/fake_models'
class CompiledTemplatesTest < ActiveSupport::TestCase
def setup
diff --git a/actionpack/test/template/date_helper_i18n_test.rb b/actionview/test/template/date_helper_i18n_test.rb
index 21fca35185..21fca35185 100644
--- a/actionpack/test/template/date_helper_i18n_test.rb
+++ b/actionview/test/template/date_helper_i18n_test.rb
diff --git a/actionpack/test/template/date_helper_test.rb b/actionview/test/template/date_helper_test.rb
index 242b56a1fd..242b56a1fd 100644
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionview/test/template/date_helper_test.rb
diff --git a/actionpack/test/template/debug_helper_test.rb b/actionview/test/template/debug_helper_test.rb
index 42d06bd9ff..42d06bd9ff 100644
--- a/actionpack/test/template/debug_helper_test.rb
+++ b/actionview/test/template/debug_helper_test.rb
diff --git a/actionpack/test/template/dependency_tracker_test.rb b/actionview/test/template/dependency_tracker_test.rb
index 7a9b4b26ac..7a9b4b26ac 100644
--- a/actionpack/test/template/dependency_tracker_test.rb
+++ b/actionview/test/template/dependency_tracker_test.rb
diff --git a/actionpack/test/template/digestor_test.rb b/actionview/test/template/digestor_test.rb
index 06735c30d3..06735c30d3 100644
--- a/actionpack/test/template/digestor_test.rb
+++ b/actionview/test/template/digestor_test.rb
diff --git a/actionpack/test/template/erb/form_for_test.rb b/actionview/test/template/erb/form_for_test.rb
index e722b40a9a..e722b40a9a 100644
--- a/actionpack/test/template/erb/form_for_test.rb
+++ b/actionview/test/template/erb/form_for_test.rb
diff --git a/actionpack/test/template/erb/helper.rb b/actionview/test/template/erb/helper.rb
index a1973068d5..a1973068d5 100644
--- a/actionpack/test/template/erb/helper.rb
+++ b/actionview/test/template/erb/helper.rb
diff --git a/actionpack/test/template/erb/tag_helper_test.rb b/actionview/test/template/erb/tag_helper_test.rb
index 84e328d8be..84e328d8be 100644
--- a/actionpack/test/template/erb/tag_helper_test.rb
+++ b/actionview/test/template/erb/tag_helper_test.rb
diff --git a/actionpack/test/template/erb_util_test.rb b/actionview/test/template/erb_util_test.rb
index 3e5b029cea..3e5b029cea 100644
--- a/actionpack/test/template/erb_util_test.rb
+++ b/actionview/test/template/erb_util_test.rb
diff --git a/actionpack/test/template/form_collections_helper_test.rb b/actionview/test/template/form_collections_helper_test.rb
index bc9c21dfd3..bc9c21dfd3 100644
--- a/actionpack/test/template/form_collections_helper_test.rb
+++ b/actionview/test/template/form_collections_helper_test.rb
diff --git a/actionpack/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb
index 1ff320224d..1ff320224d 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionview/test/template/form_helper_test.rb
diff --git a/actionpack/test/template/form_options_helper_i18n_test.rb b/actionview/test/template/form_options_helper_i18n_test.rb
index 4972ea6511..4972ea6511 100644
--- a/actionpack/test/template/form_options_helper_i18n_test.rb
+++ b/actionview/test/template/form_options_helper_i18n_test.rb
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb
index 1715902927..8c90a58a84 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionview/test/template/form_options_helper_test.rb
@@ -310,15 +310,6 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
- def test_grouped_options_for_select_with_selected_and_prompt_deprecated
- assert_deprecated 'Passing the prompt to grouped_options_for_select as an argument is deprecated. Please use an options hash like `{ prompt: "Choose a product..." }`.' do
- assert_dom_equal(
- "<option value=\"\">Choose a product...</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option selected=\"selected\" value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>",
- grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], "Cowboy Hat", "Choose a product...")
- )
- end
- end
-
def test_grouped_options_for_select_with_selected_and_prompt
assert_dom_equal(
"<option value=\"\">Choose a product...</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option selected=\"selected\" value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>",
@@ -337,14 +328,6 @@ class FormOptionsHelperTest < ActionView::TestCase
assert grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]]).html_safe?
end
- def test_grouped_options_for_select_with_prompt_returns_html_escaped_string_deprecated
- ActiveSupport::Deprecation.silence do
- assert_dom_equal(
- "<option value=\"\">&lt;Choose One&gt;</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>",
- grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], nil, '<Choose One>'))
- end
- end
-
def test_grouped_options_for_select_with_prompt_returns_html_escaped_string
assert_dom_equal(
"<option value=\"\">&lt;Choose One&gt;</option><optgroup label=\"Hats\"><option value=\"Baseball Cap\">Baseball Cap</option>\n<option value=\"Cowboy Hat\">Cowboy Hat</option></optgroup>",
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionview/test/template/form_tag_helper_test.rb
index 70fc6a588b..70fc6a588b 100644
--- a/actionpack/test/template/form_tag_helper_test.rb
+++ b/actionview/test/template/form_tag_helper_test.rb
diff --git a/actionpack/test/template/html-scanner/cdata_node_test.rb b/actionview/test/template/html-scanner/cdata_node_test.rb
index 9b58174641..9b58174641 100644
--- a/actionpack/test/template/html-scanner/cdata_node_test.rb
+++ b/actionview/test/template/html-scanner/cdata_node_test.rb
diff --git a/actionpack/test/template/html-scanner/document_test.rb b/actionview/test/template/html-scanner/document_test.rb
index 17f045d549..17f045d549 100644
--- a/actionpack/test/template/html-scanner/document_test.rb
+++ b/actionview/test/template/html-scanner/document_test.rb
diff --git a/actionpack/test/template/html-scanner/node_test.rb b/actionview/test/template/html-scanner/node_test.rb
index 5b5d092036..5b5d092036 100644
--- a/actionpack/test/template/html-scanner/node_test.rb
+++ b/actionview/test/template/html-scanner/node_test.rb
diff --git a/actionpack/test/template/html-scanner/sanitizer_test.rb b/actionview/test/template/html-scanner/sanitizer_test.rb
index b1c1b83807..b1c1b83807 100644
--- a/actionpack/test/template/html-scanner/sanitizer_test.rb
+++ b/actionview/test/template/html-scanner/sanitizer_test.rb
diff --git a/actionpack/test/template/html-scanner/tag_node_test.rb b/actionview/test/template/html-scanner/tag_node_test.rb
index a29d2d43d7..a29d2d43d7 100644
--- a/actionpack/test/template/html-scanner/tag_node_test.rb
+++ b/actionview/test/template/html-scanner/tag_node_test.rb
diff --git a/actionpack/test/template/html-scanner/text_node_test.rb b/actionview/test/template/html-scanner/text_node_test.rb
index cbcb9e78f0..cbcb9e78f0 100644
--- a/actionpack/test/template/html-scanner/text_node_test.rb
+++ b/actionview/test/template/html-scanner/text_node_test.rb
diff --git a/actionpack/test/template/html-scanner/tokenizer_test.rb b/actionview/test/template/html-scanner/tokenizer_test.rb
index 1d59de23b6..1d59de23b6 100644
--- a/actionpack/test/template/html-scanner/tokenizer_test.rb
+++ b/actionview/test/template/html-scanner/tokenizer_test.rb
diff --git a/actionpack/test/template/javascript_helper_test.rb b/actionview/test/template/javascript_helper_test.rb
index de6a6eaab3..de6a6eaab3 100644
--- a/actionpack/test/template/javascript_helper_test.rb
+++ b/actionview/test/template/javascript_helper_test.rb
diff --git a/actionpack/test/template/log_subscriber_test.rb b/actionview/test/template/log_subscriber_test.rb
index 7f4c84929f..7f4c84929f 100644
--- a/actionpack/test/template/log_subscriber_test.rb
+++ b/actionview/test/template/log_subscriber_test.rb
diff --git a/actionpack/test/template/lookup_context_test.rb b/actionview/test/template/lookup_context_test.rb
index 073bd14783..073bd14783 100644
--- a/actionpack/test/template/lookup_context_test.rb
+++ b/actionview/test/template/lookup_context_test.rb
diff --git a/actionpack/test/template/number_helper_test.rb b/actionview/test/template/number_helper_test.rb
index 6e640889d2..6e640889d2 100644
--- a/actionpack/test/template/number_helper_test.rb
+++ b/actionview/test/template/number_helper_test.rb
diff --git a/actionpack/test/template/output_buffer_test.rb b/actionview/test/template/output_buffer_test.rb
index eb0df3d1ab..eb0df3d1ab 100644
--- a/actionpack/test/template/output_buffer_test.rb
+++ b/actionview/test/template/output_buffer_test.rb
diff --git a/actionpack/test/template/output_safety_helper_test.rb b/actionview/test/template/output_safety_helper_test.rb
index 76c71c9e6d..76c71c9e6d 100644
--- a/actionpack/test/template/output_safety_helper_test.rb
+++ b/actionview/test/template/output_safety_helper_test.rb
diff --git a/actionpack/test/template/record_identifier_test.rb b/actionview/test/template/record_identifier_test.rb
index 22038110a5..22038110a5 100644
--- a/actionpack/test/template/record_identifier_test.rb
+++ b/actionview/test/template/record_identifier_test.rb
diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionview/test/template/record_tag_helper_test.rb
index ab84bccb56..ab84bccb56 100644
--- a/actionpack/test/template/record_tag_helper_test.rb
+++ b/actionview/test/template/record_tag_helper_test.rb
diff --git a/actionpack/test/template/render_test.rb b/actionview/test/template/render_test.rb
index 81f3391fcd..8cffe73cce 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionview/test/template/render_test.rb
@@ -376,6 +376,7 @@ module RenderTestCases
def test_render_ignores_templates_with_malformed_template_handlers
ActiveSupport::Deprecation.silence do
%w(malformed malformed.erb malformed.html.erb malformed.en.html.erb).each do |name|
+ assert File.exists?(File.expand_path("#{FIXTURE_LOAD_PATH}/test/malformed/#{name}~")), "Malformed file (#{name}~) which should be ignored does not exists"
assert_raises(ActionView::MissingTemplate) { @view.render(:file => "test/malformed/#{name}") }
end
end
diff --git a/actionpack/test/template/resolver_patterns_test.rb b/actionview/test/template/resolver_patterns_test.rb
index 97b1bad055..97b1bad055 100644
--- a/actionpack/test/template/resolver_patterns_test.rb
+++ b/actionview/test/template/resolver_patterns_test.rb
diff --git a/actionpack/test/template/sanitize_helper_test.rb b/actionview/test/template/sanitize_helper_test.rb
index 12d5260a9d..12d5260a9d 100644
--- a/actionpack/test/template/sanitize_helper_test.rb
+++ b/actionview/test/template/sanitize_helper_test.rb
diff --git a/actionpack/test/template/streaming_render_test.rb b/actionview/test/template/streaming_render_test.rb
index 520bf3a824..8a24d78e74 100644
--- a/actionpack/test/template/streaming_render_test.rb
+++ b/actionview/test/template/streaming_render_test.rb
@@ -1,6 +1,5 @@
# encoding: utf-8
require 'abstract_unit'
-require 'controller/fake_models'
class TestController < ActionController::Base
end
diff --git a/actionpack/test/template/tag_helper_test.rb b/actionview/test/template/tag_helper_test.rb
index 802da5d566..802da5d566 100644
--- a/actionpack/test/template/tag_helper_test.rb
+++ b/actionview/test/template/tag_helper_test.rb
diff --git a/actionpack/test/template/template_error_test.rb b/actionview/test/template/template_error_test.rb
index 91424daeed..91424daeed 100644
--- a/actionpack/test/template/template_error_test.rb
+++ b/actionview/test/template/template_error_test.rb
diff --git a/actionpack/test/template/template_test.rb b/actionview/test/template/template_test.rb
index c94508d678..c94508d678 100644
--- a/actionpack/test/template/template_test.rb
+++ b/actionview/test/template/template_test.rb
diff --git a/actionpack/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb
index acd002ce73..4ee0930341 100644
--- a/actionpack/test/template/test_case_test.rb
+++ b/actionview/test/template/test_case_test.rb
@@ -1,5 +1,4 @@
require 'abstract_unit'
-require 'controller/fake_controllers'
module ActionView
diff --git a/actionpack/test/template/test_test.rb b/actionview/test/template/test_test.rb
index 108a674d95..108a674d95 100644
--- a/actionpack/test/template/test_test.rb
+++ b/actionview/test/template/test_test.rb
diff --git a/actionpack/test/template/testing/fixture_resolver_test.rb b/actionview/test/template/testing/fixture_resolver_test.rb
index 9649f349cb..9649f349cb 100644
--- a/actionpack/test/template/testing/fixture_resolver_test.rb
+++ b/actionview/test/template/testing/fixture_resolver_test.rb
diff --git a/actionpack/test/template/testing/null_resolver_test.rb b/actionview/test/template/testing/null_resolver_test.rb
index 55ec36e753..55ec36e753 100644
--- a/actionpack/test/template/testing/null_resolver_test.rb
+++ b/actionview/test/template/testing/null_resolver_test.rb
diff --git a/actionpack/test/template/text_helper_test.rb b/actionview/test/template/text_helper_test.rb
index 1b2234f4e2..1b2234f4e2 100644
--- a/actionpack/test/template/text_helper_test.rb
+++ b/actionview/test/template/text_helper_test.rb
diff --git a/actionpack/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb
index d496dbb35e..d496dbb35e 100644
--- a/actionpack/test/template/translation_helper_test.rb
+++ b/actionview/test/template/translation_helper_test.rb
diff --git a/actionpack/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb
index eb4349015a..8373d7f992 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionview/test/template/url_helper_test.rb
@@ -1,6 +1,5 @@
# encoding: utf-8
require 'abstract_unit'
-require 'controller/fake_controllers'
class UrlHelperTest < ActiveSupport::TestCase
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md
index 6fc34ecd60..0568e5d545 100644
--- a/activemodel/CHANGELOG.md
+++ b/activemodel/CHANGELOG.md
@@ -1,3 +1,12 @@
+* `inclusion` / `exclusion` validations with ranges will only use the faster
+ `Range#cover` for numerical ranges, and the more accurate `Range#include?`
+ for non-numerical ones.
+
+ Fixes range validations like `:a..:f` that used to pass with values like `:be`.
+ Fixes #10593
+
+ *Charles Bergeron*
+
* Fix regression in has_secure_password. When a password is set, but a
confirmation is an empty string, it would incorrectly save.
diff --git a/activemodel/Rakefile b/activemodel/Rakefile
index 45d1587ed6..f72b949c64 100644
--- a/activemodel/Rakefile
+++ b/activemodel/Rakefile
@@ -28,7 +28,7 @@ Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end
-desc "Release to gemcutter"
+desc "Release to rubygems"
task :release => :package do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
diff --git a/activemodel/examples/validations.rb b/activemodel/examples/validations.rb
index a56ec4db39..2c5cc11f49 100644
--- a/activemodel/examples/validations.rb
+++ b/activemodel/examples/validations.rb
@@ -4,7 +4,7 @@ class Person
include ActiveModel::Conversion
include ActiveModel::Validations
- validates_presence_of :name
+ validates :name, presence: true
attr_accessor :name
diff --git a/activemodel/lib/active_model.rb b/activemodel/lib/active_model.rb
index 3bd5531356..ef4f2514be 100644
--- a/activemodel/lib/active_model.rb
+++ b/activemodel/lib/active_model.rb
@@ -37,7 +37,6 @@ module ActiveModel
autoload :ForbiddenAttributesProtection
autoload :Lint
autoload :Model
- autoload :DeprecatedMassAssignmentSecurity
autoload :Name, 'active_model/naming'
autoload :Naming
autoload :SecurePassword
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index 98cde8ba59..986a7ade81 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -388,14 +388,6 @@ module ActiveModel
AttributeMethodMatch = Struct.new(:target, :attr_name, :method_name)
def initialize(options = {})
- if options[:prefix] == '' || options[:suffix] == ''
- message = "Specifying an empty prefix/suffix for an attribute method is no longer " \
- "necessary. If the un-prefixed/suffixed version of the method has not been " \
- "defined when `define_attribute_methods` is called, it will be defined " \
- "automatically."
- ActiveSupport::Deprecation.warn message
- end
-
@prefix, @suffix = options.fetch(:prefix, ''), options.fetch(:suffix, '')
@regex = /^(?:#{Regexp.escape(@prefix)})(.*)(?:#{Regexp.escape(@suffix)})$/
@method_missing_target = "#{@prefix}attribute#{@suffix}"
diff --git a/activemodel/lib/active_model/deprecated_mass_assignment_security.rb b/activemodel/lib/active_model/deprecated_mass_assignment_security.rb
deleted file mode 100644
index 1f409c87b9..0000000000
--- a/activemodel/lib/active_model/deprecated_mass_assignment_security.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-module ActiveModel
- module DeprecatedMassAssignmentSecurity # :nodoc:
- extend ActiveSupport::Concern
-
- module ClassMethods # :nodoc:
- def attr_protected(*args)
- raise "`attr_protected` is extracted out of Rails into a gem. " \
- "Please use new recommended protection model for params" \
- "(strong_parameters) or add `protected_attributes` to your " \
- "Gemfile to use old one."
- end
-
- def attr_accessible(*args)
- raise "`attr_accessible` is extracted out of Rails into a gem. " \
- "Please use new recommended protection model for params" \
- "(strong_parameters) or add `protected_attributes` to your " \
- "Gemfile to use old one."
- end
- end
- end
-end
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 0d7efab04b..9341f689de 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -289,7 +289,7 @@ module ActiveModel
# # => NameIsInvalid: name is invalid
#
# person.errors.messages # => {}
- def add(attribute, message = nil, options = {})
+ def add(attribute, message = :invalid, options = {})
message = normalize_message(attribute, message, options)
if exception = options[:strict]
exception = ActiveModel::StrictValidationFailed if exception == true
@@ -331,7 +331,7 @@ module ActiveModel
#
# person.errors.add :name, :blank
# person.errors.added? :name, :blank # => true
- def added?(attribute, message = nil, options = {})
+ def added?(attribute, message = :invalid, options = {})
message = normalize_message(attribute, message, options)
self[attribute].include? message
end
@@ -437,8 +437,6 @@ module ActiveModel
private
def normalize_message(attribute, message, options)
- message ||= :invalid
-
case message
when Symbol
generate_message(attribute, message, options.except(*CALLBACKS_OPTIONS))
diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb
index e553590671..7156f1bb30 100644
--- a/activemodel/lib/active_model/secure_password.rb
+++ b/activemodel/lib/active_model/secure_password.rb
@@ -15,7 +15,7 @@ module ActiveModel
# argument. You can add more validations by hand if need be.
#
# If you don't need the confirmation validation, just don't set any
- # value to the password_confirmation attribute and the the validation
+ # value to the password_confirmation attribute and the validation
# will not be triggered.
#
# You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use #has_secure_password:
diff --git a/activemodel/lib/active_model/validations/clusivity.rb b/activemodel/lib/active_model/validations/clusivity.rb
index 49df98d6c1..c5aacb010a 100644
--- a/activemodel/lib/active_model/validations/clusivity.rb
+++ b/activemodel/lib/active_model/validations/clusivity.rb
@@ -31,10 +31,11 @@ module ActiveModel
end
# In Ruby 1.9 <tt>Range#include?</tt> on non-numeric ranges checks all possible values in the
- # range for equality, so it may be slow for large ranges. The new <tt>Range#cover?</tt>
- # uses the previous logic of comparing a value with the range endpoints.
+ # range for equality, which is slower but more accurate. <tt>Range#cover?</tt> uses
+ # the previous logic of comparing a value with the range endpoints, which is fast
+ # but is only accurate on numeric ranges.
def inclusion_method(enumerable)
- enumerable.is_a?(Range) ? :cover? : :include?
+ (enumerable.is_a?(Range) && enumerable.first.is_a?(Numeric)) ? :cover? : :include?
end
end
end
diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb
index 1cfd86efee..24337614c5 100644
--- a/activemodel/lib/active_model/validations/inclusion.rb
+++ b/activemodel/lib/active_model/validations/inclusion.rb
@@ -28,7 +28,7 @@ module ActiveModel
# Configuration options:
# * <tt>:in</tt> - An enumerable object of available items. This can be
# supplied as a proc, lambda or symbol which returns an enumerable. If the
- # enumerable is a range the test is performed with <tt>Range#cover?</tt>,
+ # enumerable is a numerical range the test is performed with <tt>Range#cover?</tt>,
# otherwise with <tt>include?</tt>.
# * <tt>:within</tt> - A synonym(or alias) for <tt>:in</tt>
# * <tt>:message</tt> - Specifies a custom error message (default is: "is
diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb
index 25eb4860e3..e9cb5ccc96 100644
--- a/activemodel/test/cases/attribute_methods_test.rb
+++ b/activemodel/test/cases/attribute_methods_test.rb
@@ -202,17 +202,6 @@ class AttributeMethodsTest < ActiveModel::TestCase
assert_equal 'bar', m.foo_test
end
- test 'explicitly specifying an empty prefix/suffix is deprecated' do
- klass = Class.new(ModelWithAttributes)
-
- assert_deprecated { klass.attribute_method_suffix '' }
- assert_deprecated { klass.attribute_method_prefix '' }
-
- klass.define_attribute_methods(:foo)
-
- assert_equal 'value of foo', klass.new.foo
- end
-
test 'should not interfere with method_missing if the attr has a private/protected method' do
m = ModelWithAttributes2.new
m.attributes = { 'private_method' => '<3', 'protected_method' => 'O_o' }
diff --git a/activemodel/test/cases/deprecated_mass_assignment_security_test.rb b/activemodel/test/cases/deprecated_mass_assignment_security_test.rb
deleted file mode 100644
index c1fe8822cd..0000000000
--- a/activemodel/test/cases/deprecated_mass_assignment_security_test.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'cases/helper'
-require 'models/project'
-
-class DeprecatedMassAssignmentSecurityTest < ActiveModel::TestCase
- def test_attr_accessible_raise_error
- assert_raise RuntimeError, /protected_attributes/ do
- Project.attr_accessible :username
- end
- end
-
- def test_attr_protected_raise_error
- assert_raise RuntimeError, /protected_attributes/ do
- Project.attr_protected :username
- end
- end
-end
diff --git a/activemodel/test/cases/validations/inclusion_validation_test.rb b/activemodel/test/cases/validations/inclusion_validation_test.rb
index ceec9dc256..01a373d85d 100644
--- a/activemodel/test/cases/validations/inclusion_validation_test.rb
+++ b/activemodel/test/cases/validations/inclusion_validation_test.rb
@@ -14,6 +14,7 @@ class InclusionValidationTest < ActiveModel::TestCase
Topic.validates_inclusion_of(:title, in: 'aaa'..'bbb')
assert Topic.new("title" => "bbc", "content" => "abc").invalid?
assert Topic.new("title" => "aa", "content" => "abc").invalid?
+ assert Topic.new("title" => "aaab", "content" => "abc").invalid?
assert Topic.new("title" => "aaa", "content" => "abc").valid?
assert Topic.new("title" => "abc", "content" => "abc").valid?
assert Topic.new("title" => "bbb", "content" => "abc").valid?
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 128d1b3e7f..29853b2228 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,77 @@
+* Apply default scope when joining associations. For example:
+
+ class Post < ActiveRecord::Base
+ default_scope -> { where published: true }
+ end
+
+ class Comment
+ belongs_to :post
+ end
+
+ When calling `Comment.joins(:post)`, we expect to receive only
+ comments on published posts, since that is the default scope for
+ posts.
+
+ Before this change, the default scope from `Post` was not applied,
+ so we'd get comments on unpublished posts.
+
+ *Jon Leighton*
+
+* Remove `activerecord-deprecated_finders` as a dependency
+
+ *Łukasz Strzałkowski*
+
+* Remove Oracle / Sqlserver / Firebird database tasks that were deprecated in 4.0.
+
+ *kennyj*
+
+* `find_each` now returns an `Enumerator` when called without a block, so that it
+ can be chained with other `Enumerable` methods.
+
+ *Ben Woosley*
+
+* `ActiveRecord::Result.each` now returns an `Enumerator` when called without
+ a block, so that it can be chained with other `Enumerable` methods.
+
+ *Ben Woosley*
+
+* Flatten merged join_values before building the joins.
+
+ While joining_values special treatment is given to string values.
+ By flattening the array it ensures that string values are detected
+ as strings and not arrays.
+
+ Fixes #10669.
+
+ *Neeraj Singh and iwiznia*
+
+* Do not load all child records for inverse case.
+
+ currently `post.comments.find(Comment.first.id)` would load all
+ comments for the given post to set the inverse association.
+
+ This has a huge performance penalty. Because if post has 100k
+ records and all these 100k records would be loaded in memory
+ even though the comment id was supplied.
+
+ Fix is to use in-memory records only if loaded? is true. Otherwise
+ load the records using full sql.
+
+ Fixes #10509.
+
+ *Neeraj Singh*
+
+* `inspect` on Active Record model classes does not initiate a
+ new connection. This means that calling `inspect`, when the
+ database is missing, will no longer raise an exception.
+ Fixes #10936.
+
+ Example:
+
+ Author.inspect # => "Author(no database connection)"
+
+ *Yves Senn*
+
* Handle single quotes in PostgreSQL default column values.
Fixes #10881.
@@ -55,7 +129,7 @@
class Tagging < ActiveRecord::Base
end
- *Aaron Peterson*
+ *Aaron Patterson*
* Remove column restrictions for `count`, let the database raise if the SQL is
invalid. The previous behavior was untested and surprising for the user.
@@ -119,7 +193,7 @@
Fixes #10620.
- *Aaron Peterson*
+ *Aaron Patterson*
* Also support extensions in PostgreSQL 9.1. This feature has been supported since 9.1.
diff --git a/activerecord/Rakefile b/activerecord/Rakefile
index 136bb1dfbc..18f03e6562 100644
--- a/activerecord/Rakefile
+++ b/activerecord/Rakefile
@@ -62,7 +62,7 @@ end
(Dir["test/cases/**/*_test.rb"].reject {
|x| x =~ /\/adapters\//
} + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file|
- sh(ruby, "-Itest", file)
+ sh(ruby, '-w' ,"-Itest", file)
end or raise "Failures"
end
@@ -222,7 +222,7 @@ end
# Publishing ------------------------------------------------------
-desc "Release to gemcutter"
+desc "Release to rubygems"
task :release => :package do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
diff --git a/activerecord/activerecord.gemspec b/activerecord/activerecord.gemspec
index 337106cb92..9986ded904 100644
--- a/activerecord/activerecord.gemspec
+++ b/activerecord/activerecord.gemspec
@@ -25,5 +25,4 @@ Gem::Specification.new do |s|
s.add_dependency 'activemodel', version
s.add_dependency 'arel', '~> 4.0.0'
- s.add_dependency 'activerecord-deprecated_finders', '~> 1.0.2'
end
diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb
index ad12f8597f..91697b3c9c 100644
--- a/activerecord/examples/performance.rb
+++ b/activerecord/examples/performance.rb
@@ -5,12 +5,12 @@ require 'benchmark/ips'
TIME = (ENV['BENCHMARK_TIME'] || 20).to_i
RECORDS = (ENV['BENCHMARK_RECORDS'] || TIME*1000).to_i
-conn = { :adapter => 'sqlite3', :database => ':memory:' }
+conn = { adapter: 'sqlite3', database: ':memory:' }
ActiveRecord::Base.establish_connection(conn)
class User < ActiveRecord::Base
- connection.create_table :users, :force => true do |t|
+ connection.create_table :users, force: true do |t|
t.string :name, :email
t.timestamps
end
@@ -19,7 +19,7 @@ class User < ActiveRecord::Base
end
class Exhibit < ActiveRecord::Base
- connection.create_table :exhibits, :force => true do |t|
+ connection.create_table :exhibits, force: true do |t|
t.belongs_to :user
t.string :name
t.text :notes
@@ -77,28 +77,28 @@ today = Date.today
puts "Inserting #{RECORDS} users and exhibits..."
RECORDS.times do
user = User.create(
- :created_at => today,
- :name => ActiveRecord::Faker.name,
- :email => ActiveRecord::Faker.email
+ created_at: today,
+ name: ActiveRecord::Faker.name,
+ email: ActiveRecord::Faker.email
)
Exhibit.create(
- :created_at => today,
- :name => ActiveRecord::Faker.name,
- :user => user,
- :notes => notes
+ created_at: today,
+ name: ActiveRecord::Faker.name,
+ user: user,
+ notes: notes
)
end
Benchmark.ips(TIME) do |x|
ar_obj = Exhibit.find(1)
- attrs = { :name => 'sam' }
- attrs_first = { :name => 'sam' }
- attrs_second = { :name => 'tom' }
+ attrs = { name: 'sam' }
+ attrs_first = { name: 'sam' }
+ attrs_second = { name: 'tom' }
exhibit = {
- :name => ActiveRecord::Faker.name,
- :notes => notes,
- :created_at => Date.today
+ name: ActiveRecord::Faker.name,
+ notes: notes,
+ created_at: Date.today
}
x.report("Model#id") do
diff --git a/activerecord/examples/simple.rb b/activerecord/examples/simple.rb
index c12f746992..4ed5d80eb2 100644
--- a/activerecord/examples/simple.rb
+++ b/activerecord/examples/simple.rb
@@ -1,14 +1,14 @@
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
+require File.expand_path('../../../load_paths', __FILE__)
require 'active_record'
class Person < ActiveRecord::Base
- establish_connection :adapter => 'sqlite3', :database => 'foobar.db'
- connection.create_table table_name, :force => true do |t|
+ establish_connection adapter: 'sqlite3', database: 'foobar.db'
+ connection.create_table table_name, force: true do |t|
t.string :name
end
end
-bob = Person.create!(:name => 'bob')
+bob = Person.create!(name: 'bob')
puts Person.all.inspect
bob.destroy
puts Person.all.inspect
diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb
index 994cacb4f9..00220cbfe6 100644
--- a/activerecord/lib/active_record.rb
+++ b/activerecord/lib/active_record.rb
@@ -25,7 +25,6 @@ require 'active_support'
require 'active_support/rails'
require 'active_model'
require 'arel'
-require 'active_record/deprecated_finders'
require 'active_record/version'
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb
index ee62298793..3fbdf9eb0b 100644
--- a/activerecord/lib/active_record/associations/association.rb
+++ b/activerecord/lib/active_record/associations/association.rb
@@ -122,11 +122,7 @@ module ActiveRecord
# Can be overridden (i.e. in ThroughAssociation) to merge in other scopes (i.e. the
# through association's scope)
def target_scope
- all = klass.all
- scope = AssociationRelation.new(klass, klass.arel_table, self)
- scope.merge! all
- scope.default_scoped = all.default_scoped?
- scope
+ AssociationRelation.new(klass, klass.arel_table, self).merge!(klass.all)
end
# Loads the \target if needed and returns it.
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index efd7ecb97c..9833822f8f 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -81,7 +81,7 @@ module ActiveRecord
else
if options[:finder_sql]
find_by_scan(*args)
- elsif options[:inverse_of]
+ elsif options[:inverse_of] && loaded?
args = args.flatten
raise RecordNotFound, "Couldn't find #{scope.klass.name} without an ID" if args.blank?
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb
index 7cdb5ba5b3..f836d45d0e 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -33,7 +33,6 @@ module ActiveRecord
def initialize(klass, association) #:nodoc:
@association = association
super klass, klass.arel_table
- self.default_scoped = true
merge! association.scope(nullify: false)
end
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
index b81aecb4e5..e0715d9dd1 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -106,6 +106,8 @@ module ActiveRecord
]
end
+ scope_chain_items += [reflection.klass.send(:build_default_scope)].compact
+
constraint = scope_chain_items.inject(constraint) do |chain, item|
unless item.is_a?(Relation)
item = ActiveRecord::Relation.new(reflection.klass, table).instance_exec(self, &item)
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb
index 82588905c6..d31f7432cd 100644
--- a/activerecord/lib/active_record/associations/preloader/association.rb
+++ b/activerecord/lib/active_record/associations/preloader/association.rb
@@ -98,7 +98,6 @@ module ActiveRecord
def build_scope
scope = klass.unscoped
- scope.default_scoped = true
values = reflection_scope.values
preload_values = preload_scope.values
@@ -113,7 +112,7 @@ module ActiveRecord
scope.where!(klass.table_name => { reflection.type => model.base_class.sti_name })
end
- scope
+ klass.default_scoped.merge(scope)
end
end
end
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb
index 35f29b37a2..bd99997e7f 100644
--- a/activerecord/lib/active_record/associations/through_association.rb
+++ b/activerecord/lib/active_record/associations/through_association.rb
@@ -15,7 +15,7 @@ module ActiveRecord
scope = super
chain[1..-1].each do |reflection|
scope.merge!(
- reflection.klass.all.with_default_scope.
+ reflection.klass.all.
except(:select, :create_with, :includes, :preload, :joins, :eager_load)
)
end
diff --git a/activerecord/lib/active_record/attribute_assignment.rb b/activerecord/lib/active_record/attribute_assignment.rb
index 75377bba57..4f06955406 100644
--- a/activerecord/lib/active_record/attribute_assignment.rb
+++ b/activerecord/lib/active_record/attribute_assignment.rb
@@ -3,7 +3,6 @@ require 'active_model/forbidden_attributes_protection'
module ActiveRecord
module AttributeAssignment
extend ActiveSupport::Concern
- include ActiveModel::DeprecatedMassAssignmentSecurity
include ActiveModel::ForbiddenAttributesProtection
# Allows you to set all the attributes by passing in a hash of attributes with
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 3ac55a0f11..9a1923dec5 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -214,8 +214,8 @@ module ActiveRecord
# its block form to do so yourself:
#
# create_join_table :products, :categories do |t|
- # t.index :products
- # t.index :categories
+ # t.index :product_id
+ # t.index :category_id
# end
#
# ====== Add a backend specific option to the generated SQL (MySQL)
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index ba053700f2..4122444b1e 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -123,6 +123,8 @@ module ActiveRecord
super
elsif abstract_class?
"#{super}(abstract)"
+ elsif !connected?
+ "#{super}(no database connection)"
elsif table_exists?
attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', '
"#{super}(#{attr_list})"
@@ -153,7 +155,7 @@ module ActiveRecord
else
superclass.arel_engine
end
- end
+ end
end
private
diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb
index 3d85898c41..6bee4f38e7 100644
--- a/activerecord/lib/active_record/querying.rb
+++ b/activerecord/lib/active_record/querying.rb
@@ -1,15 +1,16 @@
module ActiveRecord
module Querying
- delegate :find, :take, :take!, :first, :first!, :last, :last!, :exists?, :any?, :many?, :to => :all
- delegate :first_or_create, :first_or_create!, :first_or_initialize, :to => :all
- delegate :find_or_create_by, :find_or_create_by!, :find_or_initialize_by, :to => :all
- delegate :find_by, :find_by!, :to => :all
- delegate :destroy, :destroy_all, :delete, :delete_all, :update, :update_all, :to => :all
- delegate :find_each, :find_in_batches, :to => :all
+ delegate :find, :take, :take!, :first, :first!, :last, :last!, :exists?, :any?, :many?, to: :all
+ delegate :first_or_create, :first_or_create!, :first_or_initialize, to: :all
+ delegate :find_or_create_by, :find_or_create_by!, :find_or_initialize_by, to: :all
+ delegate :find_by, :find_by!, to: :all
+ delegate :destroy, :destroy_all, :delete, :delete_all, :update, :update_all, to: :all
+ delegate :find_each, :find_in_batches, to: :all
delegate :select, :group, :order, :except, :reorder, :limit, :offset, :joins,
:where, :preload, :eager_load, :includes, :from, :lock, :readonly,
- :having, :create_with, :uniq, :distinct, :references, :none, :unscope, :to => :all
- delegate :count, :average, :minimum, :maximum, :sum, :calculate, :pluck, :ids, :to => :all
+ :having, :create_with, :uniq, :distinct, :references, :none, :unscope, to: :all
+ delegate :count, :average, :minimum, :maximum, :sum, :calculate, to: :all
+ delegate :pluck, :ids, to: :all
# Executes a custom SQL query against your database and returns all the results. The results will
# be returned as an array with columns requested encapsulated as attributes of the model you call
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb
index 31a0ace864..afb0be7b74 100644
--- a/activerecord/lib/active_record/railtie.rb
+++ b/activerecord/lib/active_record/railtie.rb
@@ -37,16 +37,21 @@ module ActiveRecord
rake_tasks do
require "active_record/base"
- ActiveRecord::Tasks::DatabaseTasks.env = Rails.env
- ActiveRecord::Tasks::DatabaseTasks.db_dir = Rails.application.config.paths["db"].first
ActiveRecord::Tasks::DatabaseTasks.seed_loader = Rails.application
- ActiveRecord::Tasks::DatabaseTasks.database_configuration = Rails.application.config.database_configuration
- ActiveRecord::Tasks::DatabaseTasks.migrations_paths = Rails.application.paths['db/migrate'].to_a
- ActiveRecord::Tasks::DatabaseTasks.fixtures_path = File.join Rails.root, 'test', 'fixtures'
+ ActiveRecord::Tasks::DatabaseTasks.env = Rails.env
+
+ namespace :db do
+ task :load_config do
+ ActiveRecord::Tasks::DatabaseTasks.db_dir = Rails.application.config.paths["db"].first
+ ActiveRecord::Tasks::DatabaseTasks.database_configuration = Rails.application.config.database_configuration
+ ActiveRecord::Tasks::DatabaseTasks.migrations_paths = Rails.application.paths['db/migrate'].to_a
+ ActiveRecord::Tasks::DatabaseTasks.fixtures_path = File.join Rails.root, 'test', 'fixtures'
- if defined?(APP_RAKEFILE) && engine = Rails::Engine.find(find_engine_path(APP_RAKEFILE))
- if engine.paths['db/migrate'].existent
- ActiveRecord::Tasks::DatabaseTasks.migrations_paths += engine.paths['db/migrate'].to_a
+ if defined?(ENGINE_PATH) && engine = Rails::Engine.find(ENGINE_PATH)
+ if engine.paths['db/migrate'].existent
+ ActiveRecord::Tasks::DatabaseTasks.migrations_paths += engine.paths['db/migrate'].to_a
+ end
+ end
end
end
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index d37471e9ad..e6bfa2a969 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -17,17 +17,14 @@ module ActiveRecord
include FinderMethods, Calculations, SpawnMethods, QueryMethods, Batches, Explain, Delegation
attr_reader :table, :klass, :loaded
- attr_accessor :default_scoped
alias :model :klass
alias :loaded? :loaded
- alias :default_scoped? :default_scoped
def initialize(klass, table, values = {})
- @klass = klass
- @table = table
- @values = values
- @loaded = false
- @default_scoped = false
+ @klass = klass
+ @table = table
+ @values = values
+ @loaded = false
end
def initialize_copy(other)
@@ -313,7 +310,7 @@ module ActiveRecord
stmt.table(table)
stmt.key = table[primary_key]
- if with_default_scope.joins_values.any?
+ if joins_values.any?
@klass.connection.join_to_update(stmt, arel)
else
stmt.take(arel.limit)
@@ -438,7 +435,7 @@ module ActiveRecord
stmt = Arel::DeleteManager.new(arel.engine)
stmt.from(table)
- if with_default_scope.joins_values.any?
+ if joins_values.any?
@klass.connection.join_to_delete(stmt, arel, table[primary_key])
else
stmt.wheres = arel.constraints
@@ -512,12 +509,11 @@ module ActiveRecord
# User.where(name: 'Oscar').where_values_hash
# # => {name: "Oscar"}
def where_values_hash
- scope = with_default_scope
- equalities = scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
+ equalities = where_values.grep(Arel::Nodes::Equality).find_all { |node|
node.left.relation.name == table_name
}
- binds = Hash[scope.bind_values.find_all(&:first).map { |column, v| [column.name, v] }]
+ binds = Hash[bind_values.find_all(&:first).map { |column, v| [column.name, v] }]
binds.merge!(Hash[bind_values.find_all(&:first).map { |column, v| [column.name, v] }])
Hash[equalities.map { |where|
@@ -565,16 +561,6 @@ module ActiveRecord
q.pp(self.to_a)
end
- def with_default_scope #:nodoc:
- if default_scoped? && default_scope = klass.send(:build_default_scope)
- default_scope = default_scope.merge(self)
- default_scope.default_scoped = false
- default_scope
- else
- self
- end
- end
-
# Returns true if relation is blank.
def blank?
to_a.blank?
@@ -594,22 +580,16 @@ module ActiveRecord
private
def exec_queries
- default_scoped = with_default_scope
-
- if default_scoped.equal?(self)
- @records = eager_loading? ? find_with_associations : @klass.find_by_sql(arel, bind_values)
+ @records = eager_loading? ? find_with_associations : @klass.find_by_sql(arel, bind_values)
- preload = preload_values
- preload += includes_values unless eager_loading?
- preload.each do |associations|
- ActiveRecord::Associations::Preloader.new(@records, associations).run
- end
-
- @records.each { |record| record.readonly! } if readonly_value
- else
- @records = default_scoped.to_a
+ preload = preload_values
+ preload += includes_values unless eager_loading?
+ preload.each do |associations|
+ ActiveRecord::Associations::Preloader.new(@records, associations).run
end
+ @records.each { |record| record.readonly! } if readonly_value
+
@loaded = true
@records
end
diff --git a/activerecord/lib/active_record/relation/batches.rb b/activerecord/lib/active_record/relation/batches.rb
index 341769b5c4..fd8496442e 100644
--- a/activerecord/lib/active_record/relation/batches.rb
+++ b/activerecord/lib/active_record/relation/batches.rb
@@ -19,6 +19,13 @@ module ActiveRecord
# person.party_all_night!
# end
#
+ # If you do not provide a block to #find_each, it will return an Enumerator
+ # for chaining with other methods:
+ #
+ # Person.find_each.with_index do |person, index|
+ # person.award_trophy(index + 1)
+ # end
+ #
# ==== Options
# * <tt>:batch_size</tt> - Specifies the size of the batch. Default to 1000.
# * <tt>:start</tt> - Specifies the starting point for the batch processing.
@@ -40,8 +47,12 @@ module ActiveRecord
# NOTE: You can't set the limit either, that's used to control
# the batch sizes.
def find_each(options = {})
- find_in_batches(options) do |records|
- records.each { |record| yield record }
+ if block_given?
+ find_in_batches(options) do |records|
+ records.each { |record| yield record }
+ end
+ else
+ enum_for :find_each, options
end
end
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index 4becf3980d..f2d28db923 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -91,20 +91,14 @@ module ActiveRecord
#
# Person.sum("2 * age")
def calculate(operation, column_name, options = {})
- relation = with_default_scope
-
if column_name.is_a?(Symbol) && attribute_aliases.key?(column_name.to_s)
column_name = attribute_aliases[column_name.to_s].to_sym
end
- if relation.equal?(self)
- if has_include?(column_name)
- construct_relation_for_association_calculations.calculate(operation, column_name, options)
- else
- perform_calculation(operation, column_name, options)
- end
+ if has_include?(column_name)
+ construct_relation_for_association_calculations.calculate(operation, column_name, options)
else
- relation.calculate(operation, column_name, options)
+ perform_calculation(operation, column_name, options)
end
end
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 3ea3c33fcc..bad5886cde 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -32,7 +32,7 @@ module ActiveRecord
# end
#
# ==== Variations of +find+
- #
+ #
# Person.where(name: 'Spartacus', rating: 4)
# # returns a chainable list (which can be empty).
#
@@ -49,7 +49,7 @@ module ActiveRecord
#
# Person.where(name: 'Spartacus', rating: 4).exists?(conditions = :none)
# # returns a boolean indicating if any record with the given conditions exist.
- #
+ #
# Person.where(name: 'Spartacus', rating: 4).select("field1, field2, field3")
# # returns a chainable list of instances with only the mentioned fields.
#
@@ -124,7 +124,7 @@ module ActiveRecord
#
def first(limit = nil)
if limit
- find_first_with_limit(order_values, limit)
+ find_first_with_limit(limit)
else
find_first
end
@@ -211,7 +211,6 @@ module ActiveRecord
relation = relation.where(table[primary_key].eq(conditions)) if conditions != :none
end
- relation = relation.with_default_scope
connection.select_value(relation.arel, "#{name} Exists", relation.bind_values)
end
@@ -354,11 +353,11 @@ module ActiveRecord
if loaded?
@records.first
else
- @first ||= find_first_with_limit(with_default_scope.order_values, 1).first
+ @first ||= find_first_with_limit(1).first
end
end
- def find_first_with_limit(order_values, limit)
+ def find_first_with_limit(limit)
if order_values.empty? && primary_key
order(arel_table[primary_key].asc).limit(limit).to_a
else
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb
index c114ea0c0d..6d047e0331 100644
--- a/activerecord/lib/active_record/relation/merger.rb
+++ b/activerecord/lib/active_record/relation/merger.rb
@@ -42,10 +42,6 @@ module ActiveRecord
attr_reader :relation, :values, :other
def initialize(relation, other)
- if other.default_scoped? && other.klass != relation.klass
- other = other.with_default_scope
- end
-
@relation = relation
@values = other.values
@other = other
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index ca1de2d4dc..05e92bea33 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -795,14 +795,14 @@ module ActiveRecord
# Returns the Arel object associated with the relation.
def arel
- @arel ||= with_default_scope.build_arel
+ @arel ||= build_arel
end
# Like #arel, but ignores the default scope of the model.
def build_arel
arel = Arel::SelectManager.new(table.engine, table)
- build_joins(arel, joins_values) unless joins_values.empty?
+ build_joins(arel, joins_values.flatten) unless joins_values.empty?
collapse_wheres(arel, (where_values - ['']).uniq)
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index de784f9f57..c63ae9c9fb 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -65,7 +65,6 @@ module ActiveRecord
def relation_with(values) # :nodoc:
result = Relation.new(klass, table, values)
- result.default_scoped = default_scoped
result.extend(*extending_values) if extending_values.any?
result
end
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb
index bea195e9b8..6156b3a5ba 100644
--- a/activerecord/lib/active_record/result.rb
+++ b/activerecord/lib/active_record/result.rb
@@ -18,7 +18,11 @@ module ActiveRecord
end
def each
- hash_rows.each { |row| yield row }
+ if block_given?
+ hash_rows.each { |row| yield row }
+ else
+ hash_rows.to_enum
+ end
end
def to_hash
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index da73bead32..e7d5e6ce84 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -25,22 +25,18 @@ module ActiveRecord
if current_scope
current_scope.clone
else
- scope = relation
- scope.default_scoped = true
- scope
+ default_scoped
end
end
+ def default_scoped # :nodoc:
+ relation.merge(build_default_scope)
+ end
+
# Collects attributes from scopes that should be applied when creating
# an AR instance for the particular class this is called on.
def scope_attributes # :nodoc:
- if current_scope
- current_scope.scope_for_create
- else
- scope = relation
- scope.default_scoped = true
- scope.scope_for_create
- end
+ all.scope_for_create
end
# Are there default attributes associated with this scope?
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb
index 3e8b79c7a0..5ff594fdca 100644
--- a/activerecord/lib/active_record/tasks/database_tasks.rb
+++ b/activerecord/lib/active_record/tasks/database_tasks.rb
@@ -50,10 +50,6 @@ module ActiveRecord
register_task(/postgresql/, ActiveRecord::Tasks::PostgreSQLDatabaseTasks)
register_task(/sqlite/, ActiveRecord::Tasks::SQLiteDatabaseTasks)
- register_task(/firebird/, ActiveRecord::Tasks::FirebirdDatabaseTasks)
- register_task(/sqlserver/, ActiveRecord::Tasks::SqlserverDatabaseTasks)
- register_task(/(oci|oracle)/, ActiveRecord::Tasks::OracleDatabaseTasks)
-
def current_config(options = {})
options.reverse_merge! :env => env
if options.has_key?(:config)
diff --git a/activerecord/lib/active_record/tasks/firebird_database_tasks.rb b/activerecord/lib/active_record/tasks/firebird_database_tasks.rb
deleted file mode 100644
index 98014a38ea..0000000000
--- a/activerecord/lib/active_record/tasks/firebird_database_tasks.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-module ActiveRecord
- module Tasks # :nodoc:
- class FirebirdDatabaseTasks # :nodoc:
- delegate :connection, :establish_connection, to: ActiveRecord::Base
-
- def initialize(configuration)
- ActiveSupport::Deprecation.warn "This database tasks were deprecated, because this tasks should be served by the 3rd party adapter."
- @configuration = configuration
- end
-
- def create
- $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
- end
-
- def drop
- $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
- end
-
- def purge
- establish_connection(:test)
- connection.recreate_database!
- end
-
- def charset
- $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
- end
-
- def structure_dump(filename)
- set_firebird_env(configuration)
- db_string = firebird_db_string(configuration)
- Kernel.system "isql -a #{db_string} > #{filename}"
- end
-
- def structure_load(filename)
- set_firebird_env(configuration)
- db_string = firebird_db_string(configuration)
- Kernel.system "isql -i #{filename} #{db_string}"
- end
-
- private
-
- def set_firebird_env(config)
- ENV['ISC_USER'] = config['username'].to_s if config['username']
- ENV['ISC_PASSWORD'] = config['password'].to_s if config['password']
- end
-
- def firebird_db_string(config)
- FireRuby::Database.db_string_for(config.symbolize_keys)
- end
-
- def configuration
- @configuration
- end
- end
- end
-end
diff --git a/activerecord/lib/active_record/tasks/oracle_database_tasks.rb b/activerecord/lib/active_record/tasks/oracle_database_tasks.rb
deleted file mode 100644
index de3aa50e5e..0000000000
--- a/activerecord/lib/active_record/tasks/oracle_database_tasks.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-module ActiveRecord
- module Tasks # :nodoc:
- class OracleDatabaseTasks # :nodoc:
- delegate :connection, :establish_connection, to: ActiveRecord::Base
-
- def initialize(configuration)
- ActiveSupport::Deprecation.warn "This database tasks were deprecated, because this tasks should be served by the 3rd party adapter."
- @configuration = configuration
- end
-
- def create
- $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
- end
-
- def drop
- $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
- end
-
- def purge
- establish_connection(:test)
- connection.structure_drop.split(";\n\n").each { |ddl| connection.execute(ddl) }
- end
-
- def charset
- $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
- end
-
- def structure_dump(filename)
- establish_connection(configuration)
- File.open(filename, "w:utf-8") { |f| f << connection.structure_dump }
- end
-
- def structure_load(filename)
- establish_connection(configuration)
- IO.read(filename).split(";\n\n").each { |ddl| connection.execute(ddl) }
- end
-
- private
-
- def configuration
- @configuration
- end
- end
- end
-end
diff --git a/activerecord/lib/active_record/tasks/sqlserver_database_tasks.rb b/activerecord/lib/active_record/tasks/sqlserver_database_tasks.rb
deleted file mode 100644
index c718ee03a8..0000000000
--- a/activerecord/lib/active_record/tasks/sqlserver_database_tasks.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-require 'shellwords'
-
-module ActiveRecord
- module Tasks # :nodoc:
- class SqlserverDatabaseTasks # :nodoc:
- delegate :connection, :establish_connection, to: ActiveRecord::Base
-
- def initialize(configuration)
- ActiveSupport::Deprecation.warn "This database tasks were deprecated, because this tasks should be served by the 3rd party adapter."
- @configuration = configuration
- end
-
- def create
- $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
- end
-
- def drop
- $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
- end
-
- def purge
- test = configuration.deep_dup
- test_database = test['database']
- test['database'] = 'master'
- establish_connection(test)
- connection.recreate_database!(test_database)
- end
-
- def charset
- $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
- end
-
- def structure_dump(filename)
- Kernel.system("smoscript -s #{configuration['host']} -d #{configuration['database']} -u #{configuration['username']} -p #{configuration['password']} -f #{filename} -A -U")
- end
-
- def structure_load(filename)
- Kernel.system("sqlcmd -S #{configuration['host']} -d #{configuration['database']} -U #{configuration['username']} -P #{configuration['password']} -i #{filename}")
- end
-
- private
-
- def configuration
- @configuration
- end
- end
- end
-end
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index 77634b40bb..62920d936f 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -245,7 +245,7 @@ module ActiveRecord
if options.is_a?(Hash) && options[:on]
assert_valid_transaction_action(options[:on])
options[:if] = Array(options[:if])
- fire_on = Array(options[:on]).map(&:to_sym)
+ fire_on = Array(options[:on])
options[:if] << "transaction_include_any_action?(#{fire_on})"
end
end
@@ -288,17 +288,17 @@ module ActiveRecord
clear_transaction_record_state
end
- # Call the after_commit callbacks
+ # Call the +after_commit+ callbacks.
#
# Ensure that it is not called if the object was never persisted (failed create),
- # but call it after the commit of a destroyed object
+ # but call it after the commit of a destroyed object.
def committed! #:nodoc:
run_callbacks :commit if destroyed? || persisted?
ensure
clear_transaction_record_state
end
- # Call the after rollback callbacks. The restore_state argument indicates if the record
+ # Call the +after_rollback+ callbacks. The +force_restore_state+ argument indicates if the record
# state should be rolled back to the beginning or just to the last savepoint.
def rolledback!(force_restore_state = false) #:nodoc:
run_callbacks :rollback
@@ -306,7 +306,7 @@ module ActiveRecord
restore_transaction_record_state(force_restore_state)
end
- # Add the record to the current transaction so that the :after_rollback and :after_commit callbacks
+ # Add the record to the current transaction so that the +after_rollback+ and +after_commit+ callbacks
# can be called.
def add_to_transaction
if self.class.connection.add_transaction_record(self)
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 1cfaf552af..846ef05c7d 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -554,9 +554,9 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert_equal 2, posts.size
count = ActiveSupport::Deprecation.silence do
- Post.count(:include => [ :author, :comments ], :limit => 2, :conditions => [ "authors.name = ?", 'David' ])
+ Post.includes(:author, :comments).limit(2).references(:author).where("authors.name = ?", 'David').count
end
- assert_equal count, posts.size
+ assert_equal posts.size, count
end
def test_eager_with_has_many_and_limit_and_high_offset
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 168ce13097..8f5e18b863 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -176,6 +176,16 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_raise(ActiveRecord::SubclassNotFound) { firm.companies.build(:type => "Account") }
end
+ test "building the association with an array" do
+ speedometer = Speedometer.new(speedometer_id: "a")
+ data = [{name: "first"}, {name: "second"}]
+ speedometer.minivans.build(data)
+
+ assert_equal 2, speedometer.minivans.size
+ assert speedometer.save
+ assert_equal ["first", "second"], speedometer.reload.minivans.map(&:name)
+ end
+
def test_association_keys_bypass_attribute_protection
car = Car.create(:name => 'honda')
@@ -1326,6 +1336,33 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [companies(:second_client).id, companies(:first_client).id], companies(:first_firm).clients_ordered_by_name_ids
end
+ def test_get_ids_for_association_on_new_record_does_not_try_to_find_records
+ Company.columns # Load schema information so we don't query below
+ Contract.columns # if running just this test.
+
+ company = Company.new
+ assert_queries(0) do
+ company.contract_ids
+ end
+
+ assert_equal [], company.contract_ids
+ end
+
+ def test_set_ids_for_association_on_new_record_applies_association_correctly
+ contract_a = Contract.create!
+ contract_b = Contract.create!
+ Contract.create! # another contract
+ company = Company.new(:name => "Some Company")
+
+ company.contract_ids = [contract_a.id, contract_b.id]
+ assert_equal [contract_a.id, contract_b.id], company.contract_ids
+ assert_equal [contract_a, contract_b], company.contracts
+
+ company.save!
+ assert_equal company, contract_a.reload.company
+ assert_equal company, contract_b.reload.company
+ end
+
def test_assign_ids_ignoring_blanks
firm = Firm.create!(:name => 'Apple')
firm.client_ids = [companies(:first_client).id, nil, companies(:second_client).id, '']
diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb
index 9baf94399a..de47a576c6 100644
--- a/activerecord/test/cases/associations/inner_join_association_test.rb
+++ b/activerecord/test/cases/associations/inner_join_association_test.rb
@@ -104,4 +104,12 @@ class InnerJoinAssociationTest < ActiveRecord::TestCase
assert !posts(:welcome).tags.empty?
assert Post.joins(:misc_tags).where(:id => posts(:welcome).id).empty?
end
+
+ test "the default scope of the target is applied when joining associations" do
+ author = Author.create! name: "Jon"
+ author.categorizations.create!
+ author.categorizations.create! special: true
+
+ assert_equal [author], Author.where(id: author).joins(:special_categorizations)
+ end
end
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb
index b1f0be3204..71cf1237e8 100644
--- a/activerecord/test/cases/associations/inverse_associations_test.rb
+++ b/activerecord/test/cases/associations/inverse_associations_test.rb
@@ -401,10 +401,22 @@ class InverseHasManyTests < ActiveRecord::TestCase
assert_equal man.name, man.interests.find(interest.id).man.name, "The name of the man should match after the child name is changed"
end
+ def test_find_on_child_instance_with_id_should_not_load_all_child_records
+ man = Man.create!
+ interest = Interest.create!(man: man)
+
+ man.interests.find(interest.id)
+ refute man.interests.loaded?
+ end
+
def test_raise_record_not_found_error_when_invalid_ids_are_passed
+ # delete all interest records to ensure that hard coded invalid_id(s)
+ # are indeed invalid.
+ Interest.delete_all
+
man = Man.create!
- invalid_id = 2394823094892348920348523452345
+ invalid_id = 245324523
assert_raise(ActiveRecord::RecordNotFound) { man.interests.find(invalid_id) }
invalid_ids = [8432342, 2390102913, 2453245234523452]
diff --git a/activerecord/test/cases/batches_test.rb b/activerecord/test/cases/batches_test.rb
index 90c5e91b4a..38c2560d69 100644
--- a/activerecord/test/cases/batches_test.rb
+++ b/activerecord/test/cases/batches_test.rb
@@ -26,6 +26,24 @@ class EachTest < ActiveRecord::TestCase
end
end
+ def test_each_should_return_an_enumerator_if_no_block_is_present
+ assert_queries(1) do
+ Post.find_each(:batch_size => 100000).with_index do |post, index|
+ assert_kind_of Post, post
+ assert_kind_of Integer, index
+ end
+ end
+ end
+
+ def test_each_enumerator_should_execute_one_query_per_batch
+ assert_queries(@total + 1) do
+ Post.find_each(:batch_size => 1).with_index do |post, index|
+ assert_kind_of Post, post
+ assert_kind_of Integer, index
+ end
+ end
+ end
+
def test_each_should_raise_if_select_is_set_without_id
assert_raise(RuntimeError) do
Post.select(:title).find_each(:batch_size => 1) { |post| post }
diff --git a/activerecord/test/cases/counter_cache_test.rb b/activerecord/test/cases/counter_cache_test.rb
index 61f9d4cdae..ee3d8a81c2 100644
--- a/activerecord/test/cases/counter_cache_test.rb
+++ b/activerecord/test/cases/counter_cache_test.rb
@@ -51,14 +51,9 @@ class CounterCacheTest < ActiveRecord::TestCase
end
end
- test 'reset multiple association counters' do
- Topic.increment_counter(:replies_count, @topic.id)
- assert_difference '@topic.reload.replies_count', -1 do
- Topic.reset_counters(@topic.id, :replies, :unique_replies)
- end
-
- Topic.increment_counter(:unique_replies_count, @topic.id)
- assert_difference '@topic.reload.unique_replies_count', -1 do
+ test 'reset multiple counters' do
+ Topic.update_counters @topic.id, replies_count: 1, unique_replies_count: 1
+ assert_difference ['@topic.reload.replies_count', '@topic.reload.unique_replies_count'], -1 do
Topic.reset_counters(@topic.id, :replies, :unique_replies)
end
end
@@ -127,6 +122,12 @@ class CounterCacheTest < ActiveRecord::TestCase
end
end
+ test 'update multiple counters' do
+ assert_difference ['@topic.reload.replies_count', '@topic.reload.unique_replies_count'], 2 do
+ Topic.update_counters @topic.id, replies_count: 2, unique_replies_count: 2
+ end
+ end
+
test "update other counters on parent destroy" do
david, joanna = dog_lovers(:david, :joanna)
joanna = joanna # squelch a warning
diff --git a/activerecord/test/cases/deprecated_dynamic_methods_test.rb b/activerecord/test/cases/deprecated_dynamic_methods_test.rb
deleted file mode 100644
index 8e842d8758..0000000000
--- a/activerecord/test/cases/deprecated_dynamic_methods_test.rb
+++ /dev/null
@@ -1,592 +0,0 @@
-# This file should be deleted when activerecord-deprecated_finders is removed as
-# a dependency.
-#
-# It is kept for now as there is some fairly nuanced behavior in the dynamic
-# finders so it is useful to keep this around to guard against regressions if
-# we need to change the code.
-
-require 'cases/helper'
-require 'models/topic'
-require 'models/reply'
-require 'models/customer'
-require 'models/post'
-require 'models/company'
-require 'models/author'
-require 'models/category'
-require 'models/comment'
-require 'models/person'
-require 'models/reader'
-
-class DeprecatedDynamicMethodsTest < ActiveRecord::TestCase
- fixtures :topics, :customers, :companies, :accounts, :posts, :categories, :categories_posts, :authors, :people, :comments, :readers
-
- def setup
- @deprecation_behavior = ActiveSupport::Deprecation.behavior
- ActiveSupport::Deprecation.behavior = :silence
- end
-
- def teardown
- ActiveSupport::Deprecation.behavior = @deprecation_behavior
- end
-
- def test_find_all_by_one_attribute
- topics = Topic.find_all_by_content("Have a nice day")
- assert_equal 2, topics.size
- assert topics.include?(topics(:first))
-
- assert_equal [], Topic.find_all_by_title("The First Topic!!")
- end
-
- def test_find_all_by_one_attribute_which_is_a_symbol
- topics = Topic.find_all_by_content("Have a nice day".to_sym)
- assert_equal 2, topics.size
- assert topics.include?(topics(:first))
-
- assert_equal [], Topic.find_all_by_title("The First Topic!!")
- end
-
- def test_find_all_by_one_attribute_that_is_an_aggregate
- balance = customers(:david).balance
- assert_kind_of Money, balance
- found_customers = Customer.find_all_by_balance(balance)
- assert_equal 1, found_customers.size
- assert_equal customers(:david), found_customers.first
- end
-
- def test_find_all_by_two_attributes_that_are_both_aggregates
- balance = customers(:david).balance
- address = customers(:david).address
- assert_kind_of Money, balance
- assert_kind_of Address, address
- found_customers = Customer.find_all_by_balance_and_address(balance, address)
- assert_equal 1, found_customers.size
- assert_equal customers(:david), found_customers.first
- end
-
- def test_find_all_by_two_attributes_with_one_being_an_aggregate
- balance = customers(:david).balance
- assert_kind_of Money, balance
- found_customers = Customer.find_all_by_balance_and_name(balance, customers(:david).name)
- assert_equal 1, found_customers.size
- assert_equal customers(:david), found_customers.first
- end
-
- def test_find_all_by_one_attribute_with_options
- topics = Topic.find_all_by_content("Have a nice day", :order => "id DESC")
- assert_equal topics(:first), topics.last
-
- topics = Topic.find_all_by_content("Have a nice day", :order => "id")
- assert_equal topics(:first), topics.first
- end
-
- def test_find_all_by_array_attribute
- assert_equal 2, Topic.find_all_by_title(["The First Topic", "The Second Topic of the day"]).size
- end
-
- def test_find_all_by_boolean_attribute
- topics = Topic.find_all_by_approved(false)
- assert_equal 1, topics.size
- assert topics.include?(topics(:first))
-
- topics = Topic.find_all_by_approved(true)
- assert_equal 3, topics.size
- assert topics.include?(topics(:second))
- end
-
- def test_find_all_by_nil_and_not_nil_attributes
- topics = Topic.find_all_by_last_read_and_author_name nil, "Mary"
- assert_equal 1, topics.size
- assert_equal "Mary", topics[0].author_name
- end
-
- def test_find_or_create_from_one_attribute
- number_of_companies = Company.count
- sig38 = Company.find_or_create_by_name("38signals")
- assert_equal number_of_companies + 1, Company.count
- assert_equal sig38, Company.find_or_create_by_name("38signals")
- assert sig38.persisted?
- end
-
- def test_find_or_create_from_two_attributes
- number_of_topics = Topic.count
- another = Topic.find_or_create_by_title_and_author_name("Another topic","John")
- assert_equal number_of_topics + 1, Topic.count
- assert_equal another, Topic.find_or_create_by_title_and_author_name("Another topic", "John")
- assert another.persisted?
- end
-
- def test_find_or_create_from_one_attribute_bang
- number_of_companies = Company.count
- assert_raises(ActiveRecord::RecordInvalid) { Company.find_or_create_by_name!("") }
- assert_equal number_of_companies, Company.count
- sig38 = Company.find_or_create_by_name!("38signals")
- assert_equal number_of_companies + 1, Company.count
- assert_equal sig38, Company.find_or_create_by_name!("38signals")
- assert sig38.persisted?
- end
-
- def test_find_or_create_from_two_attributes_bang
- number_of_companies = Company.count
- assert_raises(ActiveRecord::RecordInvalid) { Company.find_or_create_by_name_and_firm_id!("", 17) }
- assert_equal number_of_companies, Company.count
- sig38 = Company.find_or_create_by_name_and_firm_id!("38signals", 17)
- assert_equal number_of_companies + 1, Company.count
- assert_equal sig38, Company.find_or_create_by_name_and_firm_id!("38signals", 17)
- assert sig38.persisted?
- assert_equal "38signals", sig38.name
- assert_equal 17, sig38.firm_id
- end
-
- def test_find_or_create_from_two_attributes_with_one_being_an_aggregate
- number_of_customers = Customer.count
- created_customer = Customer.find_or_create_by_balance_and_name(Money.new(123), "Elizabeth")
- assert_equal number_of_customers + 1, Customer.count
- assert_equal created_customer, Customer.find_or_create_by_balance(Money.new(123), "Elizabeth")
- assert created_customer.persisted?
- end
-
- def test_find_or_create_from_one_attribute_and_hash
- number_of_companies = Company.count
- sig38 = Company.find_or_create_by_name({:name => "38signals", :firm_id => 17, :client_of => 23})
- assert_equal number_of_companies + 1, Company.count
- assert_equal sig38, Company.find_or_create_by_name({:name => "38signals", :firm_id => 17, :client_of => 23})
- assert sig38.persisted?
- assert_equal "38signals", sig38.name
- assert_equal 17, sig38.firm_id
- assert_equal 23, sig38.client_of
- end
-
- def test_find_or_create_from_two_attributes_and_hash
- number_of_companies = Company.count
- sig38 = Company.find_or_create_by_name_and_firm_id({:name => "38signals", :firm_id => 17, :client_of => 23})
- assert_equal number_of_companies + 1, Company.count
- assert_equal sig38, Company.find_or_create_by_name_and_firm_id({:name => "38signals", :firm_id => 17, :client_of => 23})
- assert sig38.persisted?
- assert_equal "38signals", sig38.name
- assert_equal 17, sig38.firm_id
- assert_equal 23, sig38.client_of
- end
-
- def test_find_or_create_from_one_aggregate_attribute
- number_of_customers = Customer.count
- created_customer = Customer.find_or_create_by_balance(Money.new(123))
- assert_equal number_of_customers + 1, Customer.count
- assert_equal created_customer, Customer.find_or_create_by_balance(Money.new(123))
- assert created_customer.persisted?
- end
-
- def test_find_or_create_from_one_aggregate_attribute_and_hash
- number_of_customers = Customer.count
- balance = Money.new(123)
- name = "Elizabeth"
- created_customer = Customer.find_or_create_by_balance({:balance => balance, :name => name})
- assert_equal number_of_customers + 1, Customer.count
- assert_equal created_customer, Customer.find_or_create_by_balance({:balance => balance, :name => name})
- assert created_customer.persisted?
- assert_equal balance, created_customer.balance
- assert_equal name, created_customer.name
- end
-
- def test_find_or_initialize_from_one_attribute
- sig38 = Company.find_or_initialize_by_name("38signals")
- assert_equal "38signals", sig38.name
- assert !sig38.persisted?
- end
-
- def test_find_or_initialize_from_one_aggregate_attribute
- new_customer = Customer.find_or_initialize_by_balance(Money.new(123))
- assert_equal 123, new_customer.balance.amount
- assert !new_customer.persisted?
- end
-
- def test_find_or_initialize_from_one_attribute_should_set_attribute
- c = Company.find_or_initialize_by_name_and_rating("Fortune 1000", 1000)
- assert_equal "Fortune 1000", c.name
- assert_equal 1000, c.rating
- assert c.valid?
- assert !c.persisted?
- end
-
- def test_find_or_create_from_one_attribute_should_set_attribute
- c = Company.find_or_create_by_name_and_rating("Fortune 1000", 1000)
- assert_equal "Fortune 1000", c.name
- assert_equal 1000, c.rating
- assert c.valid?
- assert c.persisted?
- end
-
- def test_find_or_initialize_from_one_attribute_should_set_attribute_even_when_set_the_hash
- c = Company.find_or_initialize_by_rating(1000, {:name => "Fortune 1000"})
- assert_equal "Fortune 1000", c.name
- assert_equal 1000, c.rating
- assert c.valid?
- assert !c.persisted?
- end
-
- def test_find_or_create_from_one_attribute_should_set_attribute_even_when_set_the_hash
- c = Company.find_or_create_by_rating(1000, {:name => "Fortune 1000"})
- assert_equal "Fortune 1000", c.name
- assert_equal 1000, c.rating
- assert c.valid?
- assert c.persisted?
- end
-
- def test_find_or_initialize_should_set_attributes_if_given_as_block
- c = Company.find_or_initialize_by_name(:name => "Fortune 1000") { |f| f.rating = 1000 }
- assert_equal "Fortune 1000", c.name
- assert_equal 1000.to_f, c.rating.to_f
- assert c.valid?
- assert !c.persisted?
- end
-
- def test_find_or_create_should_set_attributes_if_given_as_block
- c = Company.find_or_create_by_name(:name => "Fortune 1000") { |f| f.rating = 1000 }
- assert_equal "Fortune 1000", c.name
- assert_equal 1000.to_f, c.rating.to_f
- assert c.valid?
- assert c.persisted?
- end
-
- def test_find_or_create_should_work_with_block_on_first_call
- class << Company
- undef_method(:find_or_create_by_name) if method_defined?(:find_or_create_by_name)
- end
- c = Company.find_or_create_by_name(:name => "Fortune 1000") { |f| f.rating = 1000 }
- assert_equal "Fortune 1000", c.name
- assert_equal 1000.to_f, c.rating.to_f
- assert c.valid?
- assert c.persisted?
- end
-
- def test_find_or_initialize_from_two_attributes
- another = Topic.find_or_initialize_by_title_and_author_name("Another topic","John")
- assert_equal "Another topic", another.title
- assert_equal "John", another.author_name
- assert !another.persisted?
- end
-
- def test_find_or_initialize_from_two_attributes_but_passing_only_one
- assert_raise(ArgumentError) { Topic.find_or_initialize_by_title_and_author_name("Another topic") }
- end
-
- def test_find_or_initialize_from_one_aggregate_attribute_and_one_not
- new_customer = Customer.find_or_initialize_by_balance_and_name(Money.new(123), "Elizabeth")
- assert_equal 123, new_customer.balance.amount
- assert_equal "Elizabeth", new_customer.name
- assert !new_customer.persisted?
- end
-
- def test_find_or_initialize_from_one_attribute_and_hash
- sig38 = Company.find_or_initialize_by_name({:name => "38signals", :firm_id => 17, :client_of => 23})
- assert_equal "38signals", sig38.name
- assert_equal 17, sig38.firm_id
- assert_equal 23, sig38.client_of
- assert !sig38.persisted?
- end
-
- def test_find_or_initialize_from_one_aggregate_attribute_and_hash
- balance = Money.new(123)
- name = "Elizabeth"
- new_customer = Customer.find_or_initialize_by_balance({:balance => balance, :name => name})
- assert_equal balance, new_customer.balance
- assert_equal name, new_customer.name
- assert !new_customer.persisted?
- end
-
- def test_find_last_by_one_attribute
- assert_equal Topic.last, Topic.find_last_by_title(Topic.last.title)
- assert_nil Topic.find_last_by_title("A title with no matches")
- end
-
- def test_find_last_by_invalid_method_syntax
- assert_raise(NoMethodError) { Topic.fail_to_find_last_by_title("The First Topic") }
- assert_raise(NoMethodError) { Topic.find_last_by_title?("The First Topic") }
- end
-
- def test_find_last_by_one_attribute_with_several_options
- assert_equal accounts(:signals37), Account.order('id DESC').where('id != ?', 3).find_last_by_credit_limit(50)
- end
-
- def test_find_last_by_one_missing_attribute
- assert_raise(NoMethodError) { Topic.find_last_by_undertitle("The Last Topic!") }
- end
-
- def test_find_last_by_two_attributes
- topic = Topic.last
- assert_equal topic, Topic.find_last_by_title_and_author_name(topic.title, topic.author_name)
- assert_nil Topic.find_last_by_title_and_author_name(topic.title, "Anonymous")
- end
-
- def test_find_last_with_limit_gives_same_result_when_loaded_and_unloaded
- scope = Topic.limit(2)
- unloaded_last = scope.last
- loaded_last = scope.to_a.last
- assert_equal loaded_last, unloaded_last
- end
-
- def test_find_last_with_limit_and_offset_gives_same_result_when_loaded_and_unloaded
- scope = Topic.offset(2).limit(2)
- unloaded_last = scope.last
- loaded_last = scope.to_a.last
- assert_equal loaded_last, unloaded_last
- end
-
- def test_find_last_with_offset_gives_same_result_when_loaded_and_unloaded
- scope = Topic.offset(3)
- unloaded_last = scope.last
- loaded_last = scope.to_a.last
- assert_equal loaded_last, unloaded_last
- end
-
- def test_find_all_by_nil_attribute
- topics = Topic.find_all_by_last_read nil
- assert_equal 3, topics.size
- assert topics.collect(&:last_read).all?(&:nil?)
- end
-
- def test_forwarding_to_dynamic_finders
- welcome = Post.find(1)
- assert_equal 4, Category.find_all_by_type('SpecialCategory').size
- assert_equal 0, welcome.categories.find_all_by_type('SpecialCategory').size
- assert_equal 2, welcome.categories.find_all_by_type('Category').size
- end
-
- def test_dynamic_find_all_should_respect_association_order
- assert_equal [companies(:second_client), companies(:first_client)], companies(:first_firm).clients_sorted_desc.where("type = 'Client'").to_a
- assert_equal [companies(:second_client), companies(:first_client)], companies(:first_firm).clients_sorted_desc.find_all_by_type('Client')
- end
-
- def test_dynamic_find_all_should_respect_association_limit
- assert_equal 1, companies(:first_firm).limited_clients.where("type = 'Client'").to_a.length
- assert_equal 1, companies(:first_firm).limited_clients.find_all_by_type('Client').length
- end
-
- def test_dynamic_find_all_limit_should_override_association_limit
- assert_equal 2, companies(:first_firm).limited_clients.where("type = 'Client'").limit(9_000).to_a.length
- assert_equal 2, companies(:first_firm).limited_clients.find_all_by_type('Client', :limit => 9_000).length
- end
-
- def test_dynamic_find_last_without_specified_order
- assert_equal companies(:second_client), companies(:first_firm).unsorted_clients.find_last_by_type('Client')
- end
-
- def test_dynamic_find_or_create_from_two_attributes_using_an_association
- author = authors(:david)
- number_of_posts = Post.count
- another = author.posts.find_or_create_by_title_and_body("Another Post", "This is the Body")
- assert_equal number_of_posts + 1, Post.count
- assert_equal another, author.posts.find_or_create_by_title_and_body("Another Post", "This is the Body")
- assert another.persisted?
- end
-
- def test_dynamic_find_all_should_respect_association_order_for_through
- assert_equal [Comment.find(10), Comment.find(7), Comment.find(6), Comment.find(3)], authors(:david).comments_desc.where("comments.type = 'SpecialComment'").to_a
- assert_equal [Comment.find(10), Comment.find(7), Comment.find(6), Comment.find(3)], authors(:david).comments_desc.find_all_by_type('SpecialComment')
- end
-
- def test_dynamic_find_all_should_respect_association_limit_for_through
- assert_equal 1, authors(:david).limited_comments.where("comments.type = 'SpecialComment'").to_a.length
- assert_equal 1, authors(:david).limited_comments.find_all_by_type('SpecialComment').length
- end
-
- def test_dynamic_find_all_order_should_override_association_limit_for_through
- assert_equal 4, authors(:david).limited_comments.where("comments.type = 'SpecialComment'").limit(9_000).to_a.length
- assert_equal 4, authors(:david).limited_comments.find_all_by_type('SpecialComment', :limit => 9_000).length
- end
-
- def test_find_all_include_over_the_same_table_for_through
- assert_equal 2, people(:michael).posts.includes(:people).to_a.length
- end
-
- def test_find_or_create_by_resets_cached_counters
- person = Person.create! :first_name => 'tenderlove'
- post = Post.first
-
- assert_equal [], person.readers
- assert_nil person.readers.find_by_post_id(post.id)
-
- person.readers.find_or_create_by_post_id(post.id)
-
- assert_equal 1, person.readers.count
- assert_equal 1, person.readers.length
- assert_equal post, person.readers.first.post
- assert_equal person, person.readers.first.person
- end
-
- def test_find_or_initialize
- the_client = companies(:first_firm).clients.find_or_initialize_by_name("Yet another client")
- assert_equal companies(:first_firm).id, the_client.firm_id
- assert_equal "Yet another client", the_client.name
- assert !the_client.persisted?
- end
-
- def test_find_or_create_updates_size
- number_of_clients = companies(:first_firm).clients.size
- the_client = companies(:first_firm).clients.find_or_create_by_name("Yet another client")
- assert_equal number_of_clients + 1, companies(:first_firm, :reload).clients.size
- assert_equal the_client, companies(:first_firm).clients.find_or_create_by_name("Yet another client")
- assert_equal number_of_clients + 1, companies(:first_firm, :reload).clients.size
- end
-
- def test_find_or_initialize_updates_collection_size
- number_of_clients = companies(:first_firm).clients_of_firm.size
- companies(:first_firm).clients_of_firm.find_or_initialize_by_name("name" => "Another Client")
- assert_equal number_of_clients + 1, companies(:first_firm).clients_of_firm.size
- end
-
- def test_find_or_initialize_returns_the_instantiated_object
- client = companies(:first_firm).clients_of_firm.find_or_initialize_by_name("name" => "Another Client")
- assert_equal client, companies(:first_firm).clients_of_firm[-1]
- end
-
- def test_find_or_initialize_only_instantiates_a_single_object
- number_of_clients = Client.count
- companies(:first_firm).clients_of_firm.find_or_initialize_by_name("name" => "Another Client").save!
- companies(:first_firm).save!
- assert_equal number_of_clients+1, Client.count
- end
-
- def test_find_or_create_with_hash
- post = authors(:david).posts.find_or_create_by_title(:title => 'Yet another post', :body => 'somebody')
- assert_equal post, authors(:david).posts.find_or_create_by_title(:title => 'Yet another post', :body => 'somebody')
- assert post.persisted?
- end
-
- def test_find_or_create_with_one_attribute_followed_by_hash
- post = authors(:david).posts.find_or_create_by_title('Yet another post', :body => 'somebody')
- assert_equal post, authors(:david).posts.find_or_create_by_title('Yet another post', :body => 'somebody')
- assert post.persisted?
- end
-
- def test_find_or_create_should_work_with_block
- post = authors(:david).posts.find_or_create_by_title('Yet another post') {|p| p.body = 'somebody'}
- assert_equal post, authors(:david).posts.find_or_create_by_title('Yet another post') {|p| p.body = 'somebody'}
- assert post.persisted?
- end
-
- def test_forwarding_to_dynamic_finders_2
- welcome = Post.find(1)
- assert_equal 4, Comment.find_all_by_type('Comment').size
- assert_equal 2, welcome.comments.find_all_by_type('Comment').size
- end
-
- def test_dynamic_find_all_by_attributes
- authors = Author.all
-
- davids = authors.find_all_by_name('David')
- assert_kind_of Array, davids
- assert_equal [authors(:david)], davids
- end
-
- def test_dynamic_find_or_initialize_by_attributes
- authors = Author.all
-
- lifo = authors.find_or_initialize_by_name('Lifo')
- assert_equal "Lifo", lifo.name
- assert !lifo.persisted?
-
- assert_equal authors(:david), authors.find_or_initialize_by_name(:name => 'David')
- end
-
- def test_dynamic_find_or_create_by_attributes
- authors = Author.all
-
- lifo = authors.find_or_create_by_name('Lifo')
- assert_equal "Lifo", lifo.name
- assert lifo.persisted?
-
- assert_equal authors(:david), authors.find_or_create_by_name(:name => 'David')
- end
-
- def test_dynamic_find_or_create_by_attributes_bang
- authors = Author.all
-
- assert_raises(ActiveRecord::RecordInvalid) { authors.find_or_create_by_name!('') }
-
- lifo = authors.find_or_create_by_name!('Lifo')
- assert_equal "Lifo", lifo.name
- assert lifo.persisted?
-
- assert_equal authors(:david), authors.find_or_create_by_name!(:name => 'David')
- end
-
- def test_finder_block
- t = Topic.first
- found = nil
- Topic.find_by_id(t.id) { |f| found = f }
- assert_equal t, found
- end
-
- def test_finder_block_nothing_found
- bad_id = Topic.maximum(:id) + 1
- assert_nil Topic.find_by_id(bad_id) { |f| raise }
- end
-
- def test_find_returns_block_value
- t = Topic.first
- x = Topic.find_by_id(t.id) { |f| "hi mom!" }
- assert_equal "hi mom!", x
- end
-
- def test_dynamic_finder_with_invalid_params
- assert_raise(ArgumentError) { Topic.find_by_title 'No Title', :join => "It should be `joins'" }
- end
-
- def test_find_by_one_attribute_with_order_option
- assert_equal accounts(:signals37), Account.find_by_credit_limit(50, :order => 'id')
- assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :order => 'id DESC')
- end
-
- def test_dynamic_find_by_attributes_should_yield_found_object
- david = authors(:david)
- yielded_value = nil
- Author.find_by_name(david.name) do |author|
- yielded_value = author
- end
- assert_equal david, yielded_value
- end
-end
-
-class DynamicScopeTest < ActiveRecord::TestCase
- fixtures :posts
-
- def setup
- @test_klass = Class.new(Post) do
- def self.name; "Post"; end
- end
- @deprecation_behavior = ActiveSupport::Deprecation.behavior
- ActiveSupport::Deprecation.behavior = :silence
- end
-
- def teardown
- ActiveSupport::Deprecation.behavior = @deprecation_behavior
- end
-
- def test_dynamic_scope
- assert_equal @test_klass.scoped_by_author_id(1).find(1), @test_klass.find(1)
- assert_equal @test_klass.scoped_by_author_id_and_title(1, "Welcome to the weblog").first, @test_klass.all.merge!(:where => { :author_id => 1, :title => "Welcome to the weblog"}).first
- end
-
- def test_dynamic_scope_should_create_methods_after_hitting_method_missing
- assert @test_klass.methods.grep(/scoped_by_type/).blank?
- @test_klass.scoped_by_type(nil)
- assert @test_klass.methods.grep(/scoped_by_type/).present?
- end
-
- def test_dynamic_scope_with_less_number_of_arguments
- assert_raise(ArgumentError){ @test_klass.scoped_by_author_id_and_title(1) }
- end
-end
-
-class DynamicScopeMatchTest < ActiveRecord::TestCase
- def test_scoped_by_no_match
- assert_nil ActiveRecord::DynamicMatchers::Method.match(nil, "not_scoped_at_all")
- end
-
- def test_scoped_by
- model = stub(attribute_aliases: {})
- match = ActiveRecord::DynamicMatchers::Method.match(model, "scoped_by_age_and_sex_and_location")
- assert_not_nil match
- assert_equal %w(age sex location), match.attribute_names
- end
-end
diff --git a/activerecord/test/cases/disconnected_test.rb b/activerecord/test/cases/disconnected_test.rb
index cc2c1f6489..1fecfd077e 100644
--- a/activerecord/test/cases/disconnected_test.rb
+++ b/activerecord/test/cases/disconnected_test.rb
@@ -7,13 +7,14 @@ class TestDisconnectedAdapter < ActiveRecord::TestCase
self.use_transactional_fixtures = false
def setup
+ skip "in-memory database mustn't disconnect" if in_memory_db?
@connection = ActiveRecord::Base.connection
end
def teardown
+ return if in_memory_db?
spec = ActiveRecord::Base.connection_config
ActiveRecord::Base.establish_connection(spec)
- @connection = nil
end
test "can't execute statements while disconnected" do
diff --git a/activerecord/test/cases/finder_respond_to_test.rb b/activerecord/test/cases/finder_respond_to_test.rb
index 9440cd429a..6101eb7b68 100644
--- a/activerecord/test/cases/finder_respond_to_test.rb
+++ b/activerecord/test/cases/finder_respond_to_test.rb
@@ -21,16 +21,6 @@ class FinderRespondToTest < ActiveRecord::TestCase
assert_respond_to Topic, :find_by_title
end
- def test_should_respond_to_find_all_by_one_attribute
- ensure_topic_method_is_not_cached(:find_all_by_title)
- assert_respond_to Topic, :find_all_by_title
- end
-
- def test_should_respond_to_find_all_by_two_attributes
- ensure_topic_method_is_not_cached(:find_all_by_title_and_author_name)
- assert_respond_to Topic, :find_all_by_title_and_author_name
- end
-
def test_should_respond_to_find_by_two_attributes
ensure_topic_method_is_not_cached(:find_by_title_and_author_name)
assert_respond_to Topic, :find_by_title_and_author_name
@@ -41,36 +31,6 @@ class FinderRespondToTest < ActiveRecord::TestCase
assert_respond_to Topic, :find_by_heading
end
- def test_should_respond_to_find_or_initialize_from_one_attribute
- ensure_topic_method_is_not_cached(:find_or_initialize_by_title)
- assert_respond_to Topic, :find_or_initialize_by_title
- end
-
- def test_should_respond_to_find_or_initialize_from_two_attributes
- ensure_topic_method_is_not_cached(:find_or_initialize_by_title_and_author_name)
- assert_respond_to Topic, :find_or_initialize_by_title_and_author_name
- end
-
- def test_should_respond_to_find_or_create_from_one_attribute
- ensure_topic_method_is_not_cached(:find_or_create_by_title)
- assert_respond_to Topic, :find_or_create_by_title
- end
-
- def test_should_respond_to_find_or_create_from_two_attributes
- ensure_topic_method_is_not_cached(:find_or_create_by_title_and_author_name)
- assert_respond_to Topic, :find_or_create_by_title_and_author_name
- end
-
- def test_should_respond_to_find_or_create_from_one_attribute_bang
- ensure_topic_method_is_not_cached(:find_or_create_by_title!)
- assert_respond_to Topic, :find_or_create_by_title!
- end
-
- def test_should_respond_to_find_or_create_from_two_attributes_bang
- ensure_topic_method_is_not_cached(:find_or_create_by_title_and_author_name!)
- assert_respond_to Topic, :find_or_create_by_title_and_author_name!
- end
-
def test_should_not_respond_to_find_by_one_missing_attribute
assert !Topic.respond_to?(:find_by_undertitle)
end
diff --git a/activerecord/test/cases/invalid_connection_test.rb b/activerecord/test/cases/invalid_connection_test.rb
new file mode 100644
index 0000000000..f2d8f18ec7
--- /dev/null
+++ b/activerecord/test/cases/invalid_connection_test.rb
@@ -0,0 +1,22 @@
+require "cases/helper"
+
+class TestAdapterWithInvalidConnection < ActiveRecord::TestCase
+ self.use_transactional_fixtures = false
+
+ class Bird < ActiveRecord::Base
+ end
+
+ def setup
+ # Can't just use current adapter; sqlite3 will create a database
+ # file on the fly.
+ Bird.establish_connection adapter: 'mysql', database: 'i_do_not_exist'
+ end
+
+ def teardown
+ Bird.remove_connection
+ end
+
+ test "inspect on Model class does not raise" do
+ assert_equal "#{Bird.name}(no database connection)", Bird.inspect
+ end
+end
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb
index 55fd068d37..693b36f35c 100644
--- a/activerecord/test/cases/relation_test.rb
+++ b/activerecord/test/cases/relation_test.rb
@@ -176,7 +176,7 @@ module ActiveRecord
assert_equal ['foo = bar'], relation.where_values
end
- def test_relation_merging_with_merged_joins
+ def test_relation_merging_with_merged_joins_as_symbols
special_comments_with_ratings = SpecialComment.joins(:ratings)
posts_with_special_comments_with_ratings = Post.group("posts.id").joins(:special_comments).merge(special_comments_with_ratings)
assert_equal 3, authors(:david).posts.merge(posts_with_special_comments_with_ratings).count.length
@@ -190,6 +190,13 @@ module ActiveRecord
assert_equal false, post.respond_to?(:title), "post should not respond_to?(:body) since invoking it raises exception"
end
+ def test_relation_merging_with_merged_joins_as_strings
+ join_string = "LEFT OUTER JOIN #{Rating.quoted_table_name} ON #{SpecialComment.quoted_table_name}.id = #{Rating.quoted_table_name}.comment_id"
+ special_comments_with_ratings = SpecialComment.joins join_string
+ posts_with_special_comments_with_ratings = Post.group("posts.id").joins(:special_comments).merge(special_comments_with_ratings)
+ assert_equal 3, authors(:david).posts.merge(posts_with_special_comments_with_ratings).count.length
+ end
+
end
class RelationMutationTest < ActiveSupport::TestCase
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index e746ca2805..e26cecde20 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -368,7 +368,7 @@ class RelationTest < ActiveRecord::TestCase
def test_respond_to_dynamic_finders
relation = Topic.all
- ["find_by_title", "find_by_title_and_author_name", "find_or_create_by_title", "find_or_initialize_by_title_and_author_name"].each do |method|
+ ["find_by_title", "find_by_title_and_author_name"].each do |method|
assert_respond_to relation, method, "Topic.all should respond to #{method.inspect}"
end
end
diff --git a/activerecord/test/cases/result_test.rb b/activerecord/test/cases/result_test.rb
new file mode 100644
index 0000000000..b6c583dbf5
--- /dev/null
+++ b/activerecord/test/cases/result_test.rb
@@ -0,0 +1,32 @@
+require "cases/helper"
+
+module ActiveRecord
+ class ResultTest < ActiveRecord::TestCase
+ def result
+ Result.new(['col_1', 'col_2'], [
+ ['row 1 col 1', 'row 1 col 2'],
+ ['row 2 col 1', 'row 2 col 2']
+ ])
+ end
+
+ def test_to_hash_returns_row_hashes
+ assert_equal [
+ {'col_1' => 'row 1 col 1', 'col_2' => 'row 1 col 2'},
+ {'col_1' => 'row 2 col 1', 'col_2' => 'row 2 col 2'}
+ ], result.to_hash
+ end
+
+ def test_each_with_block_returns_row_hashes
+ result.each do |row|
+ assert_equal ['col_1', 'col_2'], row.keys
+ end
+ end
+
+ def test_each_without_block_returns_an_enumerator
+ result.each.with_index do |row, index|
+ assert_equal ['col_1', 'col_2'], row.keys
+ assert_kind_of Integer, index
+ end
+ end
+ end
+end
diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb
index 0f69443839..5c7751b445 100644
--- a/activerecord/test/cases/scoping/default_scoping_test.rb
+++ b/activerecord/test/cases/scoping/default_scoping_test.rb
@@ -153,9 +153,8 @@ class DefaultScopingTest < ActiveRecord::TestCase
end
def test_order_to_unscope_reordering
- expected = DeveloperOrderedBySalary.all.collect { |dev| [dev.name, dev.id] }
- received = DeveloperOrderedBySalary.order('salary DESC, name ASC').reverse_order.unscope(:order).collect { |dev| [dev.name, dev.id] }
- assert_equal expected, received
+ scope = DeveloperOrderedBySalary.order('salary DESC, name ASC').reverse_order.unscope(:order)
+ assert !(scope.to_sql =~ /order/i)
end
def test_unscope_reverse_order
diff --git a/activerecord/test/cases/tasks/firebird_rake_test.rb b/activerecord/test/cases/tasks/firebird_rake_test.rb
deleted file mode 100644
index c54989ae34..0000000000
--- a/activerecord/test/cases/tasks/firebird_rake_test.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-require 'cases/helper'
-
-unless defined?(FireRuby::Database)
-module FireRuby
- module Database; end
-end
-end
-
-module ActiveRecord
- module FirebirdSetupper
- def setup
- @database = 'db.firebird'
- @connection = stub :connection
- @configuration = {
- 'adapter' => 'firebird',
- 'database' => @database
- }
- ActiveRecord::Base.stubs(:connection).returns(@connection)
- ActiveRecord::Base.stubs(:establish_connection).returns(true)
-
- @tasks = Class.new(ActiveRecord::Tasks::FirebirdDatabaseTasks) do
- def initialize(configuration)
- ActiveSupport::Deprecation.silence { super }
- end
- end
- ActiveRecord::Tasks::DatabaseTasks.stubs(:class_for_adapter).returns(@tasks) unless defined? ActiveRecord::ConnectionAdapters::FirebirdAdapter
- end
- end
-
- class FirebirdDBCreateTest < ActiveRecord::TestCase
- include FirebirdSetupper
-
- def test_db_retrieves_create
- message = capture(:stderr) do
- ActiveRecord::Tasks::DatabaseTasks.create @configuration
- end
- assert_match(/not supported/, message)
- end
- end
-
- class FirebirdDBDropTest < ActiveRecord::TestCase
- include FirebirdSetupper
-
- def test_db_retrieves_drop
- message = capture(:stderr) do
- ActiveRecord::Tasks::DatabaseTasks.drop @configuration
- end
- assert_match(/not supported/, message)
- end
- end
-
- class FirebirdDBCharsetAndCollationTest < ActiveRecord::TestCase
- include FirebirdSetupper
-
- def test_db_retrieves_collation
- assert_raise NoMethodError do
- ActiveRecord::Tasks::DatabaseTasks.collation @configuration
- end
- end
-
- def test_db_retrieves_charset
- message = capture(:stderr) do
- ActiveRecord::Tasks::DatabaseTasks.charset @configuration
- end
- assert_match(/not supported/, message)
- end
- end
-
- class FirebirdStructureDumpTest < ActiveRecord::TestCase
- include FirebirdSetupper
-
- def setup
- super
- FireRuby::Database.stubs(:db_string_for).returns(@database)
- end
-
- def test_structure_dump
- filename = "filebird.sql"
- Kernel.expects(:system).with("isql -a #{@database} > #{filename}")
-
- ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename)
- end
- end
-
- class FirebirdStructureLoadTest < ActiveRecord::TestCase
- include FirebirdSetupper
-
- def setup
- super
- FireRuby::Database.stubs(:db_string_for).returns(@database)
- end
-
- def test_structure_load
- filename = "firebird.sql"
- Kernel.expects(:system).with("isql -i #{filename} #{@database}")
-
- ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename)
- end
- end
-end
diff --git a/activerecord/test/cases/tasks/oracle_rake_test.rb b/activerecord/test/cases/tasks/oracle_rake_test.rb
deleted file mode 100644
index 5f840febbc..0000000000
--- a/activerecord/test/cases/tasks/oracle_rake_test.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-require 'cases/helper'
-
-module ActiveRecord
- module OracleSetupper
- def setup
- @database = 'db.oracle'
- @connection = stub :connection
- @configuration = {
- 'adapter' => 'oracle',
- 'database' => @database
- }
- ActiveRecord::Base.stubs(:connection).returns(@connection)
- ActiveRecord::Base.stubs(:establish_connection).returns(true)
-
- @tasks = Class.new(ActiveRecord::Tasks::OracleDatabaseTasks) do
- def initialize(configuration)
- ActiveSupport::Deprecation.silence { super }
- end
- end
- ActiveRecord::Tasks::DatabaseTasks.stubs(:class_for_adapter).returns(@tasks) unless defined? ActiveRecord::ConnectionAdapters::OracleAdapter
- end
- end
-
- class OracleDBCreateTest < ActiveRecord::TestCase
- include OracleSetupper
-
- def test_db_retrieves_create
- message = capture(:stderr) do
- ActiveRecord::Tasks::DatabaseTasks.create @configuration
- end
- assert_match(/not supported/, message)
- end
- end
-
- class OracleDBDropTest < ActiveRecord::TestCase
- include OracleSetupper
-
- def test_db_retrieves_drop
- message = capture(:stderr) do
- ActiveRecord::Tasks::DatabaseTasks.drop @configuration
- end
- assert_match(/not supported/, message)
- end
- end
-
- class OracleDBCharsetAndCollationTest < ActiveRecord::TestCase
- include OracleSetupper
-
- def test_db_retrieves_collation
- assert_raise NoMethodError do
- ActiveRecord::Tasks::DatabaseTasks.collation @configuration
- end
- end
-
- def test_db_retrieves_charset
- message = capture(:stderr) do
- ActiveRecord::Tasks::DatabaseTasks.charset @configuration
- end
- assert_match(/not supported/, message)
- end
- end
-
- class OracleStructureDumpTest < ActiveRecord::TestCase
- include OracleSetupper
-
- def setup
- super
- @connection.stubs(:structure_dump).returns("select sysdate from dual;")
- end
-
- def test_structure_dump
- filename = "oracle.sql"
- ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename)
- assert File.exists?(filename)
- ensure
- FileUtils.rm_f(filename)
- end
- end
-
- class OracleStructureLoadTest < ActiveRecord::TestCase
- include OracleSetupper
-
- def test_structure_load
- filename = "oracle.sql"
-
- open(filename, 'w') { |f| f.puts("select sysdate from dual;") }
- @connection.stubs(:execute).with("select sysdate from dual;\n")
- ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename)
- ensure
- FileUtils.rm_f(filename)
- end
- end
-end
diff --git a/activerecord/test/cases/tasks/sqlserver_rake_test.rb b/activerecord/test/cases/tasks/sqlserver_rake_test.rb
deleted file mode 100644
index 0f1264b8ce..0000000000
--- a/activerecord/test/cases/tasks/sqlserver_rake_test.rb
+++ /dev/null
@@ -1,87 +0,0 @@
-require 'cases/helper'
-
-module ActiveRecord
- module SqlserverSetupper
- def setup
- @database = 'db.sqlserver'
- @connection = stub :connection
- @configuration = {
- 'adapter' => 'sqlserver',
- 'database' => @database,
- 'host' => 'localhost',
- 'username' => 'username',
- 'password' => 'password',
- }
- ActiveRecord::Base.stubs(:connection).returns(@connection)
- ActiveRecord::Base.stubs(:establish_connection).returns(true)
-
- @tasks = Class.new(ActiveRecord::Tasks::SqlserverDatabaseTasks) do
- def initialize(configuration)
- ActiveSupport::Deprecation.silence { super }
- end
- end
- ActiveRecord::Tasks::DatabaseTasks.stubs(:class_for_adapter).returns(@tasks) unless defined? ActiveRecord::ConnectionAdapters::SQLServerAdapter
- end
- end
-
- class SqlserverDBCreateTest < ActiveRecord::TestCase
- include SqlserverSetupper
-
- def test_db_retrieves_create
- message = capture(:stderr) do
- ActiveRecord::Tasks::DatabaseTasks.create @configuration
- end
- assert_match(/not supported/, message)
- end
- end
-
- class SqlserverDBDropTest < ActiveRecord::TestCase
- include SqlserverSetupper
-
- def test_db_retrieves_drop
- message = capture(:stderr) do
- ActiveRecord::Tasks::DatabaseTasks.drop @configuration
- end
- assert_match(/not supported/, message)
- end
- end
-
- class SqlserverDBCharsetAndCollationTest < ActiveRecord::TestCase
- include SqlserverSetupper
-
- def test_db_retrieves_collation
- assert_raise NoMethodError do
- ActiveRecord::Tasks::DatabaseTasks.collation @configuration
- end
- end
-
- def test_db_retrieves_charset
- message = capture(:stderr) do
- ActiveRecord::Tasks::DatabaseTasks.charset @configuration
- end
- assert_match(/not supported/, message)
- end
- end
-
- class SqlserverStructureDumpTest < ActiveRecord::TestCase
- include SqlserverSetupper
-
- def test_structure_dump
- filename = "sqlserver.sql"
- Kernel.expects(:system).with("smoscript -s localhost -d #{@database} -u username -p password -f #{filename} -A -U")
-
- ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename)
- end
- end
-
- class SqlserverStructureLoadTest < ActiveRecord::TestCase
- include SqlserverSetupper
-
- def test_structure_load
- filename = "sqlserver.sql"
- Kernel.expects(:system).with("sqlcmd -S localhost -d #{@database} -U username -P password -i #{filename}")
-
- ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename)
- end
- end
-end
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index b69333851f..45f71daa08 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,3 +1,10 @@
+* Fix return value from `BacktraceCleaner#noise` when the cleaner is configured
+ with multiple silencers.
+
+ Fixes #11030
+
+ *Mark J. Titorenko*
+
* `HashWithIndifferentAccess#select` now returns a `HashWithIndifferentAccess`
instance instead of a `Hash` instance.
diff --git a/activesupport/Rakefile b/activesupport/Rakefile
index f50225a9f0..99770bace9 100644
--- a/activesupport/Rakefile
+++ b/activesupport/Rakefile
@@ -14,7 +14,7 @@ namespace :test do
task :isolated do
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
Dir.glob("test/**/*_test.rb").all? do |file|
- sh(ruby, '-Ilib:test', file)
+ sh(ruby, '-w', '-Ilib:test', file)
end or raise "Failures"
end
end
@@ -25,7 +25,7 @@ Gem::PackageTask.new(spec) do |p|
p.gem_spec = spec
end
-desc "Release to gemcutter"
+desc "Release to rubygems"
task :release => :package do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb
index 6f9dc679c2..c88ae3e661 100644
--- a/activesupport/lib/active_support/backtrace_cleaner.rb
+++ b/activesupport/lib/active_support/backtrace_cleaner.rb
@@ -97,11 +97,7 @@ module ActiveSupport
end
def noise(backtrace)
- @silencers.each do |s|
- backtrace = backtrace.select { |line| s.call(line) }
- end
-
- backtrace
+ backtrace - silence(backtrace)
end
end
end
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb
index 6fa9967a28..83038f9da5 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -70,7 +70,6 @@ class Class
# To opt out of both instance methods, pass <tt>instance_accessor: false</tt>.
def class_attribute(*attrs)
options = attrs.extract_options!
- # double assignment is used to avoid "assigned but unused variable" warning
instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true)
instance_writer = options.fetch(:instance_accessor, true) && options.fetch(:instance_writer, true)
instance_predicate = options.fetch(:instance_predicate, true)
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb
index 3dde87ac2e..1aa72da743 100644
--- a/activesupport/lib/active_support/core_ext/module/delegation.rb
+++ b/activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -1,4 +1,8 @@
class Module
+ # Error generated by +delegate+ when a method is called on +nil+ and +allow_nil+
+ # option is not used.
+ class DelegationError < NoMethodError; end
+
# Provides a +delegate+ class method to easily expose contained objects'
# public methods as your own.
#
@@ -176,7 +180,7 @@ class Module
end # end
EOS
else
- exception = %(raise "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
+ exception = %(raise DelegationError, "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
module_eval(<<-EOS, file, line - 2)
def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &block)
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb
index 6c15fffc0f..0281c9222e 100644
--- a/activesupport/lib/active_support/deprecation.rb
+++ b/activesupport/lib/active_support/deprecation.rb
@@ -25,11 +25,11 @@ module ActiveSupport
include Reporting
include MethodWrapper
- # The version the deprecated behavior will be removed, by default.
+ # The version number in which the deprecated behavior will be removed, by default.
attr_accessor :deprecation_horizon
- # It accepts two parameters on initialization. The first is an version of library
- # and the second is an library name
+ # It accepts two parameters on initialization. The first is a version of library
+ # and the second is a library name
#
# ActiveSupport::Deprecation.new('2.0', 'MyLibrary')
def initialize(deprecation_horizon = '4.1', gem_name = 'Rails')
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb
index 56213de50e..95e03ba95c 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -224,7 +224,7 @@ module ActiveSupport
undef :symbolize_keys!
undef :deep_symbolize_keys!
def symbolize_keys; to_hash.symbolize_keys! end
- def deep_symbolize_keys; to_hash.deep_symbolize_keys end
+ def deep_symbolize_keys; to_hash.deep_symbolize_keys! end
def to_options!; self end
def select(*args, &block)
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb
index a2263fa4d0..9ca5a388f8 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -1,6 +1,5 @@
# encoding: utf-8
-require 'active_support/inflector/inflections'
require 'active_support/inflections'
module ActiveSupport
diff --git a/activesupport/test/clean_backtrace_test.rb b/activesupport/test/clean_backtrace_test.rb
index b14950acb3..dd67a45cf6 100644
--- a/activesupport/test/clean_backtrace_test.rb
+++ b/activesupport/test/clean_backtrace_test.rb
@@ -36,6 +36,27 @@ class BacktraceCleanerSilencerTest < ActiveSupport::TestCase
end
end
+class BacktraceCleanerMultipleSilencersTest < ActiveSupport::TestCase
+ def setup
+ @bc = ActiveSupport::BacktraceCleaner.new
+ @bc.add_silencer { |line| line =~ /mongrel/ }
+ @bc.add_silencer { |line| line =~ /yolo/ }
+ end
+
+ test "backtrace should not contain lines that match the silencers" do
+ assert_equal \
+ [ "/other/class.rb" ],
+ @bc.clean([ "/mongrel/class.rb", "/other/class.rb", "/mongrel/stuff.rb", "/other/yolo.rb" ])
+ end
+
+ test "backtrace should only contain lines that match the silencers" do
+ assert_equal \
+ [ "/mongrel/class.rb", "/mongrel/stuff.rb", "/other/yolo.rb" ],
+ @bc.clean([ "/mongrel/class.rb", "/other/class.rb", "/mongrel/stuff.rb", "/other/yolo.rb" ],
+ :noise)
+ end
+end
+
class BacktraceCleanerFilterAndSilencerTest < ActiveSupport::TestCase
def setup
@bc = ActiveSupport::BacktraceCleaner.new
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index 8872611fb1..f08c61ae92 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -207,7 +207,7 @@ class ModuleTest < ActiveSupport::TestCase
def test_delegation_without_allow_nil_and_nil_value
david = Someone.new("David")
- assert_raise(RuntimeError) { david.street }
+ assert_raise(Module::DelegationError) { david.street }
end
def test_delegation_to_method_that_exists_on_nil
diff --git a/ci/travis.rb b/ci/travis.rb
index 9029c3f41c..7e68993332 100755
--- a/ci/travis.rb
+++ b/ci/travis.rb
@@ -20,7 +20,8 @@ class Build
'am' => 'actionmailer',
'amo' => 'activemodel',
'as' => 'activesupport',
- 'ar' => 'activerecord'
+ 'ar' => 'activerecord',
+ 'av' => 'actionview'
}
attr_reader :component, :options
diff --git a/guides/assets/stylesheets/main.css b/guides/assets/stylesheets/main.css
index dd029e6314..ca319c91cf 100644
--- a/guides/assets/stylesheets/main.css
+++ b/guides/assets/stylesheets/main.css
@@ -244,7 +244,7 @@ body {
#subCol {
position: absolute;
z-index: 0;
- top: 0;
+ top: 21px;
right: 0;
background: #FFF;
padding: 1em 1.5em 1em 1.25em;
diff --git a/guides/bug_report_templates/active_record_gem.rb b/guides/bug_report_templates/active_record_gem.rb
index 2e604bec47..a8868a1877 100644
--- a/guides/bug_report_templates/active_record_gem.rb
+++ b/guides/bug_report_templates/active_record_gem.rb
@@ -1,5 +1,5 @@
# Activate the gem you are reporting the issue against.
-gem 'activerecord', '3.2.13'
+gem 'activerecord', '4.0.0'
require 'active_record'
require 'minitest/autorun'
require 'logger'
diff --git a/guides/code/getting_started/app/views/posts/_form.html.erb b/guides/code/getting_started/app/views/posts/_form.html.erb
index c9fb74af9c..f2f83585e1 100644
--- a/guides/code/getting_started/app/views/posts/_form.html.erb
+++ b/guides/code/getting_started/app/views/posts/_form.html.erb
@@ -1,6 +1,6 @@
<%= form_for @post do |f| %>
<% if @post.errors.any? %>
- <div id="errorExplanation">
+ <div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited
this post from being saved:</h2>
<ul>
@@ -14,12 +14,12 @@
<%= f.label :title %><br>
<%= f.text_field :title %>
</p>
-
+
<p>
<%= f.label :text %><br>
<%= f.text_area :text %>
</p>
-
+
<p>
<%= f.submit %>
</p>
diff --git a/guides/code/getting_started/config/environments/development.rb b/guides/code/getting_started/config/environments/development.rb
index d169e9452c..7e5692b08b 100644
--- a/guides/code/getting_started/config/environments/development.rb
+++ b/guides/code/getting_started/config/environments/development.rb
@@ -22,7 +22,7 @@ Blog::Application.configure do
# Only use best-standards-support built into browsers.
config.action_dispatch.best_standards_support = :builtin
- # Raise an error on page load if there are pending migrations
+ # Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
diff --git a/guides/source/4_0_release_notes.md b/guides/source/4_0_release_notes.md
index 6ebeeed0bf..66e26c63cb 100644
--- a/guides/source/4_0_release_notes.md
+++ b/guides/source/4_0_release_notes.md
@@ -52,7 +52,7 @@ Major Features
TODO. Give a list and then talk about each of them briefly. We can point to relevant code commits or documentation from these sections.
-![Rails 4.0](images/rails4_features.png)
+[![Rails 4.0](images/rails4_features.png)](http://guides.rubyonrails.org/images/rails4_features.png)
Extraction of features to gems
---------------------------
@@ -89,6 +89,10 @@ Please refer to the [Changelog](https://github.com/rails/rails/blob/master/railt
* Threadsafe on by default
+* Ability to use a custom builder by passing `--builder` (or `-b`) to
+ `rails new` has been removed. Consider using application templates
+ instead. ([Pull Request](https://github.com/rails/rails/pull/9401))
+
### Deprecations
* `config.threadsafe!` is deprecated in favor of `config.eager_load` which provides a more fine grained control on what is eager loaded.
diff --git a/guides/source/_welcome.html.erb b/guides/source/_welcome.html.erb
index a50961a0c7..9210c40c17 100644
--- a/guides/source/_welcome.html.erb
+++ b/guides/source/_welcome.html.erb
@@ -10,10 +10,13 @@
</p>
<% else %>
<p>
- These are the new guides for Rails 3.2 based on <a href="https://github.com/rails/rails/tree/<%= @version %>"><%= @version %></a>.
+ These are the new guides for Rails 4.0 based on <a href="https://github.com/rails/rails/tree/<%= @version %>"><%= @version %></a>.
These guides are designed to make you immediately productive with Rails, and to help you understand how all of the pieces fit together.
</p>
<% end %>
<p>
+ The guides for Rails 3.2.x are available at <a href="http://guides.rubyonrails.org/v3.2.13/">http://guides.rubyonrails.org/v3.2.13/</a>.
+</p>
+<p>
The guides for Rails 2.3.x are available at <a href="http://guides.rubyonrails.org/v2.3.11/">http://guides.rubyonrails.org/v2.3.11/</a>.
</p>
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index 2701f5bb72..6a91418e1f 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -129,7 +129,7 @@ Note that the `params` hash is actually an instance of `ActiveSupport::HashWithI
### JSON parameters
-If you're writing a web service application, you might find yourself more comfortable accepting parameters in JSON format. Rails will automatically convert your parameters into the `params` hash, which you can access as you would normally.
+If you're writing a web service application, you might find yourself more comfortable accepting parameters in JSON format. If the "Content-Type" header of your request is set to "application/json", Rails will automatically convert your parameters into the `params` hash, which you can access as you would normally.
So for example, if you are sending this JSON content:
diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md
index dea1ddef71..b3fc61f386 100644
--- a/guides/source/action_view_overview.md
+++ b/guides/source/action_view_overview.md
@@ -1090,7 +1090,7 @@ Example object structure for use with this method:
```ruby
class Post < ActiveRecord::Base
- has_and_belongs_to_many :author
+ has_and_belongs_to_many :authors
end
class Author < ActiveRecord::Base
@@ -1230,6 +1230,14 @@ Return select and option tags for the given object and method, using `time_zone_
time_zone_select( "user", "time_zone")
```
+#### date_field
+
+Returns an input tag of the "date" type tailored for accessing a specified attribute.
+
+```ruby
+date_field("user", "dob")
+```
+
### FormTagHelper
Provides a number of methods for creating form tags that doesn't rely on an Active Record object assigned to the template like FormHelper does. Instead, you provide the names and values manually.
@@ -1364,6 +1372,15 @@ text_field_tag 'name'
# => <input id="name" name="name" type="text" />
```
+#### date_field_tag
+
+Creates a standard input field of date type.
+
+```ruby
+date_field_tag "dob"
+# => <input id="dob" name="dob" type="date" />
+```
+
### JavaScriptHelper
Provides functionality for working with JavaScript in your views.
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 2555927d15..407e779f9f 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -58,6 +58,7 @@ The methods are:
* `bind`
* `create_with`
+* `distinct`
* `eager_load`
* `extending`
* `from`
@@ -76,7 +77,6 @@ The methods are:
* `reorder`
* `reverse_order`
* `select`
-* `distinct`
* `uniq`
* `where`
diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md
index 37790c62b1..3bfc600e7c 100644
--- a/guides/source/active_record_validations.md
+++ b/guides/source/active_record_validations.md
@@ -120,8 +120,8 @@ database only if the object is valid:
* `update!`
The bang versions (e.g. `save!`) raise an exception if the record is invalid.
-The non-bang versions don't: `save` and `update` return `false`,
-`create` and `update` just return the objects.
+The non-bang versions don't, `save` and `update` return `false`,
+`create` just return the objects.
### Skipping Validations
diff --git a/guides/source/active_support_instrumentation.md b/guides/source/active_support_instrumentation.md
index 38dbfd3152..969596f470 100644
--- a/guides/source/active_support_instrumentation.md
+++ b/guides/source/active_support_instrumentation.md
@@ -39,7 +39,7 @@ Action Controller
```ruby
{
- key: 'posts/1-dasboard-view'
+ key: 'posts/1-dashboard-view'
}
```
@@ -51,7 +51,7 @@ Action Controller
```ruby
{
- key: 'posts/1-dasboard-view'
+ key: 'posts/1-dashboard-view'
}
```
@@ -63,7 +63,7 @@ Action Controller
```ruby
{
- key: 'posts/1-dasboard-view'
+ key: 'posts/1-dashboard-view'
}
```
@@ -75,7 +75,7 @@ Action Controller
```ruby
{
- key: 'posts/1-dasboard-view'
+ key: 'posts/1-dashboard-view'
}
```
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index d7277b487f..c0e584a1c7 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -781,7 +781,7 @@ The `create_association` method returns a new object of the associated type. Thi
##### `create_association!(attributes = {})`
-Does the same as <tt>create_association</tt> above, but raises <tt>ActiveRecord::RecordInvalid</tt> if the record is invalid.
+Does the same as `create_association` above, but raises `ActiveRecord::RecordInvalid` if the record is invalid.
#### Options for `belongs_to`
@@ -1083,7 +1083,7 @@ The `create_association` method returns a new object of the associated type. Thi
##### `create_association!(attributes = {})`
-Does the same as <tt>create_association</tt> above, but raises <tt>ActiveRecord::RecordInvalid</tt> if the record is invalid.
+Does the same as `create_association` above, but raises `ActiveRecord::RecordInvalid` if the record is invalid.
#### Options for `has_one`
@@ -1443,7 +1443,7 @@ The `collection.create` method returns a new object of the associated type. This
##### `collection.create!(attributes = {})`
-Does the same as <tt>collection.create</tt> above, but raises <tt>ActiveRecord::RecordInvalid</tt> if the record is invalid.
+Does the same as `collection.create` above, but raises `ActiveRecord::RecordInvalid` if the record is invalid.
#### Options for `has_many`
@@ -1736,15 +1736,15 @@ If you want to make sure that, upon insertion, all of the records in the
persisted association are distinct (so that you can be sure that when you
inspect the association that you will never find duplicate records), you should
add a unique index on the table itself. For example, if you have a table named
-``person_posts`` and you want to make sure all the posts are unique, you could
+`person_posts` and you want to make sure all the posts are unique, you could
add the following in a migration:
```ruby
-add_index :person_posts, :post, :unique => true
+add_index :person_posts, :post, unique: true
```
-Note that checking for uniqueness using something like ``include?`` is subject
-to race conditions. Do not attempt to use ``include?`` to enforce distinctness
+Note that checking for uniqueness using something like `include?` is subject
+to race conditions. Do not attempt to use `include?` to enforce distinctness
in an association. For instance, using the post example from above, the
following code would be racy because multiple users could be attempting this
at the same time:
@@ -1936,7 +1936,7 @@ The `collection.create` method returns a new object of the associated type. This
##### `collection.create!(attributes = {})`
-Does the same as <tt>collection.create</tt>, but raises <tt>ActiveRecord::RecordInvalid</tt> if the record is invalid.
+Does the same as `collection.create`, but raises `ActiveRecord::RecordInvalid` if the record is invalid.
#### Options for `has_and_belongs_to_many`
@@ -2199,4 +2199,4 @@ Extensions can refer to the internals of the association proxy using these three
* `proxy_association.owner` returns the object that the association is a part of.
* `proxy_association.reflection` returns the reflection object that describes the association.
-* `proxy_association.target` returns the associated object for `belongs_to` or `has_one`, or the collection of associated objects for `has_many` or `has_and_belongs_to_many`. \ No newline at end of file
+* `proxy_association.target` returns the associated object for `belongs_to` or `has_one`, or the collection of associated objects for `has_many` or `has_and_belongs_to_many`.
diff --git a/guides/source/command_line.md b/guides/source/command_line.md
index e0b44bbf93..218b4dd39a 100644
--- a/guides/source/command_line.md
+++ b/guides/source/command_line.md
@@ -27,6 +27,8 @@ There are a few commands that are absolutely critical to your everyday usage of
* `rails dbconsole`
* `rails new app_name`
+All commands can run with ```-h or --help``` to list more information.
+
Let's create a simple Rails application to step through each of these commands in context.
### `rails new`
@@ -64,7 +66,7 @@ With no further work, `rails server` will run our new shiny Rails app:
$ cd commandsapp
$ rails server
=> Booting WEBrick
-=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000
+=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-05-28 00:39:41] INFO WEBrick 1.3.1
@@ -289,7 +291,7 @@ If you wish to test out some code without changing any data, you can do that by
```bash
$ rails console --sandbox
-Loading development environment in sandbox (Rails 3.2.3)
+Loading development environment in sandbox (Rails 4.0.0)
Any modifications you make will be rolled back on exit
irb(main):001:0>
```
@@ -348,6 +350,9 @@ Rake is Ruby Make, a standalone Ruby utility that replaces the Unix utility 'mak
You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing `rake --tasks`. Each task has a description, and should help you find the thing you need.
+To get the full backtrace for running rake task you can pass the option
+```--trace``` to command line, for example ```rake db:create --trace```.
+
```bash
$ rake --tasks
rake about # List versions of all Rails frameworks and the environment
@@ -361,6 +366,7 @@ rake middleware # Prints out your Rack middleware stack
rake tmp:clear # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)
rake tmp:create # Creates tmp directories for sessions, cache, sockets, and pids
```
+INFO: You can also use ```rake -T``` to get the list of tasks.
### `about`
@@ -372,12 +378,12 @@ About your application's environment
Ruby version 1.9.3 (x86_64-linux)
RubyGems version 1.3.6
Rack version 1.3
-Rails version 4.0.0.beta
+Rails version 4.0.0
JavaScript Runtime Node.js (V8)
-Active Record version 4.0.0.beta
-Action Pack version 4.0.0.beta
-Action Mailer version 4.0.0.beta
-Active Support version 4.0.0.beta
+Active Record version 4.0.0
+Action Pack version 4.0.0
+Action Mailer version 4.0.0
+Active Support version 4.0.0
Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::EncryptedCookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
Application root /home/foobar/commandsapp
Environment development
@@ -468,12 +474,13 @@ Rails comes with a test suite called `Test::Unit`. Rails owes its stability to t
The `Rails.root/tmp` directory is, like the *nix /tmp directory, the holding place for temporary files like sessions (if you're using a file store for files), process id files, and cached actions.
-The `tmp:` namespaced tasks will help you clear the `Rails.root/tmp` directory:
+The `tmp:` namespaced tasks will help you clear and create the `Rails.root/tmp` directory:
* `rake tmp:cache:clear` clears `tmp/cache`.
* `rake tmp:sessions:clear` clears `tmp/sessions`.
* `rake tmp:sockets:clear` clears `tmp/sockets`.
* `rake tmp:clear` clears all the three: cache, sessions and sockets.
+* `rake tmp:create` creates tmp directories for sessions, cache, sockets, and pids.
### Miscellaneous
diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md
index 0bfa646b81..b9f42fa51b 100644
--- a/guides/source/contributing_to_ruby_on_rails.md
+++ b/guides/source/contributing_to_ruby_on_rails.md
@@ -184,7 +184,9 @@ Ruby on Rails has two main sets of documentation: the guides help you in learnin
You can help improve the Rails guides by making them more coherent, consistent or readable, adding missing information, correcting factual errors, fixing typos, or bringing it up to date with the latest edge Rails. To get involved in the translation of Rails guides, please see [Translating Rails Guides](https://wiki.github.com/rails/docrails/translating-rails-guides).
-If you're confident about your changes, you can push them directly yourself via [docrails](https://github.com/rails/docrails). Docrails is a branch with an **open commit policy** and public write access. Commits to docrails are still reviewed, but this happens after they are pushed. Docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
+You can either ask for commit bit if you'd like to contribute to [Docrails](http://github.com/rails/docrails) regularly (Please contact anyone from [the core team](http://rubyonrails.org/core)), or else open a pull request to [Rails](http://github.com/rails/rails) itself.
+
+Docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
If you are unsure of the documentation changes, you can create an issue in the [Rails](https://github.com/rails/rails/issues) issues tracker on GitHub.
diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md
index 70055c1d7d..c17aa64cac 100644
--- a/guides/source/debugging_rails_applications.md
+++ b/guides/source/debugging_rails_applications.md
@@ -248,7 +248,7 @@ Make sure you have started your web server with the option `--debugger`:
```bash
$ rails server --debugger
=> Booting WEBrick
-=> Rails 3.2.13 application starting on http://0.0.0.0:3000
+=> Rails 4.0.0 application starting on http://0.0.0.0:3000
=> Debugger enabled
...
```
@@ -504,7 +504,7 @@ TIP: You can use the debugger while using `rails console`. Just remember to `req
```
$ rails console
-Loading development environment (Rails 3.2.13)
+Loading development environment (Rails 4.0.0)
>> require "debugger"
=> []
>> author = Author.first
@@ -661,6 +661,8 @@ There are some Rails plugins to help you to find errors and debug your applicati
* [Query Trace](https://github.com/ntalbott/query_trace/tree/master) Adds query origin tracing to your logs.
* [Query Reviewer](https://github.com/nesquena/query_reviewer) This rails plugin not only runs "EXPLAIN" before each of your select queries in development, but provides a small DIV in the rendered output of each page with the summary of warnings for each query that it analyzed.
* [Exception Notifier](https://github.com/smartinez87/exception_notification/tree/master) Provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application.
+* [Better Errors](https://github.com/charliesome/better_errors) Replaces the standard Rails error page with a new one containing more contextual information, like source code and variable inspection.
+* [RailsPanel](https://github.com/dejan/rails_panel) Chrome extension for Rails development that will end your tailing of development.log. Have all information about your Rails app requests in the browser - in the Developer Tools panel. Provides insight to db/rendering/total times, parameter list, rendered views and more.
References
----------
diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md
index b409534cb0..7f37a298b1 100644
--- a/guides/source/form_helpers.md
+++ b/guides/source/form_helpers.md
@@ -973,4 +973,4 @@ As a convenience you can instead pass the symbol `:all_blank` which will create
### Adding Fields on the Fly
-Rather than rendering multiple sets of fields ahead of time you may wish to add them only when a user clicks on an 'Add new child' button. Rails does not provide any builtin support for this. When generating new sets of fields you must ensure the the key of the associated array is unique - the current javascript date (milliseconds after the epoch) is a common choice.
+Rather than rendering multiple sets of fields ahead of time you may wish to add them only when a user clicks on an 'Add new child' button. Rails does not provide any builtin support for this. When generating new sets of fields you must ensure the key of the associated array is unique - the current javascript date (milliseconds after the epoch) is a common choice.
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md
index 0d44f0e776..2574a2c111 100644
--- a/guides/source/getting_started.md
+++ b/guides/source/getting_started.md
@@ -230,16 +230,16 @@ Blog::Application.routes.draw do
# first created -> highest priority.
# ...
# You can have the root of your site routed with "root"
- # root to: "welcome#index"
+ # root "welcome#index"
```
-This is your application's _routing file_ which holds entries in a special DSL (domain-specific language) that tells Rails how to connect incoming requests to controllers and actions. This file contains many sample routes on commented lines, and one of them actually shows you how to connect the root of your site to a specific controller and action. Find the line beginning with `root :to` and uncomment it. It should look something like the following:
+This is your application's _routing file_ which holds entries in a special DSL (domain-specific language) that tells Rails how to connect incoming requests to controllers and actions. This file contains many sample routes on commented lines, and one of them actually shows you how to connect the root of your site to a specific controller and action. Find the line beginning with `root` and uncomment it. It should look something like the following:
```ruby
-root to: "welcome#index"
+root "welcome#index"
```
-The `root to: "welcome#index"` tells Rails to map requests to the root of the application to the welcome controller's index action and `get "welcome/index"` tells Rails to map requests to <http://localhost:3000/welcome/index> to the welcome controller's index action. This was created earlier when you ran the controller generator (`rails generate controller welcome index`).
+The `root "welcome#index"` tells Rails to map requests to the root of the application to the welcome controller's index action and `get "welcome/index"` tells Rails to map requests to <http://localhost:3000/welcome/index> to the welcome controller's index action. This was created earlier when you ran the controller generator (`rails generate controller welcome index`).
If you navigate to <http://localhost:3000> in your browser, you'll see the `Hello, Rails!` message you put into `app/views/welcome/index.html.erb`, indicating that this new route is indeed going to `WelcomeController`'s `index` action and is rendering the view correctly.
@@ -252,15 +252,15 @@ Now that you've seen how to create a controller, an action and a view, let's cre
In the Blog application, you will now create a new _resource_. A resource is the term used for a collection of similar objects, such as posts, people or animals. You can create, read, update and destroy items for a resource and these operations are referred to as _CRUD_ operations.
-Rails provides a `resources` method which can be used to declare a
-standard REST resource. Here's how `config/routes.rb` will look like.
+Rails provides a `resources` method which can be used to declare a standard REST resource.
+Here's what `config/routes.rb` should look like after the _post resource_ is declared.
```ruby
Blog::Application.routes.draw do
resources :posts
- root to: "welcome#index"
+ root "welcome#index"
end
```
@@ -793,7 +793,7 @@ something went wrong. To do that, you'll modify
```html+erb
<%= form_for :post, url: posts_path do |f| %>
<% if @post.errors.any? %>
- <div id="errorExplanation">
+ <div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited
this post from being saved:</h2>
<ul>
@@ -862,7 +862,7 @@ it look as follows:
<%= form_for :post, url: post_path(@post.id), method: :patch do |f| %>
<% if @post.errors.any? %>
- <div id="errorExplanation">
+ <div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited
this post from being saved:</h2>
<ul>
@@ -977,7 +977,7 @@ content:
```html+erb
<%= form_for @post do |f| %>
<% if @post.errors.any? %>
- <div id="errorExplanation">
+ <div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited
this post from being saved:</h2>
<ul>
@@ -1659,7 +1659,7 @@ Two very common sources of data that are not UTF-8:
in the browser. This also applies to your i18n translation files.
Most editors that do not already default to UTF-8 (such as some versions of
Dreamweaver) offer a way to change the default to UTF-8. Do so.
-* Your database. Rails defaults to converting data from your database into UTF-8 at
+* Your database: Rails defaults to converting data from your database into UTF-8 at
the boundary. However, if your database is not using UTF-8 internally, it may not
be able to store all characters that your users enter. For instance, if your database
is using Latin-1 internally, and your user enters a Russian, Hebrew, or Japanese
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index b248c7645a..062da3877b 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -283,7 +283,7 @@ def extract_locale_from_accept_language_header
end
```
-Of course, in a production environment you would need much more robust code, and could use a plugin such as Iain Hecker's [http_accept_language](https://github.com/iain/http_accept_language/tree/master or even Rack middleware such as Ryan Tomayko's [locale](https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/locale.rb).
+Of course, in a production environment you would need much more robust code, and could use a plugin such as Iain Hecker's [http_accept_language](https://github.com/iain/http_accept_language/tree/master) or even Rack middleware such as Ryan Tomayko's [locale](https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/locale.rb).
#### Using GeoIP (or Similar) Database
@@ -865,11 +865,11 @@ Rails uses fixed strings and other localizations, such as format strings and oth
#### Action View Helper Methods
-* `distance_of_time_in_words` translates and pluralizes its result and interpolates the number of seconds, minutes, hours, and so on. See [datetime.distance_in_words](https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml#L51) translations.
+* `distance_of_time_in_words` translates and pluralizes its result and interpolates the number of seconds, minutes, hours, and so on. See [datetime.distance_in_words](https://github.com/rails/rails/blob/master/actionview/lib/action_view/locale/en.yml#L51) translations.
-* `datetime_select` and `select_month` use translated month names for populating the resulting select tag. See [date.month_names](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L15) for translations. `datetime_select` also looks up the order option from [date.order](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L18) (unless you pass the option explicitly). All date selection helpers translate the prompt using the translations in the [datetime.prompts](https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml#L83) scope if applicable.
+* `datetime_select` and `select_month` use translated month names for populating the resulting select tag. See [date.month_names](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L15) for translations. `datetime_select` also looks up the order option from [date.order](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L18) (unless you pass the option explicitly). All date selection helpers translate the prompt using the translations in the [datetime.prompts](https://github.com/rails/rails/blob/master/actionview/lib/action_view/locale/en.yml#L83) scope if applicable.
-* The `number_to_currency`, `number_with_precision`, `number_to_percentage`, `number_with_delimiter`, and `number_to_human_size` helpers use the number format settings located in the [number](https://github.com/rails/rails/blob/master/actionpack/lib/action_view/locale/en.yml#L2) scope.
+* The `number_to_currency`, `number_with_precision`, `number_to_percentage`, `number_with_delimiter`, and `number_to_human_size` helpers use the number format settings located in the [number](https://github.com/rails/rails/blob/master/actionview/lib/action_view/locale/en.yml#L2) scope.
#### Active Model Methods
diff --git a/guides/source/kindle/toc.html.erb b/guides/source/kindle/toc.html.erb
index e013797dee..f310edd3a1 100644
--- a/guides/source/kindle/toc.html.erb
+++ b/guides/source/kindle/toc.html.erb
@@ -20,5 +20,5 @@ Ruby on Rails Guides
<ul>
<li><a href="credits.html">Credits</a></li>
<li><a href="copyright.html">Copyright &amp; License</a></li>
-<ul>
+</ul>
</div>
diff --git a/guides/source/layout.html.erb b/guides/source/layout.html.erb
index ef2bdf0753..c737a0e9dc 100644
--- a/guides/source/layout.html.erb
+++ b/guides/source/layout.html.erb
@@ -101,10 +101,12 @@
You're encouraged to help improve the quality of this guide.
</p>
<p>
- If you see any typos or factual errors you are confident to
- patch, please clone <%= link_to 'docrails', 'https://github.com/rails/docrails' %>
- and push the change yourself. That branch of Rails has public write access.
- Commits are still reviewed, but that happens after you've submitted your
+ If you see any typos or factual errors that you are confident to fix,
+ you can push the fix to <%= link_to 'docrails', 'https://github.com/rails/docrails' %> (Ask
+ the <%= link_to 'Rails core team', 'http://rubyonrails.org/core' %> for push access).
+ If you choose to open a pull request, please do it in <%= link_to 'Rails', 'https://github.com/rails/rails' %>
+ and not in the <%= link_to 'docrails', 'https://github.com/rails/docrails' %> repository.
+ Commits made to docrails are still reviewed, but that happens after you've submitted your
contribution. <%= link_to 'docrails', 'https://github.com/rails/docrails' %> is
cross-merged with master periodically.
</p>
diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md
index 1ab841b137..f6cac997ff 100644
--- a/guides/source/layouts_and_rendering.md
+++ b/guides/source/layouts_and_rendering.md
@@ -629,7 +629,7 @@ def show
@book = Book.find_by_id(params[:id])
if @book.nil?
@books = Book.all
- flash[:alert] = "Your book was not found"
+ flash.now[:alert] = "Your book was not found"
render "index"
end
end
diff --git a/guides/source/migrations.md b/guides/source/migrations.md
index eb0cfd9451..508e52a77c 100644
--- a/guides/source/migrations.md
+++ b/guides/source/migrations.md
@@ -390,8 +390,8 @@ will create a `categorization` table.
```ruby
create_join_table :products, :categories do |t|
- t.index :products
- t.index :categories
+ t.index :product_id
+ t.index :category_id
end
```
diff --git a/guides/source/routing.md b/guides/source/routing.md
index 076b9dd176..76c4c25108 100644
--- a/guides/source/routing.md
+++ b/guides/source/routing.md
@@ -171,6 +171,12 @@ A singular resourceful route generates these helpers:
As with plural resources, the same helpers ending in `_url` will also include the host, port and path prefix.
+WARNING: A [long-standing bug](https://github.com/rails/rails/issues/1769) prevents `form_for` from working automatically with singular resources. As a workaround, specify the URL for the form directly, like so:
+
+```ruby
+form_for @geocoder, url: geocoder_path do |f|
+```
+
### Controller Namespaces and Routing
You may wish to organize groups of controllers under a namespace. Most commonly, you might group a number of administrative controllers under an `Admin::` namespace. You would place these controllers under the `app/controllers/admin` directory, and you can group them together in your router:
@@ -767,11 +773,11 @@ You can also reuse dynamic segments from the match in the path to redirect to:
get '/stories/:name', to: redirect('/posts/%{name}')
```
-You can also provide a block to redirect, which receives the params and the request object:
+You can also provide a block to redirect, which receives the symbolized path parameters and the request object:
```ruby
-get '/stories/:name', to: redirect {|params, req| "/posts/#{params[:name].pluralize}" }
-get '/stories', to: redirect {|p, req| "/posts/#{req.subdomain}" }
+get '/stories/:name', to: redirect {|path_params, req| "/posts/#{path_params[:name].pluralize}" }
+get '/stories', to: redirect {|path_params, req| "/posts/#{req.subdomain}" }
```
Please note that this redirection is a 301 "Moved Permanently" redirect. Keep in mind that some web browsers or proxy servers will cache this type of redirect, making the old page inaccessible.
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index 35a9617b80..e7e28e21a3 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -61,7 +61,7 @@ end
```ruby
class UsersController < ApplicationController
def update_name
- # Change needed; form_for will try to use a non-existant PATCH route.
+ # Change needed; form_for will try to use a non-existent PATCH route.
end
end
```
diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md
index 22a59cdfec..bd0c796673 100644
--- a/guides/source/working_with_javascript_in_rails.md
+++ b/guides/source/working_with_javascript_in_rails.md
@@ -278,9 +278,7 @@ The index view (`app/views/users/index.html.erb`) contains:
<b>Users</b>
<ul id="users">
-<% @users.each do |user| %>
- <%= render user %>
-<% end %>
+<%= render @users %>
</ul>
<br>
diff --git a/rails.gemspec b/rails.gemspec
index 4a17beac69..b426faf0e8 100644
--- a/rails.gemspec
+++ b/rails.gemspec
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
s.add_dependency 'activesupport', version
s.add_dependency 'actionpack', version
+ s.add_dependency 'actionview', version
s.add_dependency 'activerecord', version
s.add_dependency 'actionmailer', version
s.add_dependency 'railties', version
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index ae4bfc2447..00ef1ad058 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Removed deprecated rake tasks for running tests: `rake test:uncommitted` and
+ `rake test:recent`.
+
+ *John Wang*
+
* Clearing autoloaded constants triggers routes reloading [Fixes #10685].
*Xavier Noria*
@@ -12,9 +17,9 @@
moved to class methods in Railtie and the Railtie has been made abstract.
*John Wang*
-
+
* Changes repetitive th tags to use colspan attribute in `index.html.erb` template.
-
+
*Sıtkı Bağdat*
Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/railties/CHANGELOG.md) for previous changes.
diff --git a/railties/Rakefile b/railties/Rakefile
index 4789f41ad4..5728c774bd 100644
--- a/railties/Rakefile
+++ b/railties/Rakefile
@@ -54,7 +54,7 @@ end
# Publishing -------------------------------------------------------
-desc "Release to gemcutter"
+desc "Release to rubygems"
task :release => :package do
require 'rake/gemcutter'
Rake::Gemcutter::Tasks.new(spec).define
diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb
index e8c42b149b..48007dd2ab 100644
--- a/railties/lib/rails/commands.rb
+++ b/railties/lib/rails/commands.rb
@@ -5,7 +5,6 @@ aliases = {
"d" => "destroy",
"c" => "console",
"s" => "server",
- "t" => "test",
"db" => "dbconsole",
"r" => "runner"
}
@@ -17,7 +16,6 @@ The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
- test Running the test file (short-cut alias: "t")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb
index 5914c9e4ae..3e4cc787c4 100644
--- a/railties/lib/rails/commands/dbconsole.rb
+++ b/railties/lib/rails/commands/dbconsole.rb
@@ -44,7 +44,7 @@ module Rails
find_cmd_and_exec(['mysql', 'mysql5'], *args)
- when "postgresql", "postgres"
+ when "postgresql", "postgres", "postgis"
ENV['PGUSER'] = config["username"] if config["username"]
ENV['PGHOST'] = config["host"] if config["host"]
ENV['PGPORT'] = config["port"].to_s if config["port"]
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
index 91253d1508..cff570a631 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
@@ -20,7 +20,7 @@ Rails.application.configure do
config.active_support.deprecation = :log
<%- unless options.skip_active_record? -%>
- # Raise an error on page load if there are pending migrations
+ # Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
<%- end -%>
diff --git a/railties/lib/rails/generators/rails/app/templates/config/routes.rb b/railties/lib/rails/generators/rails/app/templates/config/routes.rb
index 3dfb724164..3f66539d54 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/routes.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/routes.rb
@@ -39,7 +39,7 @@ Rails.application.routes.draw do
# get 'recent', on: :collection
# end
# end
-
+
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
diff --git a/railties/lib/rails/generators/rails/controller/USAGE b/railties/lib/rails/generators/rails/controller/USAGE
index 64239ad599..de33900e0a 100644
--- a/railties/lib/rails/generators/rails/controller/USAGE
+++ b/railties/lib/rails/generators/rails/controller/USAGE
@@ -16,3 +16,4 @@ Example:
Test: test/controllers/credit_cards_controller_test.rb
Views: app/views/credit_cards/debit.html.erb [...]
Helper: app/helpers/credit_cards_helper.rb
+ Test: test/helpers/credit_cards_helper_test.rb
diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake
index 9263b9b81d..2e23999a91 100644
--- a/railties/lib/rails/test_unit/testing.rake
+++ b/railties/lib/rails/test_unit/testing.rake
@@ -3,47 +3,6 @@ require 'rake/testtask'
require 'rails/test_unit/sub_test_task'
require 'active_support/deprecation'
-TEST_CHANGES_SINCE = Time.now - 600
-
-# Look up tests for recently modified sources.
-def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
- FileList[source_pattern].map do |path|
- if File.mtime(path) > touched_since
- tests = []
- source_dir = File.dirname(path).split("/")
- source_file = File.basename(path, '.rb')
-
- # Support subdirs in app/models and app/controllers
- modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path
-
- # For modified files in app/ run the tests for it. ex. /test/controllers/account_controller.rb
- test = "#{modified_test_path}/#{source_file}_test.rb"
- tests.push test if File.exist?(test)
-
- # For modified files in app, run tests in subdirs too. ex. /test/controllers/account/*_test.rb
- test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
- FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test)
-
- return tests
-
- end
- end.flatten.compact
-end
-
-
-# Recreated here from Active Support because :uncommitted needs it before Rails is available
-module Kernel
- remove_method :silence_stderr # Removing old method to prevent method redefined warning
- def silence_stderr
- old_stderr = STDERR.dup
- STDERR.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
- STDERR.sync = true
- yield
- ensure
- STDERR.reopen(old_stderr)
- end
-end
-
task default: :test
desc 'Runs test:units, test:functionals, test:integration together'
@@ -80,45 +39,6 @@ namespace :test do
task :db => %w[db:test:prepare test:all]
end
- # Display deprecation message
- task :deprecated do
- ActiveSupport::Deprecation.warn "`rake #{ARGV.first}` is deprecated with no replacement."
- end
-
- Rake::TestTask.new(recent: ["test:deprecated", "test:prepare"]) do |t|
- since = TEST_CHANGES_SINCE
- touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
- recent_tests('app/models/**/*.rb', 'test/models', since) +
- recent_tests('app/models/**/*.rb', 'test/unit', since) +
- recent_tests('app/controllers/**/*.rb', 'test/controllers', since) +
- recent_tests('app/controllers/**/*.rb', 'test/functional', since)
-
- t.test_files = touched.uniq
- end
- Rake::Task['test:recent'].comment = "Deprecated; Test recent changes"
-
- Rake::TestTask.new(uncommitted: ["test:deprecated", "test:prepare"]) do |t|
- def t.file_list
- if File.directory?(".svn")
- changed_since_checkin = silence_stderr { `svn status` }.split.map { |path| path.chomp[7 .. -1] }
- elsif system "git rev-parse --git-dir 2>&1 >/dev/null"
- changed_since_checkin = silence_stderr { `git ls-files --modified --others --exclude-standard` }.split.map { |path| path.chomp }
- else
- abort "Not a Subversion or Git checkout."
- end
-
- models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ }
- controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ }
-
- unit_tests = models.map { |model| "test/models/#{File.basename(model, '.rb')}_test.rb" } +
- models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" } +
- functional_tests = controllers.map { |controller| "test/controllers/#{File.basename(controller, '.rb')}_test.rb" } +
- controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
- (unit_tests + functional_tests).uniq.select { |file| File.exist?(file) }
- end
- end
- Rake::Task['test:uncommitted'].comment = "Deprecated; Test changes since last checkin (only Subversion and Git)"
-
Rails::TestTask.new(single: "test:prepare")
["models", "helpers", "controllers", "mailers", "integration"].each do |name|
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index 94446c6c1b..633d864dac 100644
--- a/railties/test/application/assets_test.rb
+++ b/railties/test/application/assets_test.rb
@@ -165,6 +165,29 @@ module ApplicationTests
assert_file_exists("#{app_path}/public/assets/something-*.js")
end
+ test 'precompile use assets defined in app env config' do
+ add_to_env_config 'production', 'config.assets.precompile = [ "something.js" ]'
+
+ app_file 'app/assets/javascripts/something.js.erb', 'alert();'
+
+ precompile! 'RAILS_ENV=production'
+
+ assert_file_exists("#{app_path}/public/assets/something-*.js")
+ end
+
+ test 'precompile use assets defined in app config and reassigned in app env config' do
+ add_to_config 'config.assets.precompile = [ "something.js" ]'
+ add_to_env_config 'production', 'config.assets.precompile += [ "another.js" ]'
+
+ app_file 'app/assets/javascripts/something.js.erb', 'alert();'
+ app_file 'app/assets/javascripts/another.js.erb', 'alert();'
+
+ precompile! 'RAILS_ENV=production'
+
+ assert_file_exists("#{app_path}/public/assets/something-*.js")
+ assert_file_exists("#{app_path}/public/assets/another-*.js")
+ end
+
test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do
add_to_config "config.assets.digest = true"
add_to_config "config.action_controller.perform_caching = false"
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index 746ebdaa35..8e5310afee 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -101,45 +101,6 @@ module ApplicationTests
Dir.chdir(app_path){ `rake stats` }
end
- def test_rake_test_uncommitted_always_find_git_in_parent_dir
- return "FIXME :'("
- app_name = File.basename(app_path)
- app_dir = File.dirname(app_path)
- moved_app_name = app_name + '_moved'
-
- Dir.chdir(app_dir) do
- # Go from "./app/" to "./app/app_moved"
- FileUtils.mv(app_name, moved_app_name)
- FileUtils.mkdir(app_name)
- FileUtils.mv(moved_app_name, app_name)
- # Initialize the git repository and start the test.
- Dir.chdir(app_name) do
- `git init`
- Dir.chdir(moved_app_name){ `rake db:migrate` }
- silence_stderr { Dir.chdir(moved_app_name) { `rake test:uncommitted` } }
- assert_equal 0, $?.exitstatus
- end
- end
- end
-
- def test_rake_test_uncommitted_fails_with_no_scm
- Dir.chdir(app_path){ `rake db:migrate` }
- Dir.chdir(app_path) do
- silence_stderr { `rake test:uncommitted` }
- assert_equal 1, $?.exitstatus
- end
- end
-
- def test_rake_test_deprecation_messages
- Dir.chdir(app_path){ `rails generate scaffold user name:string` }
- Dir.chdir(app_path){ `rake db:migrate` }
-
- %w(recent uncommitted).each do |test_suit_name|
- output = Dir.chdir(app_path) { `rake test:#{test_suit_name} 2>&1` }
- assert_match(/DEPRECATION WARNING: `rake test:#{test_suit_name}` is deprecated/, output)
- end
- end
-
def test_rake_routes_calls_the_route_inspector
app_file "config/routes.rb", <<-RUBY
Rails.application.routes.draw do
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
index 05e9c4ab6e..50253fe2bc 100644
--- a/railties/test/railties/engine_test.rb
+++ b/railties/test/railties/engine_test.rb
@@ -345,7 +345,7 @@ YAML
#{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/locale/en.yml
#{RAILS_FRAMEWORK_ROOT}/activemodel/lib/active_model/locale/en.yml
#{RAILS_FRAMEWORK_ROOT}/activerecord/lib/active_record/locale/en.yml
- #{RAILS_FRAMEWORK_ROOT}/actionpack/lib/action_view/locale/en.yml
+ #{RAILS_FRAMEWORK_ROOT}/actionview/lib/action_view/locale/en.yml
#{@plugin.path}/config/locales/en.yml
#{app_path}/config/locales/en.yml
#{app_path}/app/locales/en.yml