actionview 5.0.7.2 → 5.1.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +169 -345
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +1 -1
  5. data/lib/action_view/base.rb +19 -19
  6. data/lib/action_view/buffers.rb +1 -1
  7. data/lib/action_view/context.rb +1 -1
  8. data/lib/action_view/dependency_tracker.rb +4 -5
  9. data/lib/action_view/digestor.rb +22 -13
  10. data/lib/action_view/flows.rb +5 -6
  11. data/lib/action_view/gem_version.rb +2 -2
  12. data/lib/action_view/helpers/active_model_helper.rb +8 -8
  13. data/lib/action_view/helpers/asset_tag_helper.rb +62 -36
  14. data/lib/action_view/helpers/asset_url_helper.rb +111 -49
  15. data/lib/action_view/helpers/atom_feed_helper.rb +12 -13
  16. data/lib/action_view/helpers/cache_helper.rb +32 -20
  17. data/lib/action_view/helpers/capture_helper.rb +2 -2
  18. data/lib/action_view/helpers/controller_helper.rb +2 -2
  19. data/lib/action_view/helpers/csrf_helper.rb +3 -3
  20. data/lib/action_view/helpers/date_helper.rb +119 -109
  21. data/lib/action_view/helpers/debug_helper.rb +2 -3
  22. data/lib/action_view/helpers/form_helper.rb +440 -31
  23. data/lib/action_view/helpers/form_options_helper.rb +12 -12
  24. data/lib/action_view/helpers/form_tag_helper.rb +20 -19
  25. data/lib/action_view/helpers/javascript_helper.rb +6 -6
  26. data/lib/action_view/helpers/number_helper.rb +48 -46
  27. data/lib/action_view/helpers/output_safety_helper.rb +8 -8
  28. data/lib/action_view/helpers/record_tag_helper.rb +2 -2
  29. data/lib/action_view/helpers/rendering_helper.rb +2 -3
  30. data/lib/action_view/helpers/sanitize_helper.rb +16 -12
  31. data/lib/action_view/helpers/tag_helper.rb +194 -77
  32. data/lib/action_view/helpers/tags/base.rb +121 -102
  33. data/lib/action_view/helpers/tags/check_box.rb +17 -17
  34. data/lib/action_view/helpers/tags/collection_check_boxes.rb +9 -8
  35. data/lib/action_view/helpers/tags/collection_helpers.rb +60 -60
  36. data/lib/action_view/helpers/tags/collection_radio_buttons.rb +3 -2
  37. data/lib/action_view/helpers/tags/collection_select.rb +2 -2
  38. data/lib/action_view/helpers/tags/date_select.rb +36 -36
  39. data/lib/action_view/helpers/tags/grouped_collection_select.rb +2 -2
  40. data/lib/action_view/helpers/tags/label.rb +4 -0
  41. data/lib/action_view/helpers/tags/password_field.rb +1 -1
  42. data/lib/action_view/helpers/tags/radio_button.rb +4 -4
  43. data/lib/action_view/helpers/tags/select.rb +9 -9
  44. data/lib/action_view/helpers/tags/text_area.rb +1 -1
  45. data/lib/action_view/helpers/tags/text_field.rb +5 -5
  46. data/lib/action_view/helpers/tags/translator.rb +14 -12
  47. data/lib/action_view/helpers/text_helper.rb +20 -19
  48. data/lib/action_view/helpers/translation_helper.rb +6 -6
  49. data/lib/action_view/helpers/url_helper.rb +48 -46
  50. data/lib/action_view/helpers.rb +1 -1
  51. data/lib/action_view/layouts.rb +51 -47
  52. data/lib/action_view/log_subscriber.rb +25 -9
  53. data/lib/action_view/lookup_context.rb +19 -25
  54. data/lib/action_view/path_set.rb +19 -19
  55. data/lib/action_view/railtie.rb +13 -4
  56. data/lib/action_view/record_identifier.rb +6 -6
  57. data/lib/action_view/renderer/abstract_renderer.rb +17 -17
  58. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +7 -1
  59. data/lib/action_view/renderer/partial_renderer.rb +188 -187
  60. data/lib/action_view/renderer/renderer.rb +4 -0
  61. data/lib/action_view/renderer/streaming_template_renderer.rb +45 -47
  62. data/lib/action_view/renderer/template_renderer.rb +64 -66
  63. data/lib/action_view/rendering.rb +4 -5
  64. data/lib/action_view/routing_url_for.rb +9 -13
  65. data/lib/action_view/tasks/cache_digests.rake +7 -7
  66. data/lib/action_view/template/error.rb +5 -15
  67. data/lib/action_view/template/handlers/builder.rb +7 -7
  68. data/lib/action_view/template/handlers/erb/deprecated_erubis.rb +9 -0
  69. data/lib/action_view/template/handlers/erb/erubi.rb +81 -0
  70. data/lib/action_view/template/handlers/erb/erubis.rb +81 -0
  71. data/lib/action_view/template/handlers/erb.rb +9 -76
  72. data/lib/action_view/template/handlers.rb +4 -4
  73. data/lib/action_view/template/html.rb +2 -4
  74. data/lib/action_view/template/resolver.rb +107 -90
  75. data/lib/action_view/template/text.rb +5 -8
  76. data/lib/action_view/template/types.rb +1 -1
  77. data/lib/action_view/template.rb +26 -27
  78. data/lib/action_view/test_case.rb +20 -21
  79. data/lib/action_view/testing/resolvers.rb +29 -30
  80. data/lib/action_view/version.rb +1 -1
  81. data/lib/action_view/view_paths.rb +20 -8
  82. data/lib/action_view.rb +5 -5
  83. data/lib/assets/compiled/rails-ujs.js +683 -0
  84. metadata +18 -12
