1. 22 9月, 2018 1 次提交
    • A
      Let escape_javascript handle conversion to string · dd0cfb03
      Andrew Vit 提交于
      This brings `escape_javascript` in line with the behavior of `json_escape` and
      allows other value types to be output without needing explicit casting in the
      view template.
      
      Example:
      
          <%= javascript_tag do %>
            var locale = '<%== j I18n.locale %>'; // locale is a symbol
          <% end %>
      dd0cfb03
  2. 17 8月, 2018 7 次提交
  3. 16 8月, 2018 16 次提交
  4. 15 8月, 2018 13 次提交
    • Y
      Fix broken list formatting [ci skip] · ce47479b
      yuuji.yaginuma 提交于
      ce47479b
    • R
      Merge pull request #33620 from bogdanvlviv/fix-rubocop-offenses · 7e3a0a94
      Ryuta Kamizono 提交于
      Fix rubocop offenses
      7e3a0a94
    • R
      Merge pull request #33612 from bogdanvlviv/test-assert_called · 111643b8
      Ryuta Kamizono 提交于
      Test `assert_called` and `assert_called_with`
      111643b8
    • B
      Fix rubocop offenses · ea37ccdd
      bogdanvlviv 提交于
      - Layout/TrailingWhitespace
      
      ```
      actionpack/lib/action_controller/metal/request_forgery_protection.rb:49:4:
      C: Layout/TrailingWhitespace: Trailing whitespace detected.
        #
         ^
      ```
      
      Related to c3787494
      
      - Performance/StartWith
      
      ```
      tasks/release.rb:108:44: C: Performance/StartWith:
      Use String#start_with? instead of a regex match anchored to the beginning of the string.
            header += "*   No changes.\n\n\n" if current_contents =~ /\A##/
      ```
      ea37ccdd
    • R
      Merge pull request #33618 from yskkin/bulk_change_table_comment · f7a4b875
      Ryuta Kamizono 提交于
      Fix bulk change table ignores comment option on PostgreSQL.
      f7a4b875
    • Y
      6577d412
    • G
      Merge pull request #33617 from bogdanvlviv/follow-up-33530 · e715a647
      George Claghorn 提交于
      Follow up #33530
      e715a647
    • B
      Follow up #33530 · 50ac00cb
      bogdanvlviv 提交于
      - Move changelog entry of #33530 up in order to preserve the chronology
        since we always add new entries on the top of a changelog file.
      - Clarify the changelog entry
      - Clarify the docs of remove_foreign_key
      - Ensure reversible of `remove_foreign_key` with `:primary_key` and `:to_table`
        options.
      50ac00cb
    • R
      Merge pull request #33530 from jychen7/33515-invert-remove-foreign-key · d54435b6
      Richard Schneeman 提交于
      33515 invert remove foreign key support "to_table"
      d54435b6
    • M
      Merge pull request #33137 from bogdanvlviv/add-array-extract-method · 7fa2f539
      Matthew Draper 提交于
      Add `Array#extract!`
      7fa2f539
    • B
      Refactor `Array#extract!` · b71abb3b
      bogdanvlviv 提交于
      Avoid allocating the second array by using `Array#reject!` instead of
      `Enumerable#partition` in `Array#extract!`.
      
      There are benchmarks in order to ensure that the changes speed up the method:
      ```
      begin
        require "bundler/inline"
      rescue LoadError => e
        $stderr.puts "Bundler version 1.10 or later is required. Please update
      your Bundler"
        raise e
      end
      
      class Array
        def extract_v1!(&block)
          unless block_given?
            to_enum(:extract!) { size }
          else
            extracted_elements, other_elements = partition(&block)
      
            replace(other_elements)
      
            extracted_elements
          end
        end
      
        def extract_v2!
          return to_enum(:extract!) { size } unless block_given?
      
          extracted_elements = []
      
          reject! do |element|
            extracted_elements << element if yield(element)
          end
      
          extracted_elements
        end
      end
      
      gemfile(true) do
        source "https://rubygems.org"
      
        gem "benchmark-ips"
      end
      
      arrays_for_partition = Array.new(1000) { (0..10000).to_a }
      arrays_for_extract_v1 = Array.new(1000) { (0..10000).to_a }
      arrays_for_extract_v2 = Array.new(1000) { (0..10000).to_a }
      
      Benchmark.ips do |x|
        x.report("Array#partition")  do
          arrays_for_partition.each do |numbers|
            odd_numbers, numbers = numbers.partition { |number| number.odd? }
            numbers
          end
        end
      
        x.report("Array#extract_v1!")  do
          arrays_for_extract_v1.each do |numbers|
            odd_numbers = numbers.extract_v1! { |number| number.odd? }
            numbers
          end
        end
      
        x.report("Array#extract_v2!")  do
          arrays_for_extract_v2.each do |numbers|
            odd_numbers = numbers.extract_v2! { |number| number.odd? }
            numbers
          end
        end
      
        x.compare!
      end
      ```
      
      The result of the benchmarks:
      
      ```
      ruby -v
      ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
      ```
      
      ```
      Fetching gem metadata from https://rubygems.org/.
      Resolving dependencies...
      Using benchmark-ips 2.7.2
      Using bundler 1.16.1
      Warming up --------------------------------------
           Array#partition     1.000  i/100ms
         Array#extract_v1!     1.000  i/100ms
         Array#extract_v2!     1.000  i/100ms
      Calculating -------------------------------------
           Array#partition      1.390  (± 0.0%) i/s -      7.000  in   5.044843s
         Array#extract_v1!      2.781  (± 0.0%) i/s -     14.000  in   5.050589s
         Array#extract_v2!      3.151  (± 0.0%) i/s -     16.000  in   5.080608s
      
      Comparison:
         Array#extract_v2!:        3.2 i/s
         Array#extract_v1!:        2.8 i/s - 1.13x  slower
           Array#partition:        1.4 i/s - 2.27x  slower
      ```
      
      Avoid `unless`/`else` in favour of an early return.
      The double-negative of that `else` can be confusing,
      even though the code layout is nearly the same.
      Also using of early return would improve `git diff`
      if we needed to change this method.
      b71abb3b
    • B
      Use `Array#extract!` where possible · e765bff1
      bogdanvlviv 提交于
      e765bff1
    • B
      Add `Array#extract!` · 77b01260
      bogdanvlviv 提交于
      The method removes and returns the elements for which the block returns a true value.
      If no block is given, an Enumerator is returned instead.
      
      ```
      numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
      odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9]
      numbers # => [0, 2, 4, 6, 8]
      ```
      77b01260
  5. 14 8月, 2018 3 次提交
    • R
      Allow `to_table` in `invert_remove_foreign_key` · 6b9948c8
      Rich 提交于
      remove_foreign_key supports
      - remove_foreign_key :accounts, :branches
      - remove_foreign_key :accounts, to_table: :branches
      
      but the second one is not reversible.
      
      This branch is to fix and allow second one to be reversible.
      
      [Nikolay Epifanov, Rich Chen]
      6b9948c8
    • B
      Test `assert_called` and `assert_called_with` · 88439585
      bogdanvlviv 提交于
      - ActiveSupport::Testing::MethodCallAssertions#assert_called
        - Ensure that the method stubbed by `assert_called` returns correct value after
      - ActiveSupport::Testing::MethodCallAssertions#assert_called_with
        - Ensure that `#assert_called_with` stubs the method to return a specific value
        - Ensure that the method stubbed by `assert_called_with` returns correct value after
      88439585
    • L