diff --git a/lib/wisepdf/configuration.rb b/lib/wisepdf/configuration.rb index 4ed1743..b56cb9c 100644 --- a/lib/wisepdf/configuration.rb +++ b/lib/wisepdf/configuration.rb @@ -21,6 +21,12 @@ def configure yield self end + def use_asset_pipeline? + return true if ::Rails.configuration.assets.enabled.nil? + + !!(::Rails.configuration.assets.enabled) + end + def reset! @options = { :encoding => "UTF-8", diff --git a/lib/wisepdf/rails/engine.rb b/lib/wisepdf/rails/engine.rb index 1491cc7..85c384b 100644 --- a/lib/wisepdf/rails/engine.rb +++ b/lib/wisepdf/rails/engine.rb @@ -3,7 +3,7 @@ module Rails class Engine < ::Rails::Engine initializer "wise_pdf.register" do ActionController::Base.send :include, Render - if !!(::Rails.configuration.assets.enabled) + if Wisepdf::Configuration.use_asset_pipeline? ActionView::Base.send :include, Helper::Assets else ActionView::Base.send :include, Helper::Legacy diff --git a/test/configuration_test.rb b/test/configuration_test.rb index db43afd..fb11d2b 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -51,4 +51,25 @@ class ConfigurationTest < Test::Unit::TestCase assert_equal 15, Wisepdf::Configuration.options[:margin][:bottom] end end + + context "Asset pipeline configuration" do + setup do + Wisepdf::Configuration.reset! + end + + should "use the asset pipeline if assets.enabled is nil" do + ::Rails.configuration.assets.enabled = nil + assert(Wisepdf::Configuration.use_asset_pipeline?) + end + + should "use the asset pipeline if assets.enabled is true" do + ::Rails.configuration.assets.enabled = true + assert(Wisepdf::Configuration.use_asset_pipeline?) + end + + should "not use the asset pipeline if assets.enabled is false" do + ::Rails.configuration.assets.enabled = false + assert(!Wisepdf::Configuration.use_asset_pipeline?) + end + end end