@@ -1,9 +1,9 @@
1
- require 'active_support/core_ext/module/remove_method'
2
- require 'action_controller'
3
- require 'action_controller/test_case'
4
- require 'action_view'
1
+ require "active_support/core_ext/module/remove_method"
2
+ require "action_controller"
3
+ require "action_controller/test_case"
4
+ require "action_view"
5
5
 
6
- require 'rails-dom-testing'
6
+ require "rails-dom-testing"
7
7
 
8
8
  module ActionView
9
9
  # = Action View Test Case
@@ -18,16 +18,16 @@ module ActionView
18
18
  end
19
19
 
20
20
  def controller_path=(path)
21
- self.class.controller_path=(path)
21
+ self.class.controller_path = (path)
22
22
  end
23
23
 
24
24
  def initialize
25
25
  super
26
26
  self.class.controller_path = ""
27
- @request = ActionController::TestRequest.create
27
+ @request = ActionController::TestRequest.create(self.class)
28
28
  @response = ActionDispatch::TestResponse.new
29
29
 
30
- @request.env.delete('PATH_INFO')
30
+ @request.env.delete("PATH_INFO")
31
31
  @params = ActionController::Parameters.new
32
32
  end
33
33
  end
@@ -49,7 +49,7 @@ module ActionView
49
49
 
50
50
  include ActiveSupport::Testing::ConstantLookup
51
51
 
52
- delegate :lookup_context, :to => :controller
52
+ delegate :lookup_context, to: :controller
53
53
  attr_accessor :controller, :output_buffer, :rendered
54
54
 
55
55
  module ClassMethods
@@ -96,7 +96,6 @@ module ActionView
96
96
  helper(helper_class) if helper_class
97
97
  include _helpers
98
98
  end
99
-
100
99
  end
101
100
 
102
101
  def setup_with_controller
@@ -104,8 +103,8 @@ module ActionView
104
103
  @request = @controller.request
105
104
  # empty string ensures buffer has UTF-8 encoding as
106
105
  # new without arguments returns ASCII-8BIT encoded buffer like String#new
107
- @output_buffer = ActiveSupport::SafeBuffer.new ''
108
- @rendered = ''
106
+ @output_buffer = ActiveSupport::SafeBuffer.new ""
107
+ @rendered = ""
109
108
 
110
109
  make_test_case_available_to_view!
111
110
  say_no_to_protect_against_forgery!
@@ -125,6 +124,10 @@ module ActionView
125
124
  @_rendered_views ||= RenderedViewsCollection.new
