diff options
-rw-r--r-- | actionpack/lib/action_dispatch/railtie.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/system_test_case.rb | 13 | ||||
-rw-r--r-- | activerecord/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activerecord/lib/arel/predications.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/arel/attributes/attribute_test.rb | 24 | ||||
-rw-r--r-- | guides/source/engines.md | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/base.rb | 7 | ||||
-rw-r--r-- | railties/test/application/generators_test.rb | 10 |
8 files changed, 59 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb index 66f90980b9..2e09aed41d 100644 --- a/actionpack/lib/action_dispatch/railtie.rb +++ b/actionpack/lib/action_dispatch/railtie.rb @@ -54,11 +54,5 @@ module ActionDispatch ActionDispatch.test_app = app end - - initializer "action_dispatch.system_tests" do |app| - ActiveSupport.on_load(:action_dispatch_system_test_case) do - include app.routes.url_helpers - end - end end end diff --git a/actionpack/lib/action_dispatch/system_test_case.rb b/actionpack/lib/action_dispatch/system_test_case.rb index 29864c0f8e..9772beb8aa 100644 --- a/actionpack/lib/action_dispatch/system_test_case.rb +++ b/actionpack/lib/action_dispatch/system_test_case.rb @@ -119,6 +119,11 @@ module ActionDispatch def initialize(*) # :nodoc: super self.class.driver.use + @proxy_route = if ActionDispatch.test_app + Class.new { include ActionDispatch.test_app.routes.url_helpers }.new + else + nil + end end def self.start_application # :nodoc: @@ -163,6 +168,14 @@ module ActionDispatch default_url_options.merge(host: Capybara.app_host) end + def method_missing(method, *args, &block) + if @proxy_route.respond_to?(method) + @proxy_route.send(method, *args, &block) + else + super + end + end + ActiveSupport.run_load_hooks(:action_dispatch_system_test_case, self) end diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 184e881b25..b39f423700 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Add support for beginless ranges, introduced in Ruby 2.7. + + *Josh Goodall* + * Add database_exists? method to connection adapters to check if a database exists. *Guilherme Mansur* diff --git a/activerecord/lib/arel/predications.rb b/activerecord/lib/arel/predications.rb index dece478615..895d394363 100644 --- a/activerecord/lib/arel/predications.rb +++ b/activerecord/lib/arel/predications.rb @@ -37,7 +37,7 @@ module Arel # :nodoc: all def between(other) if unboundable?(other.begin) == 1 || unboundable?(other.end) == -1 self.in([]) - elsif open_ended?(other.begin) + elsif other.begin.nil? || open_ended?(other.begin) if other.end.nil? || open_ended?(other.end) not_in([]) elsif other.exclude_end? @@ -85,7 +85,7 @@ Passing a range to `#in` is deprecated. Call `#between`, instead. def not_between(other) if unboundable?(other.begin) == 1 || unboundable?(other.end) == -1 not_in([]) - elsif open_ended?(other.begin) + elsif other.begin.nil? || open_ended?(other.begin) if other.end.nil? || open_ended?(other.end) self.in([]) elsif other.exclude_end? diff --git a/activerecord/test/cases/arel/attributes/attribute_test.rb b/activerecord/test/cases/arel/attributes/attribute_test.rb index c7bd0a053b..7ebb90c6fd 100644 --- a/activerecord/test/cases/arel/attributes/attribute_test.rb +++ b/activerecord/test/cases/arel/attributes/attribute_test.rb @@ -638,6 +638,18 @@ module Arel ) end + if Gem::Version.new("2.7.0") <= Gem::Version.new(RUBY_VERSION) + it "can be constructed with a range implicitly starting at Infinity" do + attribute = Attribute.new nil, nil + node = attribute.between(eval("..0")) # eval for backwards compatibility + + node.must_equal Nodes::LessThanOrEqual.new( + attribute, + Nodes::Casted.new(0, attribute) + ) + end + end + if Gem::Version.new("2.6.0") <= Gem::Version.new(RUBY_VERSION) it "can be constructed with a range implicitly ending at Infinity" do attribute = Attribute.new nil, nil @@ -839,6 +851,18 @@ module Arel ) end + if Gem::Version.new("2.7.0") <= Gem::Version.new(RUBY_VERSION) + it "can be constructed with a range implicitly starting at Infinity" do + attribute = Attribute.new nil, nil + node = attribute.not_between(eval("..0")) # eval for backwards compatibility + + node.must_equal Nodes::GreaterThan.new( + attribute, + Nodes::Casted.new(0, attribute) + ) + end + end + if Gem::Version.new("2.6.0") <= Gem::Version.new(RUBY_VERSION) it "can be constructed with a range implicitly ending at Infinity" do attribute = Attribute.new nil, nil diff --git a/guides/source/engines.md b/guides/source/engines.md index 90b08b00f0..8961a079b5 100644 --- a/guides/source/engines.md +++ b/guides/source/engines.md @@ -220,7 +220,7 @@ Inside the `app` directory are the standard `assets`, `controllers`, `helpers`, `jobs`, `mailers`, `models`, and `views` directories that you should be familiar with from an application. We'll look more into models in a future section, when we're writing the engine. -Within the `app/assets` directory, there are the `images`, `javascripts` and +Within the `app/assets` directory, there are the `images` and `stylesheets` directories which, again, you should be familiar with due to their similarity to an application. One difference here, however, is that each directory contains a sub-directory with the engine name. Because this engine is diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index 0b91e3223e..a153923ce3 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -20,6 +20,8 @@ module Rails class_option :skip_namespace, type: :boolean, default: false, desc: "Skip namespace (affects only isolated applications)" + class_option :skip_collision_check, type: :boolean, default: false, + desc: "Skip collision check" add_runtime_options! strict_args_position! @@ -249,6 +251,7 @@ module Rails # application or Ruby on Rails. def class_collisions(*class_names) return unless behavior == :invoke + return if options.skip_collision_check? class_names.flatten.each do |class_name| class_name = class_name.to_s @@ -261,8 +264,8 @@ module Rails if last && last.const_defined?(last_name.camelize, false) raise Error, "The name '#{class_name}' is either already used in your application " \ - "or reserved by Ruby on Rails. Please choose an alternative and run " \ - "this generator again." + "or reserved by Ruby on Rails. Please choose an alternative or use --skip-collision-check " \ + "to skip this check and run this generator again." end end end diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index e5e557d204..8ec26db772 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -198,5 +198,15 @@ module ApplicationTests assert_no_match "active_record:migration", output end end + + test "skip collision check" do + rails("generate", "model", "post", "title:string") + + output = rails("generate", "model", "post", "title:string", "body:string") + assert_match(/The name 'Post' is either already used in your application or reserved/, output) + + output = rails("generate", "model", "post", "title:string", "body:string", "--skip-collision-check") + assert_no_match(/The name 'Post' is either already used in your application or reserved/, output) + end end end |