Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if assets.enabled is left blank, the default is now to use the asset pipeline #21

Merged
merged 1 commit into from
Nov 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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