Skip to content

Commit

Permalink
Manifest.asset_paths should not
Browse files Browse the repository at this point in the history
raise error if webpacked disabled
  • Loading branch information
Darkside73 committed Sep 8, 2016
1 parent 949a123 commit 14d1caf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/webpacked/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class << self
# Load manifest from file and cache it if +Rails.configuration.webpacked.dev_server+ set to +false+.
# Return entry point asset path for +:js+ or +:css+ kind or both if +kind+ skipped
def asset_paths(entry, kind = nil)
return unless Rails.configuration.webpacked.enabled

validate_asset_kind(kind)
if Rails.configuration.webpacked.dev_server
@manifest = load_manifest!
Expand All @@ -41,13 +43,10 @@ def asset_paths(entry, kind = nil)
def load_manifest!
manifest_path = Rails.configuration.webpacked.manifest_path
manifest_path = Rails.root.join(manifest_path)
manifest = {}
if File.exist?(manifest_path)
manifest = JSON.parse(File.read manifest_path).with_indifferent_access
clean_asset_paths(manifest)
elsif Rails.configuration.webpacked.enabled
raise LoadError, "File #{manifest_path} not found"
end
raise LoadError, "File #{manifest_path} not found" unless File.exist?(manifest_path)

manifest = JSON.parse(File.read manifest_path).with_indifferent_access
clean_asset_paths(manifest)
manifest
end

Expand Down
12 changes: 12 additions & 0 deletions spec/webpacked/manifest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,17 @@
.to raise_error(Webpacked::Manifest::LoadError)
end
end

describe '.asset_paths' do
context 'when webpacked disabled' do
before do
Rails.configuration.webpacked.enabled = false
end
it 'does not raise error' do
expect { Webpacked::Manifest.asset_paths 'anything' }
.to_not raise_error
end
end
end
end
end

0 comments on commit 14d1caf

Please sign in to comment.