@@ -51,7 +51,7 @@ def setup
51
51
52
52
test "user_config should reject baseUrl" do
53
53
exc = assert_raises Requirejs ::ConfigError do
54
- @cfg . user_config = { " baseUrl" => " /frobnitz" }
54
+ @cfg . user_config = { ' baseUrl' => ' /frobnitz' }
55
55
end
56
56
assert_match /baseUrl is not needed/ , exc . message
57
57
end
@@ -63,6 +63,11 @@ def setup
63
63
assert_equal 'lib/jquery-1.7.2.min' , @cfg . run_config [ 'paths' ] [ 'jquery' ]
64
64
end
65
65
66
+ test "run_config should allow settings to be overridden" do
67
+ @cfg . run_config [ 'baseUrl' ] = 'http://cdn.example.com/assets'
68
+ assert_equal 'http://cdn.example.com/assets' , @cfg . run_config [ 'baseUrl' ]
69
+ end
70
+
66
71
test "build_config should inherit user_config settings" do
67
72
@cfg . user_config = { 'paths' => { 'jquery' => 'lib/jquery-1.7.2.min' } }
68
73
refute_nil @cfg . build_config [ 'paths' ]
@@ -121,6 +126,10 @@ class RequirejsHelperTest < ActionView::TestCase
121
126
122
127
def setup
123
128
controller . requirejs_included = false
129
+ Rails . application . config . requirejs . user_config = { 'paths' =>
130
+ { 'jquery' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' }
131
+ }
132
+
124
133
end
125
134
126
135
def wrap ( tag )
@@ -153,4 +162,20 @@ def wrap(tag)
153
162
render :text => "#{ requirejs_include_tag } \n #{ requirejs_include_tag } "
154
163
end
155
164
end
165
+
166
+ test "requirejs_include_tag with CDN asset in paths" do
167
+ render :text => wrap ( requirejs_include_tag )
168
+ assert_select "script:first-of-type" , :text => %r{var require =.*paths.*http://ajax}
169
+ end
170
+
171
+ test "requirejs_include_tag with CDN asset and digested asset paths" do
172
+ begin
173
+ saved_digest = Rails . application . config . assets . digest
174
+ Rails . application . config . assets . digest = true
175
+ render :text => wrap ( requirejs_include_tag )
176
+ assert_select "script:first-of-type" , :text => %r{var require =.*paths.*http://ajax}
177
+ ensure
178
+ Rails . application . config . assets . digest = saved_digest
179
+ end
180
+ end
156
181
end
0 commit comments