Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/tracker_api/resources/story.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Story
class UpdateRepresenter < Representable::Decorator
include Representable::JSON

property :follower_ids, if: ->(options) { !options[:input].blank? }
property :follower_ids, if: ->(_) { !follower_ids.blank? }
property :name
property :after_id
property :before_id
Expand All @@ -52,7 +52,7 @@ class UpdateRepresenter < Representable::Decorator
property :accepted_at
property :deadline
property :requested_by_id
property :owner_ids, if: ->(options) { !options[:input].blank? }
property :owner_ids, if: ->(_) { !owner_ids.blank? }
collection :labels, class: Label, decorator: Label::UpdateRepresenter, render_empty: true
property :integration_id
property :external_id
Expand Down
18 changes: 16 additions & 2 deletions test/story_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
let(:another_story_id) { '66728000' }
let(:story) { VCR.use_cassette('get story') { project.story(story_id) } }


it 'can update an existing story' do
new_name = "#{story.name}+"
story.name = new_name
Expand Down Expand Up @@ -101,6 +100,22 @@
end
end

describe "updating owners" do
it do
owner_ids = [VCR.use_cassette("get me", record: :new_episodes) { client.me.id }]

refute_equal story.owner_ids, owner_ids

story.owner_ids = owner_ids

VCR.use_cassette("save story with owner_ids changed", record: :new_episodes) do
story.save
end

story.owner_ids.must_equal owner_ids
end
end

describe '.tasks' do
it 'gets all tasks for this story with eager loading' do
VCR.use_cassette('get story with tasks', record: :new_episodes) do
Expand Down Expand Up @@ -194,5 +209,4 @@
end
end
end

