You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When this is submitted, the order of the values should be preserved, and matching on the order of those values should work (and indeed, in a web browser, it does).
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
moduleMoneyFieldSpecwhereimportTestImportspec::Spec
spec = withApp $do
it "Fails with bad input"$do
get HomeR
request $do
addToken
setUrl HomeR
setMethod "POST"
addPostParam "money""XXX"
addPostParam "money""XXX"
statusIs 400
it "Supports USD"$do
get HomeR
request $do
addToken
setUrl HomeR
setMethod "POST"-- These two lines are in the wrong order, but that's because yesod-test-- adds POST parameters in the wrong order — instead of appending each-- parameter to the list of parameters, it conses them, which is not what-- web browers do.
addPostParam "money""100"
addPostParam "money""USD"
location <- followRedirect
liftIO $ location `shouldBe`Right"/"
bodyContains "Amount is USD 100"
Web browsers submit POST parameters from forms encoded with
application/x-www-form-urlencoded
in tree-order.Here's a form containing two fields sharing the same
name
.When this is submitted, the order of the values should be preserved, and matching on the order of those values should work (and indeed, in a web browser, it does).
However, if you were to write a test for this…
The test will fail because — as written in the comment —
addPostParam
conses params rather than appending them.I expect fixing this is simply a case of appending each param instead of consing.
The text was updated successfully, but these errors were encountered: