Skip to content

Commit 0991710

Browse files
committed
Merge pull request #33 from jejacks0n/duplicate_assets
Ensure assets aren't duplicated for debug. #31
2 parents 903b44d + 07ddb68 commit 0991710

File tree

8 files changed

+14
-2
lines changed

8 files changed

+14
-2
lines changed

lib/sprockets/rails/helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def javascript_include_tag(*sources)
9494
else
9595
super(source, options)
9696
end
97-
}.join("\n").html_safe
97+
}.flatten.uniq.join("\n").html_safe
9898
else
9999
sources.push(options)
100100
super(*sources)
@@ -116,7 +116,7 @@ def stylesheet_link_tag(*sources)
116116
else
117117
super(source, options)
118118
end
119-
}.join("\n").html_safe
119+
}.flatten.uniq.join("\n").html_safe
120120
else
121121
sources.push(options)
122122
super(*sources)

test/fixtures/dependency.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* dependency */

test/fixtures/dependency.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// dependency

test/fixtures/file1.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*= require dependency
2+
*/

test/fixtures/file1.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//= require dependency

test/fixtures/file2.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*= require dependency
2+
*/

test/fixtures/file2.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//= require dependency

test/test_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ def test_javascript_include_tag
296296
@view.javascript_include_tag(:foo)
297297
assert_equal %(<script src="/assets/foo.js?body=1"></script>\n<script src="/assets/bar.js?body=1"></script>),
298298
@view.javascript_include_tag(:bar)
299+
assert_equal %(<script src="/assets/dependency.js?body=1"></script>\n<script src="/assets/file1.js?body=1"></script>\n<script src="/assets/file2.js?body=1"></script>),
300+
@view.javascript_include_tag(:file1, :file2)
299301
end
300302

301303
def test_stylesheet_link_tag
@@ -305,6 +307,8 @@ def test_stylesheet_link_tag
305307
@view.stylesheet_link_tag(:foo)
306308
assert_equal %(<link href="/assets/foo.css?body=1" media="screen" rel="stylesheet" />\n<link href="/assets/bar.css?body=1" media="screen" rel="stylesheet" />),
307309
@view.stylesheet_link_tag(:bar)
310+
assert_equal %(<link href="/assets/dependency.css?body=1" media="screen" rel="stylesheet" />\n<link href="/assets/file1.css?body=1" media="screen" rel="stylesheet" />\n<link href="/assets/file2.css?body=1" media="screen" rel="stylesheet" />),
311+
@view.stylesheet_link_tag(:file1, :file2)
308312
end
309313

310314
def test_javascript_path

0 commit comments

Comments
 (0)