Skip to content

Commit

Permalink
Merge pull request #64 from jstrater/params-for-epic-and-story
Browse files Browse the repository at this point in the history
Add params hash to Client#epic and Client#story
  • Loading branch information
forest committed Feb 8, 2016
2 parents af89c34 + d2c53f5 commit 645773e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/tracker_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,19 @@ def me
# Get information about a client story without knowing what project the story belongs to
#
# @param [String] story_id
# @param [Hash] params
# @return [TrackerApi::Resources::Story]
def story(story_id)
Endpoints::Story.new(self).get_story(story_id)
def story(story_id, params={})
Endpoints::Story.new(self).get_story(story_id, params)
end

# Get information about an epic without knowing what project the epic belongs to
#
# @param [String] epic_id
# @param [Hash] params
# @return [TrackerApi::Resources::Epic]
def epic(epic_id)
Endpoints::Epic.new(self).get_epic(epic_id)
def epic(epic_id, params={})
Endpoints::Epic.new(self).get_epic(epic_id, params)
end

# Get notifications for the authenticated person
Expand Down
6 changes: 4 additions & 2 deletions test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@

it 'retrieves a story solely by story id' do
VCR.use_cassette('client: get single story by story id', record: :new_episodes) do
story = client.story('66728004')
story = client.story('66728004', fields: ':default,owned_by')

story.must_be_instance_of TrackerApi::Resources::Story
story.owned_by.wont_be_nil
end
end
end
Expand All @@ -143,9 +144,10 @@

it 'retrieves an epic solely by epic id' do
VCR.use_cassette('client: get single epic by epic id', record: :new_episodes) do
epic = client.epic('1087314')
epic = client.epic('1087314', fields: ':default,label_id')

