From 60d4ac2a71ed64b239a0a97a6285ccf3c310399c Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sun, 3 Jul 2022 13:43:19 +0200 Subject: [PATCH] Remove p shorthand deprecated in #39 --- lib/nice_partials/monkey_patch.rb | 12 ------------ test/fixtures/_clobberer.html.erb | 3 --- test/renderer_test.rb | 16 ---------------- 3 files changed, 31 deletions(-) delete mode 100644 test/fixtures/_clobberer.html.erb diff --git a/lib/nice_partials/monkey_patch.rb b/lib/nice_partials/monkey_patch.rb index 257961f..f4d4743 100644 --- a/lib/nice_partials/monkey_patch.rb +++ b/lib/nice_partials/monkey_patch.rb @@ -24,21 +24,9 @@ def with_nice_partials_t_prefix(lookup_context, block) end end -require "active_support/deprecation" -NicePartials::DEPRECATOR = ActiveSupport::Deprecation.new("1.0", "nice_partials") - module NicePartials::RenderingWithAutoContext attr_reader :partial - def p(*args) - if args.empty? - NicePartials::DEPRECATOR.deprecation_warning :p, :partial # In-branch printing so we don't warn on legit `Kernel.p` calls. - partial - else - super # …we're really Kernel.p - end - end - def render(options = {}, locals = {}, &block) _partial, @partial = partial, nice_partial @partial.capture(block) diff --git a/test/fixtures/_clobberer.html.erb b/test/fixtures/_clobberer.html.erb deleted file mode 100644 index 79efc93..0000000 --- a/test/fixtures/_clobberer.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% p "it's clobbering time" %> -<%# TODO: Remove this file once `p` has been removed post deprecation, but don't change it yet. %> -<%= p.yield :message %> diff --git a/test/renderer_test.rb b/test/renderer_test.rb index 4b8ddef..70a8f82 100644 --- a/test/renderer_test.rb +++ b/test/renderer_test.rb @@ -26,20 +26,4 @@ class RendererTest < NicePartials::Test assert_rendered "hello from nice partials" assert_equal "Some extra content", nice_partial.output_buffer end - - test "doesn't clobber Kernel.p" do - assert_output "\"it's clobbering time\"\n" do - render("clobberer") { |p| p.content_for :message, "hello from nice partials" } - end - - assert_rendered "hello from nice partials" - end - - test "deprecates top-level access through p method" do - assert_deprecated /p is deprecated and will be removed from nice_partials \d/, NicePartials::DEPRECATOR do - assert_output "\"it's clobbering time\"\n" do - render("clobberer") { |p| p.content_for :message, "hello from nice partials" } - end - end - end end