Skip to content

Commit

Permalink
Delegate xhr helper method to integration session
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Aug 19, 2008
1 parent 5df8ff1 commit 71c4ff0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def reset!
end

%w(get post put head delete cookies assigns
xml_http_request get_via_redirect post_via_redirect).each do |method|
xml_http_request xhr get_via_redirect post_via_redirect).each do |method|
define_method(method) do |*args|
reset! unless @integration_session
# reset the html_document variable, but only for new get/post calls
Expand Down
19 changes: 18 additions & 1 deletion actionpack/test/controller/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ class IntegrationController < ActionController::Base
session :off

def get
render :text => "OK", :status => 200
respond_to do |format|
format.html { render :text => "OK", :status => 200 }
format.js { render :text => "JS OK", :status => 200 }
end
end

def post
Expand Down Expand Up @@ -345,6 +348,20 @@ def test_redirect
end
end

def test_xml_http_request_get
with_test_route_set do
xhr :get, '/get'
assert_equal 200, status
assert_equal "OK", status_message
assert_equal "200 OK", response.headers["Status"]
assert_equal ["200 OK"], headers["status"]
assert_response 200
assert_response :success
assert_response :ok
assert_equal "JS OK", response.body
end
end

private
def with_test_route_set
with_routing do |set|
Expand Down

0 comments on commit 71c4ff0

Please sign in to comment.