epic.must_be_instance_of TrackerApi::Resources::Epic
epic.label_id.wont_be_nil
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/vcr/cassettes/client_get_single_epic_by_epic_id.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"http_interactions":[{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/epics/1087314","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Ruby/2.1.5 (x86_64-darwin14.0; ruby) TrackerApi/0.2.12 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"]}},"response":{"status":{"code":200,"message":null},"headers":{"Content-Type":["application/json; charset=utf-8"],"Status":["200 OK"],"Cache-Control":["max-age=0, private, must-revalidate"],"Date":["Thu, 04 Feb 2016 00:22:11 GMT"],"X-Tracker-Project-Version":["80"],"X-Request-Id":["15e6f12c733a9541b03d87d029c9cd35"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"859610ba683d894e12ca06139d46c413\""],"X-Runtime":["0.070437"],"X-Rack-Cache":["miss"],"X-Powered-By":["Phusion Passenger Enterprise"],"Server":["nginx + Phusion Passenger"],"Access-Control-Allow-Origin":["*"],"Access-Control-Allow-Credentials":["false"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"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"],"X-Tracker-Client-Pinger-Interval":["12"]},"body":{"encoding":"UTF-8","string":"{\"id\":1087314,\"kind\":\"epic\",\"created_at\":\"2014-03-02T07:11:07Z\",\"updated_at\":\"2014-03-02T07:11:07Z\",\"project_id\":1027488,\"name\":\"Admin Users\",\"description\":\"Get the Admin users working on the site\",\"url\":\"https://www.pivotaltracker.com/epic/show/1087314\",\"label\":{\"id\":7849080,\"project_id\":1027488,\"kind\":\"label\",\"name\":\"admin\",\"created_at\":\"2014-03-02T07:11:04Z\",\"updated_at\":\"2014-03-02T07:11:04Z\"}}"},"http_version":null},"recorded_at":"Thu, 04 Feb 2016 00:22:10 GMT"}],"recorded_with":"VCR 3.0.1"}
{"http_interactions":[{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/epics/1087314?fields=%3Adefault%2Clabel_id","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Ruby/2.1.5 (x86_64-darwin14.0; ruby) TrackerApi/0.2.12 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"]}},"response":{"status":{"code":200,"message":null},"headers":{"Content-Type":["application/json; charset=utf-8"],"Status":["200 OK"],"Cache-Control":["max-age=0, private, must-revalidate"],"Date":["Mon, 08 Feb 2016 21:43:24 GMT"],"X-Tracker-Project-Version":["80"],"X-Request-Id":["8df59d6eb1fe5c607e8873327a1bc883"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"16fa2db17e653781a8158dcd83c85549\""],"X-Runtime":["0.073645"],"X-Rack-Cache":["miss"],"X-Powered-By":["Phusion Passenger Enterprise"],"Server":["nginx + Phusion Passenger"],"Access-Control-Allow-Origin":["*"],"Access-Control-Allow-Credentials":["false"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"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"],"X-Tracker-Client-Pinger-Interval":["12"]},"body":{"encoding":"UTF-8","string":"{\"id\":1087314,\"kind\":\"epic\",\"created_at\":\"2014-03-02T07:11:07Z\",\"updated_at\":\"2014-03-02T07:11:07Z\",\"project_id\":1027488,\"name\":\"Admin Users\",\"label_id\":7849080,\"description\":\"Get the Admin users working on the site\",\"url\":\"https://www.pivotaltracker.com/epic/show/1087314\",\"label\":{\"id\":7849080,\"project_id\":1027488,\"kind\":\"label\",\"name\":\"admin\",\"created_at\":\"2014-03-02T07:11:04Z\",\"updated_at\":\"2014-03-02T07:11:04Z\"}}"},"http_version":null},"recorded_at":"Mon, 08 Feb 2016 21:43:24 GMT"}],"recorded_with":"VCR 3.0.1"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"http_interactions":[{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/stories/66728004","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Ruby/2.1.5 (x86_64-darwin14.0; ruby) TrackerApi/0.2.9 Faraday/0.9.1"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"]}},"response":{"status":{"code":200,"message":null},"headers":{"Content-Type":["application/json; charset=utf-8"],"Status":["200 OK"],"X-Tracker-Project-Version":["63"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"3ceeaeda1c7b6cd0dbae10df41719b9b\""],"Cache-Control":["max-age=0, private, must-revalidate"],"X-Request-Id":["4d1b3092c6ec5beb256114a056739152"],"X-Runtime":["0.069135"],"Date":["Wed, 24 Jun 2015 21:05:36 GMT"],"X-Rack-Cache":["miss"],"X-Powered-By":["Phusion Passenger 4.0.41"],"Server":["nginx/1.6.0 + Phusion Passenger 4.0.41"],"Access-Control-Allow-Origin":["*"],"Access-Control-Allow-Credentials":["false"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"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"],"X-Tracker-Client-Pinger-Interval":["12"]},"body":{"encoding":"UTF-8","string":"{\"kind\":\"story\",\"id\":66728004,\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2015-06-24T20:52:51Z\",\"story_type\":\"bug\",\"name\":\"Some product photos not scaled properly when browsing products++\",\"description\":\"+\",\"current_state\":\"started\",\"requested_by_id\":1266314,\"project_id\":1027488,\"url\":\"https://www.pivotaltracker.com/story/show/66728004\",\"owner_ids\":[],\"labels\":[{\"id\":11049868,\"project_id\":1027488,\"kind\":\"label\",\"name\":\"label1\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"},{\"id\":11049870,\"project_id\":1027488,\"kind\":\"label\",\"name\":\"label2\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"}]}"},"http_version":null},"recorded_at":"Wed, 24 Jun 2015 21:05:45 GMT"}],"recorded_with":"VCR 2.9.3"}
{"http_interactions":[{"request":{"method":"get","uri":"https://www.pivotaltracker.com/services/v5/stories/66728004?fields=%3Adefault%2Cowned_by","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Ruby/2.1.5 (x86_64-darwin14.0; ruby) TrackerApi/0.2.12 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"]}},"response":{"status":{"code":200,"message":null},"headers":{"Content-Type":["application/json; charset=utf-8"],"Status":["200 OK"],"Cache-Control":["max-age=0, private, must-revalidate"],"Date":["Mon, 08 Feb 2016 21:43:24 GMT"],"X-Tracker-Project-Version":["80"],"X-Request-Id":["d9c612bfc7f3b31b27ff6834b563bafb"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"85ea9749df8583f218a5d899f0e149c6\""],"X-Runtime":["0.079536"],"X-Rack-Cache":["miss"],"X-Powered-By":["Phusion Passenger Enterprise"],"Server":["nginx + Phusion Passenger"],"Access-Control-Allow-Origin":["*"],"Access-Control-Allow-Credentials":["false"],"Access-Control-Allow-Methods":["GET, POST, PUT, DELETE, OPTIONS"],"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"],"X-Tracker-Client-Pinger-Interval":["12"]},"body":{"encoding":"UTF-8","string":"{\"kind\":\"story\",\"id\":66728004,\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2015-12-17T22:14:04Z\",\"story_type\":\"bug\",\"name\":\"Some product photos not scaled properly when browsing products++\",\"description\":\"+\",\"current_state\":\"started\",\"requested_by_id\":1266314,\"url\":\"https://www.pivotaltracker.com/story/show/66728004\",\"project_id\":1027488,\"owned_by\":{\"kind\":\"person\",\"id\":1266314,\"name\":\"Tracker API User1\",\"email\":\"forestcarlisle+trackerapi1@gmail.com\",\"initials\":\"TU1\",\"username\":\"trackerapi1\"},\"owner_ids\":[1266314,1266316],\"labels\":[{\"id\":11049868,\"project_id\":1027488,\"kind\":\"label\",\"name\":\"label1\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"},{\"id\":11049870,\"project_id\":1027488,\"kind\":\"label\",\"name\":\"label2\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"},{\"id\":12049778,\"project_id\":1027488,\"kind\":\"label\",\"name\":\"super-special-label\",\"created_at\":\"2015-06-24T22:46:12Z\",\"updated_at\":\"2015-06-24T22:46:12Z\"}]}"},"http_version":null},"recorded_at":"Mon, 08 Feb 2016 21:43:24 GMT"}],"recorded_with":"VCR 3.0.1"}

0 comments on commit 645773e

Please sign in to comment.