Skip to content

Commit

Permalink
Fix for empty 'paths' config with digested assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhitley committed May 8, 2012
1 parent f5a5b95 commit 859563d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/helpers/requirejs_helper.rb
Expand Up @@ -54,8 +54,10 @@ def requirejs_include_tag(name=nil, &block)
paths = {}
modules.each { |m| paths[m] = _javascript_path(m).sub /\.js$/,'' }

# Add paths for assets specified by full URL (on a CDN)
run_config['paths'].each { |k,v| paths[k] = v if v =~ /^https?:/ }
if run_config.has_key? 'paths'
# Add paths for assets specified by full URL (on a CDN)
run_config['paths'].each { |k,v| paths[k] = v if v =~ /^https?:/ }
end

# Override user paths, whose mappings are only relevant in dev mode
# and in the build_config.
Expand Down
2 changes: 1 addition & 1 deletion test/requirejs-rails_test.rb
Expand Up @@ -174,7 +174,7 @@ def wrap(tag)
Rails.application.config.assets.digest = true
Rails.application.config.requirejs.user_config = { 'modules' => [{'name' => 'foo'}] }
render :text => wrap(requirejs_include_tag)
assert_select "script:first-of-type", :text => %r{var require =.*paths.*http://ajax}
assert_select "script:first-of-type", :text => %r[var require =.*"paths":{"foo":"/javascripts/foo"}]
ensure
Rails.application.config.assets.digest = saved_digest
end
Expand Down

0 comments on commit 859563d

Please sign in to comment.