diff --git a/app/controllers/concerns/view_component/preview_actions.rb b/app/controllers/concerns/view_component/preview_actions.rb index 1a4e7536e..db20a3a09 100644 --- a/app/controllers/concerns/view_component/preview_actions.rb +++ b/app/controllers/concerns/view_component/preview_actions.rb @@ -10,7 +10,7 @@ module PreviewActions around_action :set_locale, only: :previews before_action :require_local!, unless: :show_previews? - content_security_policy(false) if respond_to?(:content_security_policy) + content_security_policy(false) # Including helpers here ensures that we're loading the # latest version of helpers if code-reloading is enabled diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 73a403020..18f6f2a5b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -52,6 +52,10 @@ nav_order: 5 *Stephen Nelson* +* Remove unnecessary `respond_to` checks. + + *Tiago Menegaz*, *Joel Hawksley* + * Add Content Harmony & Learn To Be to list of companies using ViewComponent. *Kane Jamison* diff --git a/lib/view_component/base.rb b/lib/view_component/base.rb index 5099901a9..8f793c233 100644 --- a/lib/view_component/base.rb +++ b/lib/view_component/base.rb @@ -201,7 +201,7 @@ def initialize(*) # # This prevents an exception when rendering a partial inside of a component that has also been rendered outside # of the component. This is due to the partials compiled template method existing in the parent `view_context`, - # and not the component's `view_context`. + # and not the component's `view_context`. # # @private def render(options = {}, args = {}, &block) @@ -287,7 +287,7 @@ def request # # @private def __vc_request - @__vc_request ||= controller.request if controller.respond_to?(:request) + @__vc_request ||= controller.request end # The content passed to the component instance as a block. diff --git a/test/test_helper.rb b/test/test_helper.rb index 5ea189c8d..d2b6fd1a2 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -140,18 +140,14 @@ def with_new_cache end def without_template_annotations(&block) - if ActionView::Base.respond_to?(:annotate_rendered_view_with_filenames) - old_value = ActionView::Base.annotate_rendered_view_with_filenames - ActionView::Base.annotate_rendered_view_with_filenames = false - app.reloader.reload! if defined?(app) + old_value = ActionView::Base.annotate_rendered_view_with_filenames + ActionView::Base.annotate_rendered_view_with_filenames = false + app.reloader.reload! if defined?(app) - with_new_cache(&block) + with_new_cache(&block) - ActionView::Base.annotate_rendered_view_with_filenames = old_value - app.reloader.reload! if defined?(app) - else - yield - end + ActionView::Base.annotate_rendered_view_with_filenames = old_value + app.reloader.reload! if defined?(app) end def modify_file(file, content) diff --git a/view_component.gemspec b/view_component.gemspec index 8101cfb8c..b8f306c05 100644 --- a/view_component.gemspec +++ b/view_component.gemspec @@ -13,16 +13,9 @@ Gem::Specification.new do |spec| spec.homepage = "https://viewcomponent.org" spec.license = "MIT" - # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' - # to allow pushing to a single host or delete this section to allow pushing to any host. - if spec.respond_to?(:metadata) - spec.metadata["allowed_push_host"] = "https://rubygems.org" - spec.metadata["source_code_uri"] = "https://github.com/viewcomponent/view_component" - spec.metadata["changelog_uri"] = "https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md" - else - raise "RubyGems 2.0 or newer is required to protect against " \ - "public gem pushes." - end + spec.metadata["allowed_push_host"] = "https://rubygems.org" + spec.metadata["source_code_uri"] = "https://github.com/viewcomponent/view_component" + spec.metadata["changelog_uri"] = "https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md" spec.files = Dir["LICENSE.txt", "README.md", "app/**/*", "docs/CHANGELOG.md", "lib/**/*"] spec.require_paths = ["lib"]