126
125
  end
127
126
 
127
+ def _routes
128
+ @controller._routes if @controller.respond_to?(:_routes)
129
+ end
130
+
128
131
  # Need to experiment if this priority is the best one: rendered => output_buffer
129
132
  class RenderedViewsCollection
130
133
  def initialize
@@ -146,7 +149,7 @@ module ActionView
146
149
 
147
150
  def view_rendered?(view, expected_locals)
148
151
  locals_for(view).any? do |actual_locals|
149
- expected_locals.all? {|key, value| value == actual_locals[key] }
152
+ expected_locals.all? { |key, value| value == actual_locals[key] }
150
153
  end
151
154
  end
152
155
  end
@@ -207,8 +210,8 @@ module ActionView
207
210
  view = @controller.view_context
208
211
  view.singleton_class.include(_helpers)
209
212
  view.extend(Locals)
210
- view.rendered_views = self.rendered_views
211
- view.output_buffer = self.output_buffer
213
+ view.rendered_views = rendered_views
214
+ view.output_buffer = output_buffer
212
215
  view
213
216
  end
214
217
  end
@@ -259,10 +262,6 @@ module ActionView
259
262
  end]
260
263
  end
261
264
 
262
- def _routes
263
- @controller._routes if @controller.respond_to?(:_routes)
264
- end
265
-
266
265
  def method_missing(selector, *args)
267
266
  begin
268
267
  routes = @controller.respond_to?(:_routes) && @controller._routes
@@ -271,8 +270,8 @@ module ActionView
271
270
  end
272
271
 
273
272
  if routes &&
274
- ( routes.named_routes.route_defined?(selector) ||
275
- routes.mounted_helpers.method_defined?(selector) )
273
+ (routes.named_routes.route_defined?(selector) ||
274
+ routes.mounted_helpers.method_defined?(selector))
276
275
  @controller.__send__(selector, *args)
277
276
  else
278
277
  super
@@ -1,4 +1,4 @@
1
- require 'action_view/template/resolver'
1
+ require "action_view/template/resolver"
2
2
 
3
3
  module ActionView #:nodoc:
4
4
  # Use FixtureResolver in your tests to simulate the presence of files on the
@@ -8,46 +8,45 @@ module ActionView #:nodoc:
8
8
  class FixtureResolver < PathResolver
9
9
  attr_reader :hash
10
10
 
11
- def initialize(hash = {}, pattern=nil)
11
+ def initialize(hash = {}, pattern = nil)
12
12
  super(pattern)
13
13
  @hash = hash
14
14
  end
15
15
 
16
16
  def to_s
17
- @hash.keys.join(', ')
17
+ @hash.keys.join(", ")
18
18
  end
19
19
 
