diff options
12 files changed, 49 insertions, 21 deletions
diff --git a/actioncable/test/client_test.rb b/actioncable/test/client_test.rb index 4f7c585ba3..30ac1e9c38 100644 --- a/actioncable/test/client_test.rb +++ b/actioncable/test/client_test.rb @@ -78,10 +78,20 @@ class ClientTest < ActionCable::TestCase        begin          thread.join + +      rescue IOError +        # Work around https://bugs.ruby-lang.org/issues/13405 +        # +        # Puma's sometimes raising while shutting down, when it closes +        # its internal pipe. We can safely ignore that, but we do need +        # to do the step skipped by the exception: +        server.binder.close +        rescue RuntimeError => ex +        # Work around https://bugs.ruby-lang.org/issues/13239          raise unless ex.message =~ /can't modify frozen IOError/ -        # Work around https://bugs.ruby-lang.org/issues/13239 +        # Handle this as if it were the IOError: do the same as above.          server.binder.close        end      end diff --git a/actionpack/lib/action_controller/metal/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb index d9a8b9c12d..5051c02a62 100644 --- a/actionpack/lib/action_controller/metal/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb @@ -213,7 +213,11 @@ module ActionController #:nodoc:          if !verified_request?            if logger && log_warning_on_csrf_failure -            logger.warn "Can't verify CSRF token authenticity." +            if valid_request_origin? +              logger.warn "Can't verify CSRF token authenticity." +            else +              logger.warn "HTTP Origin header (#{request.origin}) didn't match request.base_url (#{request.base_url})" +            end            end            handle_unverified_request          end diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb index d645ddfdbe..794e057b85 100644 --- a/actionpack/test/controller/request_forgery_protection_test.rb +++ b/actionpack/test/controller/request_forgery_protection_test.rb @@ -347,6 +347,10 @@ module RequestForgeryProtectionTests    end    def test_should_block_post_with_origin_checking_and_wrong_origin +    old_logger = ActionController::Base.logger +    logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new +    ActionController::Base.logger = logger +      forgery_protection_origin_check do        session[:_csrf_token] = @token        @controller.stub :form_authenticity_token, @token do @@ -356,6 +360,13 @@ module RequestForgeryProtectionTests          end        end      end + +    assert_match( +      "HTTP Origin header (http://bad.host) didn't match request.base_url (http://test.host)", +      logger.logged(:warn).last +    ) +  ensure +    ActionController::Base.logger = old_logger    end    def test_should_warn_on_missing_csrf_token diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 5d3472802b..942b4fa9bb 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -172,8 +172,8 @@ module ActiveModel      #   person.errors.messages # => {:name=>["cannot be nil", "must be specified"]}      #   person.errors.values   # => [["cannot be nil", "must be specified"]]      def values -      messages.reject do |key, value| -        value.empty? +      messages.select do |key, value| +        !value.empty?        end.values      end @@ -182,8 +182,8 @@ module ActiveModel      #   person.errors.messages # => {:name=>["cannot be nil", "must be specified"]}      #   person.errors.keys     # => [:name]      def keys -      messages.reject do |key, value| -        value.empty? +      messages.select do |key, value| +        !value.empty?        end.keys      end diff --git a/activerecord/test/cases/adapters/mysql2/boolean_test.rb b/activerecord/test/cases/adapters/mysql2/boolean_test.rb index 2fa39282fb..58698d59db 100644 --- a/activerecord/test/cases/adapters/mysql2/boolean_test.rb +++ b/activerecord/test/cases/adapters/mysql2/boolean_test.rb @@ -38,7 +38,7 @@ class Mysql2BooleanTest < ActiveRecord::Mysql2TestCase      assert_equal :string, string_column.type    end -  test "test type casting with emulated booleans" do +  test "type casting with emulated booleans" do      emulate_booleans true      boolean = BooleanType.create!(archived: true, published: true) @@ -55,7 +55,7 @@ class Mysql2BooleanTest < ActiveRecord::Mysql2TestCase      assert_equal 0, @connection.type_cast(false)    end -  test "test type casting without emulated booleans" do +  test "type casting without emulated booleans" do      emulate_booleans false      boolean = BooleanType.create!(archived: true, published: true) diff --git a/activerecord/test/cases/cache_key_test.rb b/activerecord/test/cases/cache_key_test.rb index bb2829b3c1..2c6a38ec35 100644 --- a/activerecord/test/cases/cache_key_test.rb +++ b/activerecord/test/cases/cache_key_test.rb @@ -15,7 +15,7 @@ module ActiveRecord        @connection.drop_table :cache_mes, if_exists: true      end -    test "test_cache_key_format_is_not_too_precise" do +    test "cache_key format is not too precise" do        record = CacheMe.create        key = record.cache_key diff --git a/activerecord/test/cases/comment_test.rb b/activerecord/test/cases/comment_test.rb index 63f67a9a16..c23be52a6c 100644 --- a/activerecord/test/cases/comment_test.rb +++ b/activerecord/test/cases/comment_test.rb @@ -72,9 +72,11 @@ if ActiveRecord::Base.connection.supports_comments?      end      def test_add_index_with_comment_later -      @connection.add_index :commenteds, :obvious, name: "idx_obvious", comment: "We need to see obvious comments" -      index = @connection.indexes("commenteds").find { |idef| idef.name == "idx_obvious" } -      assert_equal "We need to see obvious comments", index.comment +      unless current_adapter?(:OracleAdapter) +        @connection.add_index :commenteds, :obvious, name: "idx_obvious", comment: "We need to see obvious comments" +        index = @connection.indexes("commenteds").find { |idef| idef.name == "idx_obvious" } +        assert_equal "We need to see obvious comments", index.comment +      end      end      def test_add_comment_to_column @@ -112,8 +114,10 @@ if ActiveRecord::Base.connection.supports_comments?        assert_match %r[t\.string\s+"obvious"\n], output        assert_match %r[t\.string\s+"content",\s+comment: "Whoa, content describes itself!"], output        assert_match %r[t\.integer\s+"rating",\s+comment: "I am running out of imagination"], output -      assert_match %r[t\.index\s+.+\s+comment: "\\\"Very important\\\" index that powers all the performance.\\nAnd it's fun!"], output -      assert_match %r[t\.index\s+.+\s+name: "idx_obvious",\s+comment: "We need to see obvious comments"], output +      unless current_adapter?(:OracleAdapter) +        assert_match %r[t\.index\s+.+\s+comment: "\\\"Very important\\\" index that powers all the performance.\\nAnd it's fun!"], output +        assert_match %r[t\.index\s+.+\s+name: "idx_obvious",\s+comment: "We need to see obvious comments"], output +      end      end      def test_schema_dump_omits_blank_comments diff --git a/activerecord/test/cases/relation/mutation_test.rb b/activerecord/test/cases/relation/mutation_test.rb index 4f92f71a09..11ef0d8743 100644 --- a/activerecord/test/cases/relation/mutation_test.rb +++ b/activerecord/test/cases/relation/mutation_test.rb @@ -143,7 +143,7 @@ module ActiveRecord        assert_equal({ foo: "bar" }, relation.create_with_value)      end -    test "test_merge!" do +    test "merge!" do        assert relation.merge!(select: :foo).equal?(relation)        assert_equal [:foo], relation.select_values      end diff --git a/activesupport/test/hash_with_indifferent_access_test.rb b/activesupport/test/hash_with_indifferent_access_test.rb index ee862320e8..b1177c6c15 100644 --- a/activesupport/test/hash_with_indifferent_access_test.rb +++ b/activesupport/test/hash_with_indifferent_access_test.rb @@ -675,7 +675,6 @@ class HashWithIndifferentAccessTest < ActiveSupport::TestCase        assert_includes yaml_output, "hash"      end    end -  HashWithIndifferentAccess = ActiveSupport::HashWithIndifferentAccess    def test_should_use_default_proc_for_unknown_key      hash_wia = HashWithIndifferentAccess.new { 1 + 2 } diff --git a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb index 588fb06b15..5bfbe58d97 100644 --- a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb +++ b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb @@ -140,7 +140,7 @@ module Rails        class_option :mode, enum: %w( html list line column ), type: :string,          desc: "Automatically put the sqlite3 database in the specified mode (html, list, line, column)." -      class_option :header, type: :string +      class_option :header, type: :boolean        class_option :environment, aliases: "-e", type: :string,          desc: "Specifies the environment to run this console under (test/development/production)." diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb index 00f6620188..449d281967 100644 --- a/railties/test/application/rake/migrations_test.rb +++ b/railties/test/application/rake/migrations_test.rb @@ -77,7 +77,7 @@ module ApplicationTests          assert_equal "Schema migrations table does not exist yet.\n", output        end -      test "test migration status" do +      test "migration status" do          Dir.chdir(app_path) do            `bin/rails generate model user username:string password:string;             bin/rails generate migration add_email_to_users email:string; @@ -117,7 +117,7 @@ module ApplicationTests          end        end -      test "test migration status after rollback and redo" do +      test "migration status after rollback and redo" do          Dir.chdir(app_path) do            `bin/rails generate model user username:string password:string;             bin/rails generate migration add_email_to_users email:string; @@ -224,7 +224,7 @@ module ApplicationTests          end        end -      test "test migration status migrated file is deleted" do +      test "migration status migrated file is deleted" do          Dir.chdir(app_path) do            `bin/rails generate model user username:string password:string;             bin/rails generate migration add_email_to_users email:string; diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index a8e3a7ec5b..23b259b503 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -323,7 +323,7 @@ module ApplicationTests              assert true            end -          test "test line filter does not run this" do +          test "line filter does not run this" do              assert true            end          end  | 
