diff --git a/gemfiles/Gemfile-rails-6-0 b/gemfiles/Gemfile-rails-6-0 index 7263fd8..49909b4 100644 --- a/gemfiles/Gemfile-rails-6-0 +++ b/gemfiles/Gemfile-rails-6-0 @@ -5,7 +5,7 @@ source "https://rubygems.org" gemspec path: ".." gem "actionview", "~> 6.0.0" -gem "rake" +gem "railties" gem "rake-compiler" gem "minitest" gem "mocha" diff --git a/gemfiles/Gemfile-rails-6-1 b/gemfiles/Gemfile-rails-6-1 index 6746897..179bd88 100644 --- a/gemfiles/Gemfile-rails-6-1 +++ b/gemfiles/Gemfile-rails-6-1 @@ -5,7 +5,7 @@ source "https://rubygems.org" gemspec path: ".." gem "actionview", "~> 6.1.0" -gem "rake" +gem "railties" gem "rake-compiler" gem "minitest" gem "mocha" diff --git a/lib/better_html/railtie.rb b/lib/better_html/railtie.rb index 328a07a..1fd3fbb 100644 --- a/lib/better_html/railtie.rb +++ b/lib/better_html/railtie.rb @@ -10,6 +10,8 @@ class Railtie < Rails::Railtie config.after_initialize do ActiveSupport.on_load(:action_view) do + next unless ActionView::Base.respond_to?(:annotate_rendered_view_with_filenames) + BetterHtml.config.annotate_rendered_view_with_filenames = ActionView::Base.annotate_rendered_view_with_filenames end end diff --git a/test/better_html/railtie_test.rb b/test/better_html/railtie_test.rb index 592abb0..a18fcc6 100644 --- a/test/better_html/railtie_test.rb +++ b/test/better_html/railtie_test.rb @@ -9,9 +9,11 @@ module BetterHtml class RailtieTest < ActiveSupport::TestCase - test "configuration is copied from ActionView" do - _ = ActionView::Base - assert BetterHtml.config.annotate_rendered_view_with_filenames + if Rails::VERSION::STRING >= "6.1" + test "configuration is copied from ActionView" do + _ = ActionView::Base + assert BetterHtml.config.annotate_rendered_view_with_filenames + end end end end diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 020fdef..03f7388 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -21,6 +21,8 @@ class Application < Rails::Application # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - config.action_view.annotate_rendered_view_with_filenames = true + if Rails::VERSION::STRING >= "6.1" + config.action_view.annotate_rendered_view_with_filenames = true + end end end