Skip to content

Commit

Permalink
Add deprecation warnings for EOL Rails and Ruby and the associated wo…
Browse files Browse the repository at this point in the history
…rk arounds (#1902)

* add: depreaction warnings

* fix: rubocop erors

* add: changelog entry

* Update docs/CHANGELOG.md

Co-authored-by: Cameron Dutro <camertron@gmail.com>

* Apply suggestions from code review

* remove coverage for render monkey patch

* remove coverage of deprecation warnings

---------

Co-authored-by: Cameron Dutro <camertron@gmail.com>
Co-authored-by: Joel Hawksley <joel@hawksley.org>
Co-authored-by: Joel Hawksley <joelhawksley@github.com>
  • Loading branch information
4 people committed Jan 3, 2024
1 parent a5ccdef commit d5f2544
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nav_order: 5

## main

* Add deprecation warnings for EOL ruby and Rails versions and patches associated with them.

*Reegan Viljoen*

* Add support for Ruby 3.3.

*Reegan Viljoen*
Expand Down
14 changes: 14 additions & 0 deletions lib/view_component/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class Engine < Rails::Engine # :nodoc:
next if Rails.version.to_f >= 6.1 || !app.config.view_component.render_monkey_patch_enabled

# :nocov:
ViewComponent::Deprecation.deprecation_warning("Monkey patching `render`", "ViewComponent 4.0 will remove the `render` monkey patch")

ActiveSupport.on_load(:action_view) do
require "view_component/render_monkey_patch"
ActionView::Base.prepend ViewComponent::RenderMonkeyPatch
Expand All @@ -99,6 +101,8 @@ class Engine < Rails::Engine # :nodoc:
next if Rails.version.to_f >= 6.1

# :nocov:
ViewComponent::Deprecation.deprecation_warning("using `render_component`", "ViewComponent 4.0 will remove `render_component`")

ActiveSupport.on_load(:action_view) do
require "view_component/render_component_helper"
ActionView::Base.include ViewComponent::RenderComponentHelper
Expand Down Expand Up @@ -160,6 +164,16 @@ def serve_static_preview_assets?(app_config)
end
end

# :nocov:
if RUBY_VERSION < "3.0.0"
ViewComponent::Deprecation.deprecation_warning("Support for Ruby versions < 3.0.0", "ViewComponent 4.0 will remove support for Ruby versions < 3.0.0 ")
end

if Rails.version.to_f < 6.1
ViewComponent::Deprecation.deprecation_warning("Support for Rails versions < 6.1", "ViewComponent 4.0 will remove support for Rails versions < 6.1 ")
end
# :nocov:

app.executor.to_run :before do
CompileCache.invalidate! unless ActionView::Base.cache_template_loading
end
Expand Down

0 comments on commit d5f2544

Please sign in to comment.