Skip to content

Commit

Permalink
Add test for transparently handling form submits
Browse files Browse the repository at this point in the history
Closes #302
  • Loading branch information
mislav committed Nov 22, 2014
1 parent 71cd225 commit 37b32b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/unit/pjax_fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,22 @@ asyncTest("POST with data string"+s, function() {
})
})

asyncTest("handle form submit"+s, function() {
var frame = this.frame

frame.$(frame.document).on("submit", "form", function(event) {
frame.$.pjax.submit(event, "#main")
})

this.loaded = function() {
var env = JSON.parse(frame.$("#env").text())
var expected = {foo: "1", bar: "2"}
if (!disabled) expected._pjax = "#main"
deepEqual(env['rack.request.query_hash'], expected)
start()
}

frame.$("form").submit()
})

})
5 changes: 5 additions & 0 deletions test/views/home.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<li><a href="#main">Main</a></li>
</ul>

<form action="env.html" method="GET">
<input name="foo" value="1">
<input name="bar" value="2">
</form>

<div style="width:500px;height:10000px;"></div>

<script type="text/javascript">window.parent.iframeLoad(window)</script>

0 comments on commit 37b32b0

Please sign in to comment.