Skip to content

Commit

Permalink
Fix Search (#127)
Browse files Browse the repository at this point in the history
* Pass search query in params (fixes #121)
  • Loading branch information
forest committed Sep 24, 2018
1 parent dc1785a commit aa46ca0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/tracker_api/endpoints/search.rb
Expand Up @@ -10,7 +10,7 @@ def initialize(client)
def get(project_id, query, options={})
raise ArgumentError, 'Valid query string required to search' unless query.is_a?(String)

options.key?(:body) ? options[:body][:query] = query : options[:body] = { query: query }
options[:params] = { query: query }
data = client.get("/projects/#{project_id}/search", options).body

raise Errors::UnexpectedData, 'Hash of search results expect' unless data.is_a? Hash
Expand Down
2 changes: 1 addition & 1 deletion test/vcr/cassettes/search_project.json
@@ -1 +1 @@
{"http_interactions":[{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/projects/1027494","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Ruby/2.3.1 (x86_64-darwin15; ruby) TrackerApi/1.7.0 Faraday/0.9.2"],"X-TrackerToken":["77f9b9a466c436e6456939208c84c973"]}},"response":{"status":{"code":200,"message":null},"headers":{"Access-Control-Allow-Credentials":["false"],"Access-Control-Allow-Headers":["X-TrackerToken,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Tracker-Warn-Unless-Project-Version-Is"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=0, private, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Wed, 03 May 2017 23:29:43 GMT"],"Etag":["\"bee447d8953acab8e6f52d725b44b4d7\""],"Server":["nginx + Phusion Passenger"],"Status":["200 OK"],"Strict-Transport-Security":["max-age=31536000; includeSubDomains; preload"],"X-Content-Type-Options":["nosniff"],"X-Powered-By":["Phusion Passenger Enterprise"],"X-Rack-Cache":["miss"],"X-Request-Id":["4ecb19a70299df501daba9a51dc89abd"],"X-Runtime":["0.060077"],"X-Tracker-Client-Pinger-Interval":["20"],"X-Tracker-Project-Version":["3"],"X-Ua-Compatible":["IE=Edge,chrome=1"],"X-Vcap-Request-Id":["4e8c69bf-b14b-4d04-496e-f43a4ab4f31f"],"X-Xss-Protection":["1; mode=block"],"Content-Length":["845"],"Connection":["keep-alive"]},"body":{"encoding":"ASCII-8BIT","string":"{\"id\":1027494,\"kind\":\"project\",\"name\":\"My Sample Project\",\"version\":3,\"iteration_length\":1,\"week_start_day\":\"Monday\",\"point_scale\":\"0,1,2,3\",\"point_scale_is_custom\":false,\"bugs_and_chores_are_estimatable\":false,\"automatic_planning\":true,\"enable_tasks\":true,\"time_zone\":{\"kind\":\"time_zone\",\"olson_name\":\"America/Los_Angeles\",\"offset\":\"-07:00\"},\"velocity_averaged_over\":3,\"number_of_done_iterations_to_show\":12,\"has_google_domain\":false,\"profile_content\":\"This is a demo project, created by Tracker, with example stories for a simple shopping web site.\",\"enable_incoming_emails\":true,\"initial_velocity\":10,\"public\":false,\"atom_enabled\":false,\"project_type\":\"demo\",\"start_time\":\"2014-02-10T08:00:00Z\",\"created_at\":\"2014-03-02T07:18:28Z\",\"updated_at\":\"2014-03-02T07:18:28Z\",\"account_id\":621388,\"current_iteration_number\":169,\"enable_following\":true}"},"http_version":null},"recorded_at":"Wed, 03 May 2017 23:29:43 GMT"},{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/projects/1027494/search","body":{"encoding":"UTF-8","string":"{\"query\":\"name:\\\"story to test search\\\"\"}"},"headers":{"User-Agent":["Ruby/2.3.1 (x86_64-darwin15; ruby) TrackerApi/1.7.0 Faraday/0.9.2"],"X-TrackerToken":["77f9b9a466c436e6456939208c84c973"],"Content-Type":["application/json"]}},"response":{"status":{"code":200,"message":null},"headers":{"Access-Control-Allow-Credentials":["false"],"Access-Control-Allow-Headers":["X-TrackerToken,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Tracker-Warn-Unless-Project-Version-Is"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=0, private, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Wed, 03 May 2017 23:29:44 GMT"],"Etag":["\"8a5f6bd57393dc3dcfc9ee0386be8575\""],"Server":["nginx + Phusion Passenger"],"Status":["200 OK"],"Strict-Transport-Security":["max-age=31536000; includeSubDomains; preload"],"X-Content-Type-Options":["nosniff"],"X-Powered-By":["Phusion Passenger Enterprise"],"X-Rack-Cache":["miss"],"X-Request-Id":["f2e4dd411e1db55d620a1c12f978d082"],"X-Runtime":["0.499813"],"X-Tracker-Client-Pinger-Interval":["20"],"X-Tracker-Project-Version":["3"],"X-Ua-Compatible":["IE=Edge,chrome=1"],"X-Vcap-Request-Id":["2884d725-4b08-4abf-54e7-d219a7a1ac34"],"X-Xss-Protection":["1; mode=block"],"Content-Length":["506"],"Connection":["keep-alive"]},"body":{"encoding":"ASCII-8BIT","string":"{\"stories\":{\"stories\":[{\"kind\":\"story\",\"id\":143444685,\"created_at\":\"2017-04-10T18:20:52Z\",\"updated_at\":\"2017-04-10T18:20:52Z\",\"story_type\":\"feature\",\"name\":\"story to test search\",\"current_state\":\"unscheduled\",\"requested_by_id\":1266318,\"url\":\"https://www.pivotaltracker.com/story/show/143444685\",\"project_id\":1027494,\"owner_ids\":[],\"labels\":[]}],\"total_points\":0,\"total_points_completed\":0,\"total_hits\":1,\"total_hits_with_done\":1},\"epics\":{\"epics\":[],\"total_hits\":0},\"query\":\"name:\\\"story to test search\\\"\"}"},"http_version":null},"recorded_at":"Wed, 03 May 2017 23:29:44 GMT"}],"recorded_with":"VCR 2.9.3"}
{"http_interactions":[{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/projects/1027494","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Ruby/2.5.1 (x86_64-darwin17; ruby) TrackerApi/1.9.0 Faraday/0.15.3"],"X-TrackerToken":["77f9b9a466c436e6456939208c84c973"],"Accept":["application/json"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Credentials":["false"],"Access-Control-Allow-Headers":["X-TrackerToken,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Tracker-Warn-Unless-Project-Version-Is"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=0, private, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Mon, 24 Sep 2018 23:26:16 GMT"],"Etag":["W/\"4ae072562994d5bd15e6a9074f6416ad\""],"Server":["nginx + Phusion Passenger"],"Status":["200 OK"],"Strict-Transport-Security":["max-age=31536000; includeSubDomains; preload"],"X-Content-Type-Options":["nosniff, nosniff"],"X-Frame-Options":["SAMEORIGIN"],"X-Powered-By":["Phusion Passenger Enterprise"],"X-Request-Id":["c9eb89e5-2865-4b6e-a2bc-6bcda28863e5"],"X-Runtime":["0.050412"],"X-Tracker-Client-Pinger-Interval":["20"],"X-Tracker-Project-Version":["3"],"X-Vcap-Request-Id":["d57342dc-7ed3-4af7-48e9-4fd73f3f6329"],"X-Xss-Protection":["1; mode=block"],"Content-Length":["845"],"Via":["1.1 google"],"Alt-Svc":["clear"]},"body":{"encoding":"ASCII-8BIT","string":"{\"id\":1027494,\"kind\":\"project\",\"name\":\"My Sample Project\",\"version\":3,\"iteration_length\":1,\"week_start_day\":\"Monday\",\"point_scale\":\"0,1,2,3\",\"point_scale_is_custom\":false,\"bugs_and_chores_are_estimatable\":false,\"automatic_planning\":true,\"enable_tasks\":true,\"time_zone\":{\"kind\":\"time_zone\",\"olson_name\":\"America/Los_Angeles\",\"offset\":\"-07:00\"},\"velocity_averaged_over\":3,\"number_of_done_iterations_to_show\":12,\"has_google_domain\":false,\"profile_content\":\"This is a demo project, created by Tracker, with example stories for a simple shopping web site.\",\"enable_incoming_emails\":true,\"initial_velocity\":10,\"public\":false,\"atom_enabled\":false,\"project_type\":\"demo\",\"start_time\":\"2014-02-10T08:00:00Z\",\"created_at\":\"2014-03-02T07:18:28Z\",\"updated_at\":\"2014-03-02T07:18:28Z\",\"account_id\":621388,\"current_iteration_number\":242,\"enable_following\":true}"},"http_version":null},"recorded_at":"Mon, 24 Sep 2018 23:26:16 GMT"},{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/projects/1027494/search?query=name%3A%22story+to+test+search%22","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Ruby/2.5.1 (x86_64-darwin17; ruby) TrackerApi/1.9.0 Faraday/0.15.3"],"X-TrackerToken":["77f9b9a466c436e6456939208c84c973"],"Accept":["application/json"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Credentials":["false"],"Access-Control-Allow-Headers":["X-TrackerToken,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Tracker-Warn-Unless-Project-Version-Is"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"Access-Control-Allow-Origin":["*"],"Cache-Control":["max-age=0, private, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Mon, 24 Sep 2018 23:26:17 GMT"],"Etag":["W/\"8a5f6bd57393dc3dcfc9ee0386be8575\""],"Server":["nginx + Phusion Passenger"],"Status":["200 OK"],"Strict-Transport-Security":["max-age=31536000; includeSubDomains; preload"],"X-Content-Type-Options":["nosniff, nosniff"],"X-Frame-Options":["SAMEORIGIN"],"X-Powered-By":["Phusion Passenger Enterprise"],"X-Request-Id":["d4ba2d69-b3a4-40d9-83ae-103ed31d7604"],"X-Runtime":["0.281657"],"X-Tracker-Client-Pinger-Interval":["20"],"X-Tracker-Project-Version":["3"],"X-Vcap-Request-Id":["35b4554f-a348-4ec6-46ff-2a3bdd585b79"],"X-Xss-Protection":["1; mode=block"],"Content-Length":["506"],"Via":["1.1 google"],"Alt-Svc":["clear"]},"body":{"encoding":"ASCII-8BIT","string":"{\"stories\":{\"stories\":[{\"kind\":\"story\",\"id\":143444685,\"created_at\":\"2017-04-10T18:20:52Z\",\"updated_at\":\"2017-04-10T18:20:52Z\",\"story_type\":\"feature\",\"name\":\"story to test search\",\"current_state\":\"unscheduled\",\"requested_by_id\":1266318,\"url\":\"https://www.pivotaltracker.com/story/show/143444685\",\"project_id\":1027494,\"owner_ids\":[],\"labels\":[]}],\"total_points\":0,\"total_points_completed\":0,\"total_hits\":1,\"total_hits_with_done\":1},\"epics\":{\"epics\":[],\"total_hits\":0},\"query\":\"name:\\\"story to test search\\\"\"}"},"http_version":null},"recorded_at":"Mon, 24 Sep 2018 23:26:17 GMT"}],"recorded_with":"VCR 4.0.0"}

0 comments on commit aa46ca0

Please sign in to comment.