Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit f5a5b95

Browse files
JustinLovejwhitley
authored andcommitted
failing test for nil paths in include helper
1 parent 32fedd1 commit f5a5b95

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/requirejs-rails_test.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,15 @@ class RequirejsHelperTest < ActionView::TestCase
126126

127127
def setup
128128
controller.requirejs_included = false
129+
Rails.application.config.requirejs.user_config = {}
130+
Rails.application.config.requirejs.delete(:run_config)
131+
Rails.application.config.requirejs.delete(:build_config)
132+
end
133+
134+
def with_cdn
129135
Rails.application.config.requirejs.user_config = { 'paths' =>
130136
{ 'jquery' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' }
131137
}
132-
133138
end
134139

135140
def wrap(tag)
@@ -163,13 +168,27 @@ def wrap(tag)
163168
end
164169
end
165170

171+
test "requirejs_include_tag with digested asset paths" do
172+
begin
173+
saved_digest = Rails.application.config.assets.digest
174+
Rails.application.config.assets.digest = true
175+
Rails.application.config.requirejs.user_config = { 'modules' => [{'name' => 'foo'}] }
176+
render :text => wrap(requirejs_include_tag)
177+
assert_select "script:first-of-type", :text => %r{var require =.*paths.*http://ajax}
178+
ensure
179+
Rails.application.config.assets.digest = saved_digest
180+
end
181+
end
182+
166183
test "requirejs_include_tag with CDN asset in paths" do
184+
with_cdn
167185
render :text => wrap(requirejs_include_tag)
168186
assert_select "script:first-of-type", :text => %r{var require =.*paths.*http://ajax}
169187
end
170188

171189
test "requirejs_include_tag with CDN asset and digested asset paths" do
172190
begin
191+
with_cdn
173192
saved_digest = Rails.application.config.assets.digest
174193
Rails.application.config.assets.digest = true
175194
render :text => wrap(requirejs_include_tag)

0 commit comments

Comments
 (0)