Skip to content

Commit

Permalink
if assets.enabled is left blank, the default is now to use the asset …
Browse files Browse the repository at this point in the history
…pipeline
  • Loading branch information
spra85 committed Nov 8, 2013
1 parent a843b9f commit 33345d1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/wisepdf/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/wisepdf/rails/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 33345d1

Please sign in to comment.