+1
-1
@@ -162,7 +162,7 @@ orderParse q =
|
|||||||
orderParseTerm :: Text -> Maybe OrderTerm
|
orderParseTerm :: Text -> Maybe OrderTerm
|
||||||
orderParseTerm s =
|
orderParseTerm s =
|
||||||
case split (=='.') s of
|
case split (=='.') s of
|
||||||
[d,c] ->
|
[c,d] ->
|
||||||
if d `elem` ["asc", "desc"]
|
if d `elem` ["asc", "desc"]
|
||||||
then Just $ OrderTerm c $
|
then Just $ OrderTerm c $
|
||||||
if d == "asc" then "asc" else "desc"
|
if d == "asc" then "asc" else "desc"
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ spec = beforeAll (clearTable "items" >> createItems 15)
|
|||||||
|
|
||||||
describe "ordering response" $ do
|
describe "ordering response" $ do
|
||||||
it "by a column asc" $
|
it "by a column asc" $
|
||||||
get "/items?id=lte.2&order=asc.id"
|
get "/items?id=lte.2&order=id.asc"
|
||||||
`shouldRespondWith` ResponseMatcher {
|
`shouldRespondWith` ResponseMatcher {
|
||||||
matchBody = Just "[{\"id\":1},{\"id\":2}]"
|
matchBody = Just "[{\"id\":1},{\"id\":2}]"
|
||||||
, matchStatus = 200
|
, matchStatus = 200
|
||||||
, matchHeaders = ["Content-Range" <:> "0-1/2"]
|
, matchHeaders = ["Content-Range" <:> "0-1/2"]
|
||||||
}
|
}
|
||||||
it "by a column desc" $
|
it "by a column desc" $
|
||||||
get "/items?id=lte.2&order=desc.id"
|
get "/items?id=lte.2&order=id.desc"
|
||||||
`shouldRespondWith` ResponseMatcher {
|
`shouldRespondWith` ResponseMatcher {
|
||||||
matchBody = Just "[{\"id\":2},{\"id\":1}]"
|
matchBody = Just "[{\"id\":2},{\"id\":1}]"
|
||||||
, matchStatus = 200
|
, matchStatus = 200
|
||||||
|
|||||||
Reference in New Issue
Block a user