Ensure assets aren't duplicated for debug. #31 #33

merged 1 commit into from Jan 10, 2013

4 participants


When debug=true assets can require the same file multiple times -- this ensures that even if several files are included using javascript_include_tag only one dependency file will ever be included (even if multiple files require it).


Travis failed:

Bundler could not find compatible versions for gem "sprockets":
In Gemfile:
   sprockets-rails (>= 0) ruby depends on
     sprockets (~> 2.8) ruby
   actionpack (~> 3.2.0) ruby depends on
     sprockets (2.2.2)

Adding rails/rails#8735 for reference. A separate fix for rails 3-2-stable that addresses the same issue.



@guilleiguaran guilleiguaran commented on the diff Jan 6, 2013
@@ -95,7 +95,7 @@ def javascript_include_tag(*sources)
super(source, options)
- }.join("\n").html_safe
+ }.flatten.uniq.join("\n").html_safe
guilleiguaran Jan 6, 2013 Ruby on Rails member

we need the flatten?

jejacks0n Jan 6, 2013

If you're asking me and not starting a discussion.. Yes, without it it's an array of arrays -- thus uniq is semi-ineffective. Check the test case without the flatten and you'll see the dependency twice.

jejacks0n Jan 6, 2013

Oh wait -- not positive -- will double check tomorrow.

guilleiguaran Jan 6, 2013 Ruby on Rails member

right, thanks for clarification 😄

jejacks0n Jan 7, 2013

Yup, removing flatten causes the test cases to fail (with the dependency included twice).. it's the same logic as what needs to be in 3-2-stable in rails/rails.

@guilleiguaran guilleiguaran merged commit 0991710 into rails:master Jan 10, 2013

1 check failed

Details default The Travis build failed
Ruby on Rails member

Makes sense.

@jejacks0n jejacks0n referenced this pull request in jejacks0n/teaspoon Apr 23, 2013

Is my SpecController running slow? #57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment