diff options
64 files changed, 284 insertions, 131 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index a291e94936..95dc680c67 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,78 +17,78 @@ GIT PATH remote: . specs: - actioncable (6.0.0.beta1) - actionpack (= 6.0.0.beta1) + actioncable (6.0.0.beta2) + actionpack (= 6.0.0.beta2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.0.beta1) - actionpack (= 6.0.0.beta1) - activejob (= 6.0.0.beta1) - activerecord (= 6.0.0.beta1) - activestorage (= 6.0.0.beta1) - activesupport (= 6.0.0.beta1) + actionmailbox (6.0.0.beta2) + actionpack (= 6.0.0.beta2) + activejob (= 6.0.0.beta2) + activerecord (= 6.0.0.beta2) + activestorage (= 6.0.0.beta2) + activesupport (= 6.0.0.beta2) mail (>= 2.7.1) - actionmailer (6.0.0.beta1) - actionpack (= 6.0.0.beta1) - actionview (= 6.0.0.beta1) - activejob (= 6.0.0.beta1) + actionmailer (6.0.0.beta2) + actionpack (= 6.0.0.beta2) + actionview (= 6.0.0.beta2) + activejob (= 6.0.0.beta2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.0.beta1) - actionview (= 6.0.0.beta1) - activesupport (= 6.0.0.beta1) + actionpack (6.0.0.beta2) + actionview (= 6.0.0.beta2) + activesupport (= 6.0.0.beta2) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actiontext (6.0.0.beta1) - actionpack (= 6.0.0.beta1) - activerecord (= 6.0.0.beta1) - activestorage (= 6.0.0.beta1) - activesupport (= 6.0.0.beta1) + actiontext (6.0.0.beta2) + actionpack (= 6.0.0.beta2) + activerecord (= 6.0.0.beta2) + activestorage (= 6.0.0.beta2) + activesupport (= 6.0.0.beta2) nokogiri (>= 1.8.5) - actionview (6.0.0.beta1) - activesupport (= 6.0.0.beta1) + actionview (6.0.0.beta2) + activesupport (= 6.0.0.beta2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (6.0.0.beta1) - activesupport (= 6.0.0.beta1) + activejob (6.0.0.beta2) + activesupport (= 6.0.0.beta2) globalid (>= 0.3.6) - activemodel (6.0.0.beta1) - activesupport (= 6.0.0.beta1) - activerecord (6.0.0.beta1) - activemodel (= 6.0.0.beta1) - activesupport (= 6.0.0.beta1) - activestorage (6.0.0.beta1) - actionpack (= 6.0.0.beta1) - activerecord (= 6.0.0.beta1) + activemodel (6.0.0.beta2) + activesupport (= 6.0.0.beta2) + activerecord (6.0.0.beta2) + activemodel (= 6.0.0.beta2) + activesupport (= 6.0.0.beta2) + activestorage (6.0.0.beta2) + actionpack (= 6.0.0.beta2) + activerecord (= 6.0.0.beta2) marcel (~> 0.3.1) - activesupport (6.0.0.beta1) + activesupport (6.0.0.beta2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) zeitwerk (~> 1.3, >= 1.3.1) - rails (6.0.0.beta1) - actioncable (= 6.0.0.beta1) - actionmailbox (= 6.0.0.beta1) - actionmailer (= 6.0.0.beta1) - actionpack (= 6.0.0.beta1) - actiontext (= 6.0.0.beta1) - actionview (= 6.0.0.beta1) - activejob (= 6.0.0.beta1) - activemodel (= 6.0.0.beta1) - activerecord (= 6.0.0.beta1) - activestorage (= 6.0.0.beta1) - activesupport (= 6.0.0.beta1) + rails (6.0.0.beta2) + actioncable (= 6.0.0.beta2) + actionmailbox (= 6.0.0.beta2) + actionmailer (= 6.0.0.beta2) + actionpack (= 6.0.0.beta2) + actiontext (= 6.0.0.beta2) + actionview (= 6.0.0.beta2) + activejob (= 6.0.0.beta2) + activemodel (= 6.0.0.beta2) + activerecord (= 6.0.0.beta2) + activestorage (= 6.0.0.beta2) + activesupport (= 6.0.0.beta2) bundler (>= 1.3.0) - railties (= 6.0.0.beta1) + railties (= 6.0.0.beta2) sprockets-rails (>= 2.0.0) - railties (6.0.0.beta1) - actionpack (= 6.0.0.beta1) - activesupport (= 6.0.0.beta1) + railties (6.0.0.beta2) + actionpack (= 6.0.0.beta2) + activesupport (= 6.0.0.beta2) method_source rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) @@ -246,7 +246,7 @@ GEM fugit (1.1.6) et-orbi (~> 1.1, >= 1.1.6) raabro (~> 1.1) - globalid (0.4.1) + globalid (0.4.2) activesupport (>= 4.2.0) google-api-client (0.25.0) addressable (~> 2.5, >= 2.5.1) diff --git a/RAILS_VERSION b/RAILS_VERSION index 248da9b7b5..21cfcbd0d8 100644 --- a/RAILS_VERSION +++ b/RAILS_VERSION @@ -1 +1 @@ -6.0.0.beta1 +6.0.0.beta2 diff --git a/actioncable/CHANGELOG.md b/actioncable/CHANGELOG.md index 600d4e130f..aa72cec9cb 100644 --- a/actioncable/CHANGELOG.md +++ b/actioncable/CHANGELOG.md @@ -1,3 +1,5 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + * PostgreSQL subscription adapters now support `channel_prefix` option in cable.yml Avoids channel name collisions when multiple apps use the same database for Action Cable. diff --git a/actioncable/lib/action_cable/gem_version.rb b/actioncable/lib/action_cable/gem_version.rb index 5082827417..728b3e90cb 100644 --- a/actioncable/lib/action_cable/gem_version.rb +++ b/actioncable/lib/action_cable/gem_version.rb @@ -10,7 +10,7 @@ module ActionCable MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actioncable/package.json b/actioncable/package.json index 801fcc0c22..f6691e10d1 100644 --- a/actioncable/package.json +++ b/actioncable/package.json @@ -1,6 +1,6 @@ { "name": "@rails/actioncable", - "version": "6.0.0-beta1", + "version": "6.0.0-beta2", "description": "WebSocket framework for Ruby on Rails.", "main": "app/assets/javascripts/action_cable.js", "files": [ diff --git a/actionmailbox/CHANGELOG.md b/actionmailbox/CHANGELOG.md index 3e92283c12..d47f72fff7 100644 --- a/actionmailbox/CHANGELOG.md +++ b/actionmailbox/CHANGELOG.md @@ -1,3 +1,5 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + * Allow skipping incineration of processed emails. This can be done by setting `config.action_mailbox.incinerate` to `false`. diff --git a/actionmailbox/lib/action_mailbox/gem_version.rb b/actionmailbox/lib/action_mailbox/gem_version.rb index 1f9c4272b9..e7e3317f16 100644 --- a/actionmailbox/lib/action_mailbox/gem_version.rb +++ b/actionmailbox/lib/action_mailbox/gem_version.rb @@ -10,7 +10,7 @@ module ActionMailbox MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md index 806e428481..e9d8d07c79 100644 --- a/actionmailer/CHANGELOG.md +++ b/actionmailer/CHANGELOG.md @@ -1,3 +1,8 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + +* No changes. + + ## Rails 6.0.0.beta1 (January 18, 2019) ## * Deprecate `ActionMailer::Base.receive` in favor of [Action Mailbox](https://github.com/rails/rails/tree/master/actionmailbox). diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 033a7f5b9e..52360d40fe 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -973,7 +973,7 @@ module ActionMailer templates_name = headers[:template_name] || action_name each_template(Array(templates_path), templates_name).map do |template| - self.formats = template.formats + self.formats = [template.format] { body: render(template: template), content_type: template.type.to_s @@ -986,7 +986,7 @@ module ActionMailer if templates.empty? raise ActionView::MissingTemplate.new(paths, name, paths, false, "mailer") else - templates.uniq(&:formats).each(&block) + templates.uniq(&:format).each(&block) end end diff --git a/actionmailer/lib/action_mailer/gem_version.rb b/actionmailer/lib/action_mailer/gem_version.rb index 4cab52d1f3..3002fd2ad6 100644 --- a/actionmailer/lib/action_mailer/gem_version.rb +++ b/actionmailer/lib/action_mailer/gem_version.rb @@ -10,7 +10,7 @@ module ActionMailer MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionmailer/lib/action_mailer/mail_delivery_job.rb b/actionmailer/lib/action_mailer/mail_delivery_job.rb index 93778edfce..609c6a72d9 100644 --- a/actionmailer/lib/action_mailer/mail_delivery_job.rb +++ b/actionmailer/lib/action_mailer/mail_delivery_job.rb @@ -3,7 +3,7 @@ require "active_job" module ActionMailer - # The <tt>ActionMailer::NewDeliveryJob</tt> class is used when you + # The <tt>ActionMailer::MailDeliveryJob</tt> class is used when you # want to send emails outside of the request-response cycle. It supports # sending either parameterized or normal mail. # diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 23ac619f50..8eaaee5100 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,5 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + * Make debug exceptions works in an environment where ActiveStorage is not loaded. *Tomoyuki Kurosawa* diff --git a/actionpack/lib/action_controller/metal/live.rb b/actionpack/lib/action_controller/metal/live.rb index 083b762f5a..eb43ff9c63 100644 --- a/actionpack/lib/action_controller/metal/live.rb +++ b/actionpack/lib/action_controller/metal/live.rb @@ -146,7 +146,7 @@ module ActionController def write(string) unless @response.committed? - @response.set_header "Cache-Control", "no-cache" + @response.headers["Cache-Control"] ||= "no-cache" @response.delete_header "Content-Length" end diff --git a/actionpack/lib/action_pack/gem_version.rb b/actionpack/lib/action_pack/gem_version.rb index c7cb3cb91e..8007cfe35b 100644 --- a/actionpack/lib/action_pack/gem_version.rb +++ b/actionpack/lib/action_pack/gem_version.rb @@ -10,7 +10,7 @@ module ActionPack MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionpack/test/dispatch/debug_exceptions_test.rb b/actionpack/test/dispatch/debug_exceptions_test.rb index 6914fb66f9..c33b0e1c14 100644 --- a/actionpack/test/dispatch/debug_exceptions_test.rb +++ b/actionpack/test/dispatch/debug_exceptions_test.rb @@ -39,7 +39,7 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest def call(env) env["action_dispatch.show_detailed_exceptions"] = @detailed req = ActionDispatch::Request.new(env) - template = ActionView::Template.new(File.read(__FILE__), __FILE__, ActionView::Template::Handlers::Raw.new, {}) + template = ActionView::Template.new(File.read(__FILE__), __FILE__, ActionView::Template::Handlers::Raw.new, format: :html) case req.path when "/pass" diff --git a/actionpack/test/dispatch/live_response_test.rb b/actionpack/test/dispatch/live_response_test.rb index b673fd3805..f2459112b2 100644 --- a/actionpack/test/dispatch/live_response_test.rb +++ b/actionpack/test/dispatch/live_response_test.rb @@ -51,11 +51,17 @@ module ActionController assert_equal ["omg"], @response.body_parts end - def test_cache_control_is_set + def test_cache_control_is_set_by_default @response.stream.write "omg" assert_equal "no-cache", @response.headers["Cache-Control"] end + def test_cache_control_is_set_manually + @response.set_header("Cache-Control", "public") + @response.stream.write "omg" + assert_equal "public", @response.headers["Cache-Control"] + end + def test_content_length_is_removed @response.headers["Content-Length"] = "1234" @response.stream.write "omg" diff --git a/actiontext/CHANGELOG.md b/actiontext/CHANGELOG.md index d92367dc17..203800da1f 100644 --- a/actiontext/CHANGELOG.md +++ b/actiontext/CHANGELOG.md @@ -1,3 +1,8 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + +* No changes. + + ## Rails 6.0.0.beta1 (January 18, 2019) ## * Added to Rails. diff --git a/actiontext/lib/action_text/gem_version.rb b/actiontext/lib/action_text/gem_version.rb index 5404ac54e9..da2a9212d3 100644 --- a/actiontext/lib/action_text/gem_version.rb +++ b/actiontext/lib/action_text/gem_version.rb @@ -10,7 +10,7 @@ module ActionText MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actiontext/package.json b/actiontext/package.json index a24026bc51..6408d38765 100644 --- a/actiontext/package.json +++ b/actiontext/package.json @@ -1,6 +1,6 @@ { "name": "@rails/actiontext", - "version": "6.0.0-beta1", + "version": "6.0.0-beta2", "description": "Edit and display rich text in Rails applications", "main": "app/javascript/actiontext/index.js", "files": [ diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 5e7b271fb9..2e6c37de58 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,5 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + * ActionView::Template.finalize_compiled_template_methods is deprecated with no replacement. diff --git a/actionview/lib/action_view/file_template.rb b/actionview/lib/action_view/file_template.rb index 4921074383..cdc077a01a 100644 --- a/actionview/lib/action_view/file_template.rb +++ b/actionview/lib/action_view/file_template.rb @@ -22,11 +22,11 @@ module ActionView # to ensure that references to the template object can be marshalled as well. This means forgoing # the marshalling of the compiler mutex and instantiating that again on unmarshalling. def marshal_dump # :nodoc: - [ @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants ] + [ @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant ] end def marshal_load(array) # :nodoc: - @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants = *array + @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant = *array @compile_mutex = Mutex.new end end diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb index 02de3eeec2..c799967cc5 100644 --- a/actionview/lib/action_view/gem_version.rb +++ b/actionview/lib/action_view/gem_version.rb @@ -10,7 +10,7 @@ module ActionView MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb index 6b69b71947..020aebeea3 100644 --- a/actionview/lib/action_view/helpers/cache_helper.rb +++ b/actionview/lib/action_view/helpers/cache_helper.rb @@ -217,7 +217,7 @@ module ActionView end def digest_path_from_template(template) # :nodoc: - digest = Digestor.digest(name: template.virtual_path, format: template.formats.first, finder: lookup_context, dependencies: view_cache_dependencies) + digest = Digestor.digest(name: template.virtual_path, format: template.format, finder: lookup_context, dependencies: view_cache_dependencies) if digest.present? "#{template.virtual_path}:#{digest}" diff --git a/actionview/lib/action_view/renderer/abstract_renderer.rb b/actionview/lib/action_view/renderer/abstract_renderer.rb index f1b4c9b92d..475452f1bb 100644 --- a/actionview/lib/action_view/renderer/abstract_renderer.rb +++ b/actionview/lib/action_view/renderer/abstract_renderer.rb @@ -68,7 +68,7 @@ module ActionView end def format - template.formats.first + template.format end EMPTY_SPACER = Struct.new(:body).new diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index 87f6cf3de3..83b990b081 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -8,7 +8,7 @@ module ActionView @details = extract_details(options) template = determine_template(options) - prepend_formats(template.formats) + prepend_formats(template.format) render_template(context, template, options[:layout], options[:locals] || {}) end diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 133a316405..f67c90de76 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -122,14 +122,16 @@ module ActionView extend Template::Handlers - attr_accessor :locals, :formats, :variants, :virtual_path + attr_accessor :locals, :virtual_path attr_reader :source, :identifier, :handler, :original_encoding, :updated_at + attr_reader :variable, :format, :variant - attr_reader :variable - - def initialize(source, identifier, handler, details) - format = details[:format] || (handler.default_format if handler.respond_to?(:default_format)) + def initialize(source, identifier, handler, format: nil, variant: nil, **details) + unless format + ActiveSupport::Deprecation.warn "ActionView::Template#initialize requires a format parameter" + format = :html + end @source = source @identifier = identifier @@ -146,11 +148,16 @@ module ActionView end @updated_at = details[:updated_at] || Time.now - @formats = Array(format).map { |f| f.respond_to?(:ref) ? f.ref : f } - @variants = [details[:variant]] + @format = format + @variant = variant @compile_mutex = Mutex.new end + deprecate def formats=(_); end + deprecate def formats; Array(format); end + deprecate def variants=(_); end + deprecate def variants; [variant]; end + # Returns whether the underlying handler supports streaming. If so, # a streaming buffer *may* be passed when it starts rendering. def supports_streaming? @@ -173,7 +180,7 @@ module ActionView end def type - @type ||= Types[@formats.first] if @formats.first + @type ||= Types[format] end # Receives a view object and return a template similar to self by using @virtual_path. @@ -195,8 +202,12 @@ module ActionView end end + def short_identifier + @short_identifier ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", "") : identifier + end + def inspect - @inspect ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", "") : identifier + "#<#{self.class.name} #{short_identifier} locals=#{@locals.inspect}>" end # This method is responsible for properly setting the encoding of the @@ -250,11 +261,11 @@ module ActionView # to ensure that references to the template object can be marshalled as well. This means forgoing # the marshalling of the compiler mutex and instantiating that again on unmarshalling. def marshal_dump # :nodoc: - [ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants ] + [ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant ] end def marshal_load(array) # :nodoc: - @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants = *array + @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @format, @variant = *array @compile_mutex = Mutex.new end @@ -370,7 +381,7 @@ module ActionView end def identifier_method_name - inspect.tr("^a-z_", "_") + short_identifier.tr("^a-z_", "_") end def instrument(action, &block) # :doc: diff --git a/actionview/lib/action_view/template/html.rb b/actionview/lib/action_view/template/html.rb index a262c6d9ad..ecd1c31e79 100644 --- a/actionview/lib/action_view/template/html.rb +++ b/actionview/lib/action_view/template/html.rb @@ -1,15 +1,21 @@ # frozen_string_literal: true +require "active_support/deprecation" + module ActionView #:nodoc: # = Action View HTML Template class Template #:nodoc: class HTML #:nodoc: - attr_accessor :type + attr_reader :type def initialize(string, type = nil) + unless type + ActiveSupport::Deprecation.warn "ActionView::Template::HTML#initialize requires a type parameter" + type = :html + end + @string = string.to_s - @type = Types[type] || type if type - @type ||= Types[:html] + @type = type end def identifier @@ -26,9 +32,12 @@ module ActionView #:nodoc: to_str end - def formats - [@type.respond_to?(:ref) ? @type.ref : @type.to_s] + def format + @type end + + def formats; Array(format); end + deprecate :formats end end end diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index 3b4594942b..6f0bf4187e 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -196,8 +196,6 @@ module ActionView cached = nil templates.each do |t| t.locals = locals - t.formats = details[:formats] || [:html] if t.formats.empty? - t.variants = details[:variants] || [] if t.variants.empty? t.virtual_path ||= (cached ||= build_path(*path_info)) end end @@ -225,7 +223,7 @@ module ActionView template_paths = reject_files_external_to_app(template_paths) unless outside_app_allowed template_paths.map do |template| - handler, format, variant = extract_handler_and_format_and_variant(template) + handler, format, variant = extract_handler_and_format_and_variant(template, formats.first) FileTemplate.new(File.expand_path(template), handler, virtual_path: path.virtual, @@ -292,7 +290,7 @@ module ActionView # Extract handler, formats and variant from path. If a format cannot be found neither # from the path, or the handler, we should return the array of formats given # to the resolver. - def extract_handler_and_format_and_variant(path) + def extract_handler_and_format_and_variant(path, query_format) pieces = File.basename(path).split(".") pieces.shift @@ -300,9 +298,18 @@ module ActionView handler = Template.handler_for_extension(extension) format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last - format &&= Template::Types[format] + format = if format + Template::Types[format]&.ref + else + if handler.respond_to?(:default_format) # default_format can return nil + handler.default_format + else + query_format + end + end - [handler, format, variant] + # Template::Types[format] and handler.default_format can return nil + [handler, format || query_format, variant] end end diff --git a/actionview/lib/action_view/template/text.rb b/actionview/lib/action_view/template/text.rb index f8d6c2811f..c5fd55f1b3 100644 --- a/actionview/lib/action_view/template/text.rb +++ b/actionview/lib/action_view/template/text.rb @@ -8,7 +8,6 @@ module ActionView #:nodoc: def initialize(string) @string = string.to_s - @type = Types[:text] end def identifier @@ -25,9 +24,12 @@ module ActionView #:nodoc: to_str end - def formats - [@type.ref] + def format + :text end + + def formats; Array(format); end + deprecate :formats end end end diff --git a/actionview/lib/action_view/testing/resolvers.rb b/actionview/lib/action_view/testing/resolvers.rb index d6203b95c5..275e2e9182 100644 --- a/actionview/lib/action_view/testing/resolvers.rb +++ b/actionview/lib/action_view/testing/resolvers.rb @@ -34,7 +34,7 @@ module ActionView #:nodoc: @hash.each do |_path, array| source, updated_at = array next unless query.match?(_path) - handler, format, variant = extract_handler_and_format_and_variant(_path) + handler, format, variant = extract_handler_and_format_and_variant(_path, :html) templates << Template.new(source, _path, handler, virtual_path: path.virtual, format: format, @@ -49,7 +49,7 @@ module ActionView #:nodoc: class NullResolver < PathResolver def query(path, exts, _, _) - handler, format, variant = extract_handler_and_format_and_variant(path) + handler, format, variant = extract_handler_and_format_and_variant(path, :html) [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant)] end end diff --git a/actionview/package.json b/actionview/package.json index eb2a9f879e..98827efd62 100644 --- a/actionview/package.json +++ b/actionview/package.json @@ -1,6 +1,6 @@ { "name": "@rails/ujs", - "version": "6.0.0-beta1", + "version": "6.0.0-beta2", "description": "Ruby on Rails unobtrusive scripting adapter", "main": "lib/assets/compiled/rails-ujs.js", "files": [ diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index b649b3c9dd..e0a1f59755 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -60,7 +60,7 @@ module RenderERBUtils string.strip, "test template", ActionView::Template.handler_for_extension(:erb), - {}) + format: :html) view = ActionView::Base.with_empty_template_cache template.render(view.empty, {}).strip diff --git a/actionview/test/actionpack/controller/view_paths_test.rb b/actionview/test/actionpack/controller/view_paths_test.rb index c5238dd746..a7a58a78cc 100644 --- a/actionview/test/actionpack/controller/view_paths_test.rb +++ b/actionview/test/actionpack/controller/view_paths_test.rb @@ -144,7 +144,7 @@ class ViewLoadPathsTest < ActionController::TestCase template.identifier, template.handler, virtual_path: template.virtual_path, - format: template.formats + format: template.format ) end end diff --git a/actionview/test/template/digestor_test.rb b/actionview/test/template/digestor_test.rb index 91861edf11..7affd3c005 100644 --- a/actionview/test/template/digestor_test.rb +++ b/actionview/test/template/digestor_test.rb @@ -361,7 +361,7 @@ class TemplateDigestorTest < ActionView::TestCase def tree_template_formats(template_name) tree = ActionView::Digestor.tree(template_name, finder) - tree.flatten.map(&:template).compact.flat_map(&:formats) + tree.flatten.map(&:template).compact.map(&:format) end def disable_resolver_caching diff --git a/actionview/test/template/html_test.rb b/actionview/test/template/html_test.rb index 5cdff74d60..c5fc8f906c 100644 --- a/actionview/test/template/html_test.rb +++ b/actionview/test/template/html_test.rb @@ -4,16 +4,16 @@ require "abstract_unit" class HTMLTest < ActiveSupport::TestCase test "formats returns symbol for recognized MIME type" do - assert_equal [:html], ActionView::Template::HTML.new("", :html).formats + assert_equal :html, ActionView::Template::HTML.new("", :html).format end test "formats returns string for recognized MIME type when MIME does not have symbol" do foo = Mime::Type.lookup("foo") assert_nil foo.to_sym - assert_equal ["foo"], ActionView::Template::HTML.new("", foo).formats + assert_equal "foo", ActionView::Template::HTML.new("", foo).format end test "formats returns string for unknown MIME type" do - assert_equal ["foo"], ActionView::Template::HTML.new("", "foo").formats + assert_equal "foo", ActionView::Template::HTML.new("", "foo").format end end diff --git a/actionview/test/template/lookup_context_test.rb b/actionview/test/template/lookup_context_test.rb index 5298afb694..a763e24226 100644 --- a/actionview/test/template/lookup_context_test.rb +++ b/actionview/test/template/lookup_context_test.rb @@ -125,7 +125,7 @@ class LookupContextTest < ActiveSupport::TestCase assert_called(ActionView::Template::Handlers::Builder, :default_format, returns: nil) do @lookup_context.formats = [:text] template = @lookup_context.find("hello", %w(test)) - assert_equal [:text], template.formats + assert_equal :text, template.format end end diff --git a/actionview/test/template/resolver_patterns_test.rb b/actionview/test/template/resolver_patterns_test.rb index 1e1a4c5063..38357aa10b 100644 --- a/actionview/test/template/resolver_patterns_test.rb +++ b/actionview/test/template/resolver_patterns_test.rb @@ -19,7 +19,7 @@ class ResolverPatternsTest < ActiveSupport::TestCase assert_equal 1, templates.size, "expected one template" assert_equal "Hello custom patterns!", templates.first.source assert_equal "custom_pattern/path", templates.first.virtual_path - assert_equal [:html], templates.first.formats + assert_equal :html, templates.first.format end def test_should_return_all_templates_when_ambiguous_pattern diff --git a/actionview/test/template/template_test.rb b/actionview/test/template/template_test.rb index a069c8f2d0..c74305fb42 100644 --- a/actionview/test/template/template_test.rb +++ b/actionview/test/template/template_test.rb @@ -38,7 +38,8 @@ class TestERBTemplate < ActiveSupport::TestCase "<%= @virtual_path %>", "partial", ERBHandler, - virtual_path: "partial" + virtual_path: "partial", + format: :html ) end @@ -55,7 +56,8 @@ class TestERBTemplate < ActiveSupport::TestCase end end - def new_template(body = "<%= hello %>", details = { format: :html }) + def new_template(body = "<%= hello %>", details = {}) + details = { format: :html }.merge details ActionView::Template.new(body.dup, "hello template", details.fetch(:handler) { ERBHandler }, { virtual_path: "hello" }.merge!(details)) end @@ -213,4 +215,14 @@ class TestERBTemplate < ActiveSupport::TestCase ensure silence_warnings { Encoding.default_external = old } end + + def test_short_identifier + @template = new_template("hello") + assert_equal "hello template", @template.short_identifier + end + + def test_template_inspect + @template = new_template("hello") + assert_equal "#<ActionView::Template hello template locals=[]>", @template.inspect + end end diff --git a/actionview/test/template/testing/fixture_resolver_test.rb b/actionview/test/template/testing/fixture_resolver_test.rb index 9954e3500d..4361824a71 100644 --- a/actionview/test/template/testing/fixture_resolver_test.rb +++ b/actionview/test/template/testing/fixture_resolver_test.rb @@ -15,6 +15,6 @@ class FixtureResolverTest < ActiveSupport::TestCase assert_equal 1, templates.size, "expected one template" assert_equal "this text", templates.first.source assert_equal "arbitrary/path", templates.first.virtual_path - assert_equal [:html], templates.first.formats + assert_equal :html, templates.first.format end end diff --git a/actionview/test/template/testing/null_resolver_test.rb b/actionview/test/template/testing/null_resolver_test.rb index 53364c1d90..dad8d0966d 100644 --- a/actionview/test/template/testing/null_resolver_test.rb +++ b/actionview/test/template/testing/null_resolver_test.rb @@ -9,6 +9,6 @@ class NullResolverTest < ActiveSupport::TestCase assert_equal 1, templates.size, "expected one template" assert_equal "Template generated by Null Resolver", templates.first.source assert_equal "arbitrary/path.erb", templates.first.virtual_path.to_s - assert_equal [:html], templates.first.formats + assert_equal :html, templates.first.format end end diff --git a/actionview/test/template/text_test.rb b/actionview/test/template/text_test.rb index 0c6470df21..c837c53587 100644 --- a/actionview/test/template/text_test.rb +++ b/actionview/test/template/text_test.rb @@ -3,8 +3,8 @@ require "abstract_unit" class TextTest < ActiveSupport::TestCase - test "formats always return :text" do - assert_equal [:text], ActionView::Template::Text.new("").formats + test "format always return :text" do + assert_equal :text, ActionView::Template::Text.new("").format end test "identifier should return 'text template'" do diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md index 0ed937f4cc..f782b2d69f 100644 --- a/activejob/CHANGELOG.md +++ b/activejob/CHANGELOG.md @@ -1,3 +1,8 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + +* No changes. + + ## Rails 6.0.0.beta1 (January 18, 2019) ## * Return false instead of the job instance when `enqueue` is aborted. diff --git a/activejob/lib/active_job/gem_version.rb b/activejob/lib/active_job/gem_version.rb index 2b894397e3..f303dcddf5 100644 --- a/activejob/lib/active_job/gem_version.rb +++ b/activejob/lib/active_job/gem_version.rb @@ -10,7 +10,7 @@ module ActiveJob MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 55e0c85b00..a644c63992 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,3 +1,5 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + * Fix date value when casting a multiparameter date hash to not convert from Gregorian date to Julian date. diff --git a/activemodel/lib/active_model/gem_version.rb b/activemodel/lib/active_model/gem_version.rb index b0322f62c7..399e724cea 100644 --- a/activemodel/lib/active_model/gem_version.rb +++ b/activemodel/lib/active_model/gem_version.rb @@ -10,7 +10,7 @@ module ActiveModel MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 7e153a6642..4323c57b9e 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,12 @@ +* Fix different `count` calculation when using `size` with manual `select` with DISTINCT. + + Fixes #35214. + + *Juani Villarejo* + + +## Rails 6.0.0.beta2 (February 25, 2019) ## + * Fix prepared statements caching to be enabled even when query caching is enabled. *Ryuta Kamizono* diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index c1d846f58d..f205d77ddb 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -102,7 +102,7 @@ module ActiveRecord end def self.build_read_query_regexp(*parts) # :nodoc: - parts = parts.map { |part| /\A\s*#{part}/i } + parts = parts.map { |part| /\A[\(\s]*#{part}/i } Regexp.union(*parts) end diff --git a/activerecord/lib/active_record/gem_version.rb b/activerecord/lib/active_record/gem_version.rb index 16dff9c2b0..345441eea8 100644 --- a/activerecord/lib/active_record/gem_version.rb +++ b/activerecord/lib/active_record/gem_version.rb @@ -10,7 +10,7 @@ module ActiveRecord MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index bdd3c540bb..4f9ddf302e 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -221,7 +221,6 @@ module ActiveRecord end private - def has_include?(column_name) eager_loading? || (includes_values.present? && column_name && column_name != :all) end @@ -236,10 +235,12 @@ module ActiveRecord if operation == "count" column_name ||= select_for_count if column_name == :all - if distinct && (group_values.any? || select_values.empty? && order_values.empty?) + if !distinct + distinct = distinct_select?(select_for_count) if group_values.empty? + elsif group_values.any? || select_values.empty? && order_values.empty? column_name = primary_key end - elsif column_name.is_a?(::String) && /\bDISTINCT[\s(]/i.match?(column_name) + elsif distinct_select?(column_name) distinct = nil end end @@ -251,6 +252,10 @@ module ActiveRecord end end + def distinct_select?(column_name) + column_name.is_a?(::String) && /\bDISTINCT[\s(]/i.match?(column_name) + end + def aggregate_column(column_name) return column_name if Arel::Expressions === column_name diff --git a/activerecord/test/cases/adapters/mysql2/mysql2_adapter_test.rb b/activerecord/test/cases/adapters/mysql2/mysql2_adapter_test.rb index ed3f669331..a5b53f76b4 100644 --- a/activerecord/test/cases/adapters/mysql2/mysql2_adapter_test.rb +++ b/activerecord/test/cases/adapters/mysql2/mysql2_adapter_test.rb @@ -204,6 +204,14 @@ class Mysql2AdapterTest < ActiveRecord::Mysql2TestCase end end + def test_doesnt_error_when_a_read_query_with_leading_chars_is_called_while_preventing_writes + @conn.execute("INSERT INTO `engines` (`car_id`) VALUES ('138853948594')") + + @conn.while_preventing_writes do + assert_equal 1, @conn.execute("(\n( SELECT `engines`.* FROM `engines` WHERE `engines`.`car_id` = '138853948594' ) )").entries.count + end + end + private def with_example_table(definition = "id int auto_increment primary key, number int, data varchar(255)", &block) diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb index 34b4fc344b..fbd3cbf90f 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -432,6 +432,16 @@ module ActiveRecord end end + def test_doesnt_error_when_a_read_query_with_leading_chars_is_called_while_preventing_writes + with_example_table do + @connection.execute("INSERT INTO ex (data) VALUES ('138853948594')") + + @connection.while_preventing_writes do + assert_equal 1, @connection.execute("(\n( SELECT * FROM ex WHERE data = '138853948594' ) )").entries.count + end + end + end + private def with_example_table(definition = "id serial primary key, number integer, data character varying(255)", &block) diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb index 5c41c14171..806cfbfc00 100644 --- a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb @@ -625,6 +625,16 @@ module ActiveRecord end end + def test_doesnt_error_when_a_read_query_with_leading_chars_is_called_while_preventing_writes + with_example_table "id int, data string" do + @conn.execute("INSERT INTO ex (data) VALUES ('138853948594')") + + @conn.while_preventing_writes do + assert_equal 1, @conn.execute(" SELECT data from ex WHERE data = '138853948594'").count + end + end + end + private def assert_logged(logs) diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 8ac2d55218..f1e35d6ab9 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -473,6 +473,24 @@ class CalculationsTest < ActiveRecord::TestCase assert_equal 6, Account.select("DISTINCT accounts.id").includes(:firm).count end + def test_should_count_manual_select_with_count_all + assert_equal 5, Account.select("DISTINCT accounts.firm_id").count(:all) + end + + def test_should_count_with_manual_distinct_select_and_distinct + assert_equal 4, Account.select("DISTINCT accounts.firm_id").distinct(true).count + end + + def test_should_count_manual_select_with_group_with_count_all + expected = { nil => 1, 1 => 1, 2 => 1, 6 => 2, 9 => 1 } + actual = Account.select("DISTINCT accounts.firm_id").group("accounts.firm_id").count(:all) + assert_equal expected, actual + end + + def test_should_count_manual_with_count_all + assert_equal 6, Account.count(:all) + end + def test_count_selected_arel_attribute assert_equal 5, Account.select(Account.arel_table[:firm_id]).count assert_equal 4, Account.distinct.select(Account.arel_table[:firm_id]).count diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 2de0a81c99..a7f09e6de0 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -972,6 +972,13 @@ class RelationTest < ActiveRecord::TestCase assert_queries(1) { assert_equal 11, posts.load.size } end + def test_size_with_eager_loading_and_manual_distinct_select_and_custom_order + accounts = Account.select("DISTINCT accounts.firm_id").order("accounts.firm_id") + + assert_queries(1) { assert_equal 5, accounts.size } + assert_queries(1) { assert_equal 5, accounts.load.size } + end + def test_count_explicit_columns Post.update_all(comments_count: nil) posts = Post.all @@ -1483,10 +1490,10 @@ class RelationTest < ActiveRecord::TestCase assert_equal [posts(:welcome)], relation.to_a author_posts = relation.except(:order, :limit) - assert_equal Post.where(author_id: 1).to_a, author_posts.to_a + assert_equal Post.where(author_id: 1).sort_by(&:id), author_posts.sort_by(&:id) all_posts = relation.except(:where, :order, :limit) - assert_equal Post.all, all_posts + assert_equal Post.all.sort_by(&:id), all_posts.sort_by(&:id) end def test_only @@ -1494,10 +1501,10 @@ class RelationTest < ActiveRecord::TestCase assert_equal [posts(:welcome)], relation.to_a author_posts = relation.only(:where) - assert_equal Post.where(author_id: 1).to_a, author_posts.to_a + assert_equal Post.where(author_id: 1).sort_by(&:id), author_posts.sort_by(&:id) - all_posts = relation.only(:limit) - assert_equal Post.limit(1).to_a, all_posts.to_a + all_posts = relation.only(:order) + assert_equal Post.order("id ASC").to_a, all_posts.to_a end def test_anonymous_extension diff --git a/activestorage/CHANGELOG.md b/activestorage/CHANGELOG.md index 0c7e0426ae..ba9204249d 100644 --- a/activestorage/CHANGELOG.md +++ b/activestorage/CHANGELOG.md @@ -1,3 +1,8 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + +* No changes. + + ## Rails 6.0.0.beta1 (January 18, 2019) ## * [Rename npm package](https://github.com/rails/rails/pull/34905) from diff --git a/activestorage/lib/active_storage/gem_version.rb b/activestorage/lib/active_storage/gem_version.rb index c4c7bf5677..046534fc07 100644 --- a/activestorage/lib/active_storage/gem_version.rb +++ b/activestorage/lib/active_storage/gem_version.rb @@ -10,7 +10,7 @@ module ActiveStorage MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/activestorage/package.json b/activestorage/package.json index f7b896b5ee..49b9163bd9 100644 --- a/activestorage/package.json +++ b/activestorage/package.json @@ -1,6 +1,6 @@ { "name": "@rails/activestorage", - "version": "6.0.0-beta1", + "version": "6.0.0-beta2", "description": "Attach cloud and local files in Rails applications", "main": "app/assets/javascripts/activestorage.js", "files": [ diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index c46b56833d..3f0c6fbd4e 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,5 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + * New autoloading based on [Zeitwerk](https://github.com/fxn/zeitwerk). *Xavier Noria* diff --git a/activesupport/lib/active_support/gem_version.rb b/activesupport/lib/active_support/gem_version.rb index 8bf016e88c..009bb895a6 100644 --- a/activesupport/lib/active_support/gem_version.rb +++ b/activesupport/lib/active_support/gem_version.rb @@ -10,7 +10,7 @@ module ActiveSupport MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/guides/CHANGELOG.md b/guides/CHANGELOG.md index 6432dbfd00..41037146a0 100644 --- a/guides/CHANGELOG.md +++ b/guides/CHANGELOG.md @@ -1,3 +1,8 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + +* No changes. + + ## Rails 6.0.0.beta1 (January 18, 2019) ## * Add "Action Text Overview" Guide. diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index d66add2ca0..9e8b38733a 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,5 @@ +## Rails 6.0.0.beta2 (February 25, 2019) ## + * Fix non-symbol access to nested hashes returned from `Rails::Application.config_for` being broken by allowing non-symbol access with a deprecation notice. diff --git a/railties/lib/rails/gem_version.rb b/railties/lib/rails/gem_version.rb index 82df56559c..249894f9d0 100644 --- a/railties/lib/rails/gem_version.rb +++ b/railties/lib/rails/gem_version.rb @@ -10,7 +10,7 @@ module Rails MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile.tt b/railties/lib/rails/generators/rails/app/templates/Gemfile.tt index 783254b54d..18de6948f0 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile.tt +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile.tt @@ -28,7 +28,7 @@ ruby <%= "'#{RUBY_VERSION}'" -%> <% if depend_on_bootsnap? -%> # Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.4.0', require: false +gem 'bootsnap', '>= 1.4.1', require: false <%- end -%> <%- if options.api? -%> diff --git a/version.rb b/version.rb index 82df56559c..249894f9d0 100644 --- a/version.rb +++ b/version.rb @@ -10,7 +10,7 @@ module Rails MAJOR = 6 MINOR = 0 TINY = 0 - PRE = "beta1" + PRE = "beta2" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end |