Closed rudyrigot closed 10 years ago
Note: when either a form OR predicates are used, everything works fine, of course (I've created tests for that too on my branch).
The set SearchForm#set
method handle a Hash, but some values are stored in an array. It looks like this:
{
'param1' => 'val1',
'param2' => ['val2a', 'val2b'],
}
This syntax is understood by the HTTP lib which transforms it into param1=val1¶m2=val2a¶m2=valb
However, there were a problem with SearchForm initialization, that I fixed with 7c422ef34e06d210372e918f0badbd99a273c985
I let you close the issue if this commit fixed it :-)
Awesome man! All my tests pass!
I just pushed this commit, that introduces a lesbonneschoses_spec.rb that tests on the actual Les Bonnes Choses API, since this is how I had written the failing test that now passes. If you want to add to it at some point, you now know it's there. Thanks man!
This commit ;)
But still error report is wrong if there is a mistake in one of the predicates.
On Sat, Nov 23, 2013 at 8:19 PM, Rudy Rigot notifications@github.comwrote:
This commithttps://github.com/prismicio/ruby-kit/commit/59977f05680fa01d47d8f862a56353c3e6e07d5f;)
— Reply to this email directly or view it on GitHubhttps://github.com/prismicio/ruby-kit/issues/6#issuecomment-29139420 .
http://sadache.tumblr.com ʎdoɹʇuǝ
Not sure I understand, I didn't test errors in predicates in this one; we do need to test them though, but as Etienne was saying this weeks, the Ruby kit does need a bit more tests to be written globally.
Basically, when you write something like:
@api.create_search_form("products").query(%([[:d = any(document.tags, ["Cupcake", "Macaron"])]])).submit(@master_ref).size.should == 11
thequery
method is simply ignored (all the documents matching the form are returned no matter what additional predicates are submitted insidequery
).The origin is the same problem described in issue #3 of the JS kit, simply the two kits react differently:
q
is pushed into an array which makes it an array of two items, and twoq
URL parameters are sent, which returns a 500.SearchForm::set
method, which handles a Hash, so there can only be one value at a time.I'm waiting for the answer on how to handle it in JS to fix it here the same way; I'm working on it on a branch I've only pushed on my GitHub fork so far, and I've written it as a test that fails for now, as it should (the test works by calling the real LesBonnesChoses API, to make sure it's happening in the real world).