1. 10 10月, 2018 1 次提交
    • E
      Add allocations to template renderer subscription · e8c1be4a
      Eileen Uchitelle 提交于
      This PR adds the allocations to the instrumentation for template and
      partial rendering.
      
      Before:
      
      ```
        Rendering posts/new.html.erb within layouts/application
        Rendered posts/_form.html.erb (9.7ms)
        Rendered posts/new.html.erb within layouts/application (10.9ms)
      Completed 200 OK in 902ms (Views: 890.8ms | ActiveRecord: 0.8ms)
      ```
      
      After:
      
      ```
        Rendering posts/new.html.erb within layouts/application
        Rendered posts/_form.html.erb (Duration: 7.1ms | Allocations: 6004)
        Rendered posts/new.html.erb within layouts/application (Duration: 8.3ms | Allocations: 6654)
      Completed 200 OK in 858ms (Views: 848.4ms | ActiveRecord: 0.4ms | Allocations: 1539564)
      ```
      e8c1be4a
  2. 02 10月, 2018 1 次提交
    • J
      respect path_only option when an array is passed into url_for · b48c2ade
      Joel Ambass 提交于
      The url_for method is now extracting the path_only option in order to determine if polymorphic_path or polymorphic_url should be called.
      
      If the path_only option is not set it will be set to true unless the host option is set. This behaviour is the same as when a Hash or Params object is passed.
      
      To support this unifying the code responsible for setting this default value has been extracted into a private method
      b48c2ade
  3. 01 10月, 2018 1 次提交
  4. 29 9月, 2018 1 次提交
    • Y
      Add `Style/RedundantFreeze` to remove redudant `.freeze` · aa3dcabd
      Yasuo Honda 提交于
      Since Rails 6.0 will support Ruby 2.4.1 or higher
      `# frozen_string_literal: true` magic comment is enough to make string object frozen.
      This magic comment is enabled by `Style/FrozenStringLiteralComment` cop.
      
      * Exclude these files not to auto correct false positive `Regexp#freeze`
       - 'actionpack/lib/action_dispatch/journey/router/utils.rb'
       - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'
      
      It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333
      Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed.
      
      * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required
      
       - 'actionpack/test/controller/test_case_test.rb'
       - 'activemodel/test/cases/type/string_test.rb'
       - 'activesupport/lib/active_support/core_ext/string/strip.rb'
       - 'activesupport/test/core_ext/string_ext_test.rb'
       - 'railties/test/generators/actions_test.rb'
      aa3dcabd
  5. 27 9月, 2018 1 次提交
  6. 26 9月, 2018 2 次提交
  7. 25 9月, 2018 3 次提交
  8. 23 9月, 2018 2 次提交
    • S
      Remove private def · 0fe2bb81
      Sakshi Jain 提交于
      0fe2bb81
    • Y
      Enable `Performance/UnfreezeString` cop · 1b86d901
      yuuji.yaginuma 提交于
      In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.
      
      ```ruby
      # frozen_string_literal: true
      
      require "bundler/inline"
      
      gemfile(true) do
        source "https://rubygems.org"
      
        gem "benchmark-ips"
      end
      
      Benchmark.ips do |x|
        x.report('+@') { +"" }
        x.report('dup') { "".dup }
        x.compare!
      end
      ```
      
      ```
      $ ruby -v benchmark.rb
      ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
      Warming up --------------------------------------
                        +@   282.289k i/100ms
                       dup   187.638k i/100ms
      Calculating -------------------------------------
                        +@      6.775M (± 3.6%) i/s -     33.875M in   5.006253s
                       dup      3.320M (± 2.2%) i/s -     16.700M in   5.032125s
      
      Comparison:
                        +@:  6775299.3 i/s
                       dup:  3320400.7 i/s - 2.04x  slower
      
      ```
      1b86d901
  9. 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
  10. 08 9月, 2018 1 次提交
    • S
      Don’t allocate array on no args · 1bd578ff
      schneems 提交于
      When no dependencies are present to be digested there is no reason to build an array just to turn around and turn it back into a string.
      
      The dependencies array is not mutated in this method so we can use the same empty array across all invocations.
      
      Total allocated: 791402 bytes (7294 objects)
      Total allocated: 777442 bytes (7132 objects)
      
      (791402 - 777442) / 791402.0 # => 1.76 % speed improvement
      1bd578ff
  11. 19 8月, 2018 1 次提交
  12. 09 8月, 2018 1 次提交
  13. 24 7月, 2018 1 次提交
  14. 21 7月, 2018 1 次提交
  15. 16 7月, 2018 1 次提交
    • G
      Fix issue with `button_to`'s `to_form_params` · 113d8a2b
      Georgi Georgiev 提交于
      `button_to` was throwing exception when invoked with `params` hash that
      contains symbol and string keys. The reason for the exception was that
      `to_form_params` was comparing the given symbol and string keys.
      
      The issue is fixed by turning all keys to strings inside
      `to_form_params` before comparing them.
      113d8a2b
  16. 03 7月, 2018 1 次提交
  17. 10 6月, 2018 1 次提交
    • K
      Add `year_format` option to date_select tag. This option makes it possible to customize year · 8f46a23d
      Koki Ryu 提交于
      names. Lambda should be passed to use this option. Example:
      
          date_select('user_birthday', '', start_year: 1998, end_year: 2000, year_format: ->year { "Heisei #{year - 1988}" })
      
      The HTML produced:
      
          <select id="user_birthday__1i" name="user_birthday[(1i)]">
          <option value="1998">Heisei 10</option>
          <option value="1999">Heisei 11</option>
          <option value="2000">Heisei 12</option>
          </select>
          /* The rest is omitted */
      8f46a23d
  18. 28 5月, 2018 1 次提交
  19. 13 5月, 2018 1 次提交
  20. 19 4月, 2018 1 次提交
  21. 18 4月, 2018 1 次提交
  22. 15 4月, 2018 1 次提交
  23. 07 4月, 2018 1 次提交
    • Y
      Remove RecordTagHelper · 5c5ddd69
      Yoshiyuki Hirano 提交于
      * Since #18411, we started to inform about extracted gem (record_tag_helper)
        to developers who use `ActionView::Helpers::RecordTagHelper` 's methods.
      
      * Currently, it seems no problem that we don't have to support no longer.
      5c5ddd69
  24. 02 4月, 2018 1 次提交
  25. 01 4月, 2018 1 次提交
  26. 20 3月, 2018 1 次提交
  27. 19 3月, 2018 1 次提交
    • R
      Pass HTML responses as plain-text in rails-ujs · 48e44edf
      Raymond Zhou 提交于
      Running HTML responses through `DOMParser#parseFromString` results in
      complete `HTMLDocument` instances with unnecessary surrounding tags.
      
      For example:
      
          new DOMParser().parseFromString('<p>hello</p>', 'text/html')
      
      Will output:
      
          <html>
            <head></head>
            <body>
              <p>hello</p>
            </body>
          </html>
      
      This is passed to the `ajax:success` handler as `event.detail[0]`
      (`data`), but cannot be used directly without first traversing the
      document.
      
      To resolve this, only XML content is passed through `parseFromString`,
      while HTML content is treated as plain-text.
      
      This matches the behavior of jquery-ujs, which relied on jQuery's
      response-type inference.
      48e44edf
  28. 06 3月, 2018 1 次提交
  29. 05 3月, 2018 2 次提交
    • B
    • B
      Fix actionview tests execution · b41c981b
      bogdanvlviv 提交于
      On my local environment execution of `cd actionview/ && bin/test` raises error:
      
      ```
      (snip)
      rails/actionview/test/template/render_test.rb:6:in `<top (required)>': superclass mismatch for class TestController (TypeError)
      ```
      
      In some test files `TestController` inherited from `ActionController::Base`,
      but in `test/actionpack/controller/render_test.rb` file `TestController`
      inherited from `ApplicationController`.
      This produces error `superclass mismatch for class TestController (TypeError)`
      
      Step to reproduce this on any environment:
      `cd actionview/ && bin/test test/template/streaming_render_test.rb test/actionpack/controller/render_test.rb`
      b41c981b
  30. 28 2月, 2018 1 次提交
  31. 27 2月, 2018 2 次提交
  32. 19 2月, 2018 1 次提交
    • A
      Add support for automatic nonce generation for Rails UJS · 31abee03
      Andrew White 提交于
      Because the UJS library creates a script tag to process responses it
      normally requires the script-src attribute of the content security
      policy to include 'unsafe-inline'.
      
      To work around this we generate a per-request nonce value that is
      embedded in a meta tag in a similar fashion to how CSRF protection
      embeds its token in a meta tag. The UJS library can then read the
      nonce value and set it on the dynamically generated script tag to
      enable it to execute without needing 'unsafe-inline' enabled.
      
      Nonce generation isn't 100% safe - if your script tag is including
      user generated content in someway then it may be possible to exploit
      an XSS vulnerability which can take advantage of the nonce. It is
      however an improvement on a blanket permission for inline scripts.
      
      It is also possible to use the nonce within your own script tags by
      using `nonce: true` to set the nonce value on the tag, e.g
      
          <%= javascript_tag nonce: true do %>
            alert('Hello, World!');
          <% end %>
      
      Fixes #31689.
      31abee03
  33. 18 2月, 2018 2 次提交
    • J
      Rails 6 requires Ruby 2.4.1+ · d4eb0dc8
      Jeremy Daer 提交于
      Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.
      
      References #32028
      d4eb0dc8
    • B
      Clean up and consolidate .gitignores · 0f98954a
      bogdanvlviv 提交于
      * Global ignores at toplevel .gitignore
      * Component-specific ignores in each toplevel directory
      * Remove `actionview/test/tmp/.keep` for JRuby
      
      ```
      rm actionview/test/tmp/ -fr
      cd actionview/
      bundle exec jruby -Itest test/template/digestor_test.rb
      ```
      
      Related to #11743, #30392.
      
      Closes #29978.
      0f98954a