end
2 changes: 1 addition & 1 deletion test/vcr/cassettes/save_story.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"http_interactions":[{"request":{"method":"put","uri":"https://www.pivotaltracker.com/services/v5/projects/1027488/stories/66728004","body":{"encoding":"UTF-8","string":"{\"name\":\"Some product photos not scaled properly when browsing products+++++++\"}"},"headers":{"User-Agent":["Ruby/2.2.3 (x86_64-darwin15; ruby) TrackerApi/0.2.12 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"],"Content-Type":["application/json"]}},"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, 15 Feb 2016 19:33:48 GMT"],"X-Tracker-Project-Version":["118"],"X-Request-Id":["c3fda522db86a15b555905938fec3c43"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"69086648b523f7008cafceb1ab4ff4ed\""],"X-Runtime":["0.358272"],"X-Rack-Cache":["invalidate, pass"],"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,\"project_id\":1027488,\"name\":\"Some product photos not scaled properly when browsing products+++++++\",\"description\":\"+++++++\",\"story_type\":\"bug\",\"current_state\":\"started\",\"requested_by_id\":1266314,\"owned_by_id\":1266314,\"owner_ids\":[1266314,1266316],\"labels\":[{\"kind\":\"label\",\"id\":11049868,\"project_id\":1027488,\"name\":\"label1\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"},{\"kind\":\"label\",\"id\":11049870,\"project_id\":1027488,\"name\":\"label2\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"}],\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2016-02-15T19:33:48Z\",\"url\":\"https://www.pivotaltracker.com/story/show/66728004\"}"},"http_version":null},"recorded_at":"Mon, 15 Feb 2016 19:33:48 GMT"}],"recorded_with":"VCR 2.9.3"}
{"http_interactions":[{"request":{"method":"put","uri":"https://www.pivotaltracker.com/services/v5/projects/1027488/stories/66728004","body":{"encoding":"UTF-8","string":"{\"name\":\"Some product photos not scaled properly when browsing products+++++++\"}"},"headers":{"User-Agent":["Ruby/2.2.3 (x86_64-darwin15; ruby) TrackerApi/0.2.12 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"],"Content-Type":["application/json"]}},"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, 15 Feb 2016 19:33:48 GMT"],"X-Tracker-Project-Version":["118"],"X-Request-Id":["c3fda522db86a15b555905938fec3c43"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"69086648b523f7008cafceb1ab4ff4ed\""],"X-Runtime":["0.358272"],"X-Rack-Cache":["invalidate, pass"],"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,\"project_id\":1027488,\"name\":\"Some product photos not scaled properly when browsing products+++++++\",\"description\":\"+++++++\",\"story_type\":\"bug\",\"current_state\":\"started\",\"requested_by_id\":1266314,\"owned_by_id\":1266314,\"owner_ids\":[1266314,1266316],\"labels\":[{\"kind\":\"label\",\"id\":11049868,\"project_id\":1027488,\"name\":\"label1\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"},{\"kind\":\"label\",\"id\":11049870,\"project_id\":1027488,\"name\":\"label2\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"}],\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2016-02-15T19:33:48Z\",\"url\":\"https://www.pivotaltracker.com/story/show/66728004\"}"},"http_version":null},"recorded_at":"Mon, 15 Feb 2016 19:33:48 GMT"},{"request":{"method":"put","uri":"https://www.pivotaltracker.com/services/v5/projects/1027488/stories/66728004","body":{"encoding":"UTF-8","string":"{\"name\":\"Some product photos not scaled properly when browsing products+++++++\"}"},"headers":{"User-Agent":["Ruby/2.2.3 (x86_64-darwin14; ruby) TrackerApi/1.2.1 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"],"Content-Type":["application/json"]}},"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, 22 Aug 2016 19:26:25 GMT"],"X-Tracker-Project-Version":["150"],"X-Request-Id":["ce554f47d4685dee9f8c92a6071edea4"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"49204d1c1e8b5dc1d78d1ea61a294233\""],"X-Runtime":["0.115724"],"X-Rack-Cache":["invalidate, pass"],"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,\"project_id\":1027488,\"name\":\"Some product photos not scaled properly when browsing products+++++++\",\"description\":\"++++++++++\",\"story_type\":\"bug\",\"current_state\":\"started\",\"requested_by_id\":1266314,\"owned_by_id\":1266314,\"owner_ids\":[1266314],\"labels\":[],\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2016-08-22T19:26:23Z\",\"url\":\"https://www.pivotaltracker.com/story/show/66728004\"}"},"http_version":null},"recorded_at":"Mon, 22 Aug 2016 19:26:25 GMT"}],"recorded_with":"VCR 3.0.3"}
2 changes: 1 addition & 1 deletion test/vcr/cassettes/save_story_with_multiple_changes.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"http_interactions":[{"request":{"method":"put","uri":"https://www.pivotaltracker.com/services/v5/projects/1027488/stories/66728004","body":{"encoding":"UTF-8","string":"{\"name\":\"Some product photos not scaled properly when browsing products+++++++\",\"description\":\"++++++++\"}"},"headers":{"User-Agent":["Ruby/2.2.3 (x86_64-darwin15; ruby) TrackerApi/0.2.12 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"],"Content-Type":["application/json"]}},"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, 15 Feb 2016 19:33:49 GMT"],"X-Tracker-Project-Version":["119"],"X-Request-Id":["c2dcfff1ff4852de4bc8df8aa179a9a1"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"9d8ccb7ba7d7b0c7fe77c602ff3a872e\""],"X-Runtime":["0.348974"],"X-Rack-Cache":["invalidate, pass"],"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,\"project_id\":1027488,\"name\":\"Some product photos not scaled properly when browsing products+++++++\",\"description\":\"++++++++\",\"story_type\":\"bug\",\"current_state\":\"started\",\"requested_by_id\":1266314,\"owned_by_id\":1266314,\"owner_ids\":[1266314,1266316],\"labels\":[{\"kind\":\"label\",\"id\":11049868,\"project_id\":1027488,\"name\":\"label1\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"},{\"kind\":\"label\",\"id\":11049870,\"project_id\":1027488,\"name\":\"label2\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"}],\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2016-02-15T19:33:49Z\",\"url\":\"https://www.pivotaltracker.com/story/show/66728004\"}"},"http_version":null},"recorded_at":"Mon, 15 Feb 2016 19:33:49 GMT"}],"recorded_with":"VCR 2.9.3"}
{"http_interactions":[{"request":{"method":"put","uri":"https://www.pivotaltracker.com/services/v5/projects/1027488/stories/66728004","body":{"encoding":"UTF-8","string":"{\"name\":\"Some product photos not scaled properly when browsing products+++++++\",\"description\":\"++++++++\"}"},"headers":{"User-Agent":["Ruby/2.2.3 (x86_64-darwin15; ruby) TrackerApi/0.2.12 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"],"Content-Type":["application/json"]}},"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, 15 Feb 2016 19:33:49 GMT"],"X-Tracker-Project-Version":["119"],"X-Request-Id":["c2dcfff1ff4852de4bc8df8aa179a9a1"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"9d8ccb7ba7d7b0c7fe77c602ff3a872e\""],"X-Runtime":["0.348974"],"X-Rack-Cache":["invalidate, pass"],"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,\"project_id\":1027488,\"name\":\"Some product photos not scaled properly when browsing products+++++++\",\"description\":\"++++++++\",\"story_type\":\"bug\",\"current_state\":\"started\",\"requested_by_id\":1266314,\"owned_by_id\":1266314,\"owner_ids\":[1266314,1266316],\"labels\":[{\"kind\":\"label\",\"id\":11049868,\"project_id\":1027488,\"name\":\"label1\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"},{\"kind\":\"label\",\"id\":11049870,\"project_id\":1027488,\"name\":\"label2\",\"created_at\":\"2015-03-07T12:51:39Z\",\"updated_at\":\"2015-03-07T12:51:39Z\"}],\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2016-02-15T19:33:49Z\",\"url\":\"https://www.pivotaltracker.com/story/show/66728004\"}"},"http_version":null},"recorded_at":"Mon, 15 Feb 2016 19:33:49 GMT"},{"request":{"method":"put","uri":"https://www.pivotaltracker.com/services/v5/projects/1027488/stories/66728004","body":{"encoding":"UTF-8","string":"{\"name\":\"Some product photos not scaled properly when browsing products+++++++\",\"description\":\"++++++++\"}"},"headers":{"User-Agent":["Ruby/2.2.3 (x86_64-darwin14; ruby) TrackerApi/1.2.1 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"],"Content-Type":["application/json"]}},"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, 22 Aug 2016 19:26:26 GMT"],"X-Tracker-Project-Version":["151"],"X-Request-Id":["3d27f9b64b7f7e44e664ec700483d97d"],"X-UA-Compatible":["IE=Edge,chrome=1"],"ETag":["\"9632b13e83280ff6e899da614d92d6f0\""],"X-Runtime":["0.174542"],"X-Rack-Cache":["invalidate, pass"],"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,\"project_id\":1027488,\"name\":\"Some product photos not scaled properly when browsing products+++++++\",\"description\":\"++++++++\",\"story_type\":\"bug\",\"current_state\":\"started\",\"requested_by_id\":1266314,\"owned_by_id\":1266314,\"owner_ids\":[1266314],\"labels\":[],\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2016-08-22T19:26:26Z\",\"url\":\"https://www.pivotaltracker.com/story/show/66728004\"}"},"http_version":null},"recorded_at":"Mon, 22 Aug 2016 19:26:26 GMT"}],"recorded_with":"VCR 3.0.3"}
Loading