Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Wait for async processes

  • Loading branch information...
commit 07ac3bb1f3ee7841fc9a720b08ac98085912f7b1 1 parent a87ca58
@mynyml authored
View
1  Manifest
@@ -8,6 +8,7 @@ holygrail.gemspec
lib/holygrail.rb
public/javascripts/application.js
public/javascripts/foo.js
+public/javascripts/jquery.js
rails/init.rb
specs.watchr
test/functional_test.rb
View
1  lib/holygrail.rb
@@ -55,6 +55,7 @@ def process(*args) #:nodoc:
def js(code)
XhrProxy.context = self
@__page ||= Harmony::Page.new(XHR_MOCK_SCRIPT + rewrite_script_paths(@response.body.to_s))
+ Harmony::Page::Window::BASE_RUNTIME.wait
@__page.execute_js(code)
end
alias :execute_javascript :js
View
4,376 public/javascripts/jquery.js
4,376 additions, 0 deletions not shown
View
23 test/integration_test.rb
@@ -41,6 +41,17 @@ def boo
HTML
end
+ def moo
+ render :text => <<-HTML
+ <html>
+ <head>
+ <script type="text/javascript" src="javascripts/jquery.js"></script>
+ </head>
+ <body></body>
+ </html>
+ HTML
+ end
+
def xhr
render :text => "xhr response"
end
@@ -91,5 +102,17 @@ class IntegrationControllerTest < ActionController::IntegrationTest
JS
assert_equal 'animove', request.body.read
end
+
+ test "xhr with jquery" do
+ get 'moo' #loads jquery.js
+ js(<<-JS)
+ $.get("/xhr", function(data, textStatus, xhr){
+ document.body.innerHTML = data
+ })
+ JS
+ assert_equal "xhr response", js(<<-JS).strip
+ document.body.innerHTML
+ JS
+ end
end
View
1  test/test_helper.rb
@@ -19,6 +19,7 @@ def self.root
map.connect '/bar', :controller => 'functionals', :action => 'bar'
map.connect '/baz', :controller => 'integration', :action => 'baz'
map.connect '/boo', :controller => 'integration', :action => 'boo'
+ map.connect '/moo', :controller => 'integration', :action => 'moo'
map.connect '/xhr', :controller => 'integration', :action => 'xhr'
end
Please sign in to comment.
Something went wrong with that request. Please try again.