20
- private
21
-
22
- def query(path, exts, formats, _)
23
- query = ""
24
- EXTENSIONS.each_key do |ext|
25
- query << '(' << exts[ext].map {|e| e && Regexp.escape(".#{e}") }.join('|') << '|)'
26
- end
27
- query = /^(#{Regexp.escape(path)})#{query}$/
28
-
29
- templates = []
30
- @hash.each do |_path, array|
31
- source, updated_at = array
32
- next unless _path =~ query
33
- handler, format, variant = extract_handler_and_format_and_variant(_path, formats)
34
- templates << Template.new(source, _path, handler,
35
- :virtual_path => path.virtual,
36
- :format => format,
37
- :variant => variant,
38
- :updated_at => updated_at
39
- )
20
+ private
21
+
22
+ def query(path, exts, _, _)
23
+ query = ""
24
+ EXTENSIONS.each_key do |ext|
25
+ query << "(" << exts[ext].map { |e| e && Regexp.escape(".#{e}") }.join("|") << "|)"
26
+ end
27
+ query = /^(#{Regexp.escape(path)})#{query}$/
28
+
29
+ templates = []
30
+ @hash.each do |_path, array|
31
+ source, updated_at = array
32
+ next unless query.match?(_path)
33
+ handler, format, variant = extract_handler_and_format_and_variant(_path)
34
+ templates << Template.new(source, _path, handler,
35
+ virtual_path: path.virtual,
36
+ format: format,
37
+ variant: variant,
38
+ updated_at: updated_at
39
+ )
40
+ end
41
+
42
+ templates.sort_by { |t| -t.identifier.match(/^#{query}$/).captures.reject(&:blank?).size }
40
43
  end
41
-
42
- templates.sort_by {|t| -t.identifier.match(/^#{query}$/).captures.reject(&:blank?).size }
43
- end
44
44
  end
45
45
 
46
46
  class NullResolver < PathResolver
47
- def query(path, exts, formats, _)
48
- handler, format, variant = extract_handler_and_format_and_variant(path, formats)
49
- [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, :virtual_path => path.virtual, :format => format, :variant => variant)]
47
+ def query(path, exts, _, _)
48
+ handler, format, variant = extract_handler_and_format_and_variant(path)
49
+ [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant)]
50
50
  end
51
51
  end
52
52
  end
53
-
@@ -1,4 +1,4 @@
1
- require_relative 'gem_version'
1
+ require_relative "gem_version"
2
2
 
3
3
  module ActionView
4
4
  # Returns the version of the currently loaded ActionView as a <tt>Gem::Version</tt>
@@ -5,11 +5,11 @@ module ActionView
5
5
  included do
6
6
  class_attribute :_view_paths
7
7
  self._view_paths = ActionView::PathSet.new
8
- self._view_paths.freeze
8
+ _view_paths.freeze
9
9
  end
10
10
 
11
11
  delegate :template_exists?, :any_templates?, :view_paths, :formats, :formats=,
12
- :locale, :locale=, :to => :lookup_context
12
+ :locale, :locale=, to: :lookup_context
13
13
 
14
14
  module ClassMethods
15
15
  def _prefixes # :nodoc:
@@ -22,11 +22,11 @@ module ActionView
22
22
 
23
23
  private
24
24
 
25
- # Override this method in your controller if you want to change paths prefixes for finding views.
26
- # Prefixes defined here will still be added to parents' <tt>._prefixes</tt>.
27
- def local_prefixes
28
- [controller_path]
29
- end
25
+ # Override this method in your controller if you want to change paths prefixes for finding views.
26
+ # Prefixes defined here will still be added to parents' <tt>._prefixes</tt>.
27
+ def local_prefixes
28
+ [controller_path]
29
+ end
30
30
  end
31
31
 
32
32
  # The prefixes used in render "foo" shortcuts.
@@ -43,13 +43,25 @@ module ActionView
43
43
  end
44
44
 
45
45
  def details_for_lookup
46
- { }
46
+ {}
47
47
  end
48
48
 
49
+ # Append a path to the list of view paths for the current <tt>LookupContext</tt>.
50
+ #
51
+ # ==== Parameters
52
+ # * <tt>path</tt> - If a String is provided, it gets converted into
53
+ # the default view path. You may also provide a custom view path
54
+ # (see ActionView::PathSet for more information)
49
55
  def append_view_path(path)
50
56
  lookup_context.view_paths.push(*path)
51
57
  end
52
58
 
59
+ # Prepend a path to the list of view paths for the current <tt>LookupContext</tt>.
60
+ #
61
+ # ==== Parameters
62
+ # * <tt>path</tt> - If a String is provided, it gets converted into
63
+ # the default view path. You may also provide a custom view path
64
+ # (see ActionView::PathSet for more information)
53
65
  def prepend_view_path(path)
54
66
  lookup_context.view_paths.unshift(*path)
55
67
  end
data/lib/action_view.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004-2016 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2017 David Heinemeier Hansson
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -21,9 +21,9 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- require 'active_support'
25
- require 'active_support/rails'
26
- require 'action_view/version'
24
+ require "active_support"
25
+ require "active_support/rails"
26
+ require "action_view/version"
27
27
 
28
28
  module ActionView
29
29
  extend ActiveSupport::Autoload
@@ -89,7 +89,7 @@ module ActionView
89
89
  end
90
90
  end
91
91
 
92
- require 'active_support/core_ext/string/output_safety'
92
+ require "active_support/core_ext/string/output_safety"
93
93
 
94
94
  ActiveSupport.on_load(:i18n) do
95
95
  I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml"