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

Merged
merged 1 commit into from Jan 10, 2013

Conversation

Projects
None yet
4 participants
Contributor

jejacks0n commented Jan 2, 2013

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).

Contributor

jejacks0n commented Jan 2, 2013

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)
Contributor

jejacks0n commented Jan 3, 2013

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

pboling commented Jan 4, 2013

👍

@@ -95,7 +95,7 @@ def javascript_include_tag(*sources)
else
super(source, options)
end
- }.join("\n").html_safe
+ }.flatten.uniq.join("\n").html_safe
@guilleiguaran

guilleiguaran Jan 6, 2013

Owner

we need the flatten?

@jejacks0n

jejacks0n Jan 6, 2013

Contributor

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

jejacks0n Jan 6, 2013

Contributor

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

@guilleiguaran

guilleiguaran Jan 6, 2013

Owner

right, thanks for clarification 😄

@jejacks0n

jejacks0n Jan 7, 2013

Contributor

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 added a commit that referenced this pull request Jan 10, 2013

Merge pull request #33 from jejacks0n/duplicate_assets
Ensure assets aren't duplicated for debug. #31

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

1 check failed

default The Travis build failed
Details
Member

josh commented Jan 10, 2013

Makes sense.

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

Closed

Is my SpecController running slow? #57

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