Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ruby 2.7 warnings in Action View 6.0 #38016

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/asset_tag_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def preload_link_tag(source, options = {})
crossorigin = "anonymous" if crossorigin == true || (crossorigin.blank? && as_type == "font")
nopush = options.delete(:nopush) || false

link_tag = tag.link({
link_tag = tag.link(**{
rel: "preload",
href: href,
as: as_type,
Expand Down
2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/cache_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ module CacheHelper
def cache(name = {}, options = {}, &block)
if controller.respond_to?(:perform_caching) && controller.perform_caching
name_options = options.slice(:skip_digest, :virtual_path)
safe_concat(fragment_for(cache_fragment_name(name, name_options), options, &block))
safe_concat(fragment_for(cache_fragment_name(name, **name_options), options, &block))
else
yield
end
Expand Down
4 changes: 2 additions & 2 deletions actionview/lib/action_view/helpers/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -755,10 +755,10 @@ def form_with(model: nil, scope: nil, url: nil, format: nil, **options, &block)
output = capture(builder, &block)
options[:multipart] ||= builder.multipart?

html_options = html_options_for_form_with(url, model, options)
html_options = html_options_for_form_with(url, model, **options)
form_tag_with_body(html_options, output)
else
html_options = html_options_for_form_with(url, model, options)
html_options = html_options_for_form_with(url, model, **options)
form_tag_html(html_options)
end
end
Expand Down
4 changes: 2 additions & 2 deletions actionview/lib/action_view/helpers/tag_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def respond_to_missing?(*args)
true
end

def method_missing(called, *args, &block)
tag_string(called, *args, &block)
def method_missing(called, *args, **options, &block)
tag_string(called, *args, **options, &block)
end
end

Expand Down
4 changes: 2 additions & 2 deletions actionview/lib/action_view/helpers/translation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ def translate(key, options = {})
html_safe_options[name] = ERB::Util.html_escape(value.to_s)
end
end
translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))
translation = I18n.translate(scope_key_by_partial(key), **html_safe_options.merge(raise: i18n_raise))
if translation.respond_to?(:map)
translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }
else
translation.respond_to?(:html_safe) ? translation.html_safe : translation
end
else
I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))
I18n.translate(scope_key_by_partial(key), **options.merge(raise: i18n_raise))
end
rescue I18n::MissingTranslationData => e
if remaining_defaults.present?
Expand Down
2 changes: 1 addition & 1 deletion actionview/lib/action_view/unbound_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def build_template(locals)
@source,
@identifer,
@handler,
options
**options
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions actionview/test/template/form_helper/form_with_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def form_text(action = "http://www.example.com", local: false, **options)
end

def whole_form(action = "http://www.example.com", options = {})
out = form_text(action, options) + hidden_fields(options)
out = form_text(action, **options) + hidden_fields(options)

if block_given?
out << yield << "</form>"
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_form_with_with_block_in_erb_and_local_true
end

class FormWithActsLikeFormForTest < FormWithTest
def form_with(*)
def form_with(*, **)
@output_buffer = super
end

Expand Down
2 changes: 1 addition & 1 deletion actionview/test/template/template_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def my_buffer

def new_template(body = "<%= hello %>", details = {})
details = { format: :html, locals: [] }.merge details
ActionView::Template.new(body.dup, "hello template", details.delete(:handler) || ERBHandler, { virtual_path: "hello" }.merge!(details))
ActionView::Template.new(body.dup, "hello template", details.delete(:handler) || ERBHandler, **{ virtual_path: "hello" }.merge!(details))
end

def render(locals = {})
Expand Down
2 changes: 1 addition & 1 deletion actionview/test/template/text_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_word_wrap_with_leading_spaces
def test_word_wrap_does_not_modify_the_options_hash
options = { line_width: 15 }
passed_options = options.dup
word_wrap("some text", passed_options)
word_wrap("some text", **passed_options)
assert_equal options, passed_options
end

Expand Down
6 changes: 3 additions & 3 deletions actionview/test/template/url_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -562,21 +562,21 @@ def test_current_page_with_scope_that_match
def test_current_page_with_escaped_params
@request = request_for_url("/category/administra%c3%a7%c3%a3o")

assert current_page?(controller: "foo", action: "category", category: "administração")
assert current_page?({ controller: "foo", action: "category", category: "administração" })
end

def test_current_page_with_escaped_params_with_different_encoding
@request = request_for_url("/")
@request.stub(:path, (+"/category/administra%c3%a7%c3%a3o").force_encoding(Encoding::ASCII_8BIT)) do
assert current_page?(controller: "foo", action: "category", category: "administração")
assert current_page?({ controller: "foo", action: "category", category: "administração" })
assert current_page?("http://www.example.com/category/administra%c3%a7%c3%a3o")
end
end

def test_current_page_with_double_escaped_params
@request = request_for_url("/category/administra%c3%a7%c3%a3o?callback_url=http%3a%2f%2fexample.com%2ffoo")

assert current_page?(controller: "foo", action: "category", category: "administração", callback_url: "http://example.com/foo")
assert current_page?({ controller: "foo", action: "category", category: "administração", callback_url: "http://example.com/foo" })
end

def test_current_page_with_trailing_slash
Expand Down