Skip to content

Commit 07ddb68

Browse files
committed
ensure assets aren't duplicated for debug.
1 parent 0228520 commit 07ddb68

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
@@ -95,7 +95,7 @@ def javascript_include_tag(*sources)
9595
else
9696
super(source, options)
9797
end
98-
}.join("\n").html_safe
98+
}.flatten.uniq.join("\n").html_safe
9999
else
100100
sources.push(options)
101101
super(*sources)
@@ -117,7 +117,7 @@ def stylesheet_link_tag(*sources)
117117
else
118118
super(source, options)
119119
end
120-
}.join("\n").html_safe
120+
}.flatten.uniq.join("\n").html_safe
121121
else
122122
sources.push(options)
123123
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)