@@ -126,10 +126,15 @@ class RequirejsHelperTest < ActionView::TestCase
126
126
127
127
def setup
128
128
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
129
135
Rails . application . config . requirejs . user_config = { 'paths' =>
130
136
{ 'jquery' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' }
131
137
}
132
-
133
138
end
134
139
135
140
def wrap ( tag )
@@ -163,13 +168,27 @@ def wrap(tag)
163
168
end
164
169
end
165
170
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":{"foo":"/javascripts/foo"}]
178
+ ensure
179
+ Rails . application . config . assets . digest = saved_digest
180
+ end
181
+ end
182
+
166
183
test "requirejs_include_tag with CDN asset in paths" do
184
+ with_cdn
167
185
render :text => wrap ( requirejs_include_tag )
168
186
assert_select "script:first-of-type" , :text => %r{var require =.*paths.*http://ajax}
169
187
end
170
188
171
189
test "requirejs_include_tag with CDN asset and digested asset paths" do
172
190
begin
191
+ with_cdn
173
192
saved_digest = Rails . application . config . assets . digest
174
193
Rails . application . config . assets . digest = true
175
194
render :text => wrap ( requirejs_include_tag )
0 commit comments