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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.config
.yardoc
.idea
.vscode
bin
.DS_Store
Gemfile.lock
InstalledFiles
Expand Down
1 change: 1 addition & 0 deletions lib/tracker_api/resources/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Comment
attribute :epic_id, Integer
attribute :text, String
attribute :person_id, Integer
attribute :person, Person
attribute :created_at, DateTime
attribute :updated_at, DateTime
attribute :file_attachment_ids, [Integer]
Expand Down
4 changes: 2 additions & 2 deletions test/minitest_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
end

# These API Tokens are for a user with just one Public Sample Project
PT_USER_1 = { username: 'trackerapi1', password: 'trackerapi1', token: 'd55c3bc1f74346b843ca84ba340b29bf', project_id: 1027488, workspace_id: 375106 }
PT_USER_2 = { username: 'trackerapi2', password: 'trackerapi2', token: 'ab4c5895f57995bb7547986eacf91160', project_ids: [1027488, 1027492], workspace_id: 581707 }
PT_USER_1 = { username: 'trackerapi1', password: 'trackerapi1', token: 'd55c3bc1f74346b843ca84ba340b29bf', project_id: 1027488, workspace_id: 375106, id: 1266314 }
PT_USER_2 = { username: 'trackerapi2', password: 'trackerapi2', token: 'ab4c5895f57995bb7547986eacf91160', project_ids: [1027488, 1027492], workspace_id: 581707, id: 1266316 }
PT_USER_3 = { username: 'trackerapi3', password: 'trackerapi3', token: '77f9b9a466c436e6456939208c84c973', project_id: 1027494 }
PT_USERS = [PT_USER_1, PT_USER_2, PT_USER_3]

Expand Down
57 changes: 33 additions & 24 deletions test/story_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
require_relative 'minitest_helper'

describe TrackerApi::Resources::Story do
let(:pt_user) { PT_USER_1 }
let(:client) { TrackerApi::Client.new token: pt_user[:token] }
let(:project_id) { pt_user[:project_id] }
let(:pt_user_1) { PT_USER_1 }
let(:pt_user_1_id) { pt_user_1[:id] }
let(:pt_user_2) { PT_USER_2 }
let(:pt_user_2_id) { pt_user_2[:id] }
let(:client) { TrackerApi::Client.new token: pt_user_1[:token] }
let(:project_id) { pt_user_1[:project_id] }
let(:project) { VCR.use_cassette('get project') { client.project(project_id) } }
let(:story_id) { '66728004' }
let(:another_story_id) { '66728000' }
Expand Down Expand Up @@ -116,19 +119,37 @@
end
end

describe "updating owners" do
it do
owner_ids = [VCR.use_cassette("get me", record: :new_episodes) { client.me.id }]
describe '.owner_ids' do
it 'gets owner_ids for this story' do
VCR.use_cassette('get story', record: :new_episodes) do
story = project.story(story_id)
owner_ids = story.owner_ids

owner_ids.wont_be_empty
owner_ids.first.must_be_instance_of Fixnum
end
end

refute_equal story.owner_ids, owner_ids
it 'update owners for a story' do
VCR.use_cassette('get story', record: :new_episodes) do
story = project.story(story_id)

story.owner_ids = owner_ids
# save with one owner
one_owner = [pt_user_1_id]
story.owner_ids = one_owner
VCR.use_cassette('save story with one owner') { story.save }

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

# save with two owners
two_owners = [pt_user_1_id, pt_user_2_id]
story.owner_ids = two_owners
VCR.use_cassette('save story with two owners') { story.save }

story.owner_ids.must_equal owner_ids
story.owner_ids.wont_be_empty
story.owner_ids.must_equal two_owners
end
end
end

Expand Down Expand Up @@ -200,18 +221,6 @@
end
end

describe '.owners' do
it 'gets all owners of this story' do
VCR.use_cassette('get story owners', record: :new_episodes) do
owners = story.owners

owners.wont_be_empty
owner = owners.first
owner.must_be_instance_of TrackerApi::Resources::Person
end
end
end

describe '.comments' do
it 'gets all comments of story with just project_id and story_id' do
VCR.use_cassette('get story comments', record: :new_episodes) do
Expand Down
1 change: 1 addition & 0 deletions test/vcr/cassettes/save_story_with_one_owner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"http_interactions":[{"request":{"method":"put","uri":"https://www.pivotaltracker.com/services/v5/projects/1027488/stories/66728004","body":{"encoding":"UTF-8","string":"{\"owner_ids\":[1266314]}"},"headers":{"User-Agent":["Ruby/2.3.1 (x86_64-darwin15; ruby) TrackerApi/1.5.0 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"],"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":["Thu, 05 Jan 2017 00:38:24 GMT"],"Etag":["\"5cd25879d7debd9d20fb03038596c268\""],"Server":["nginx + Phusion Passenger"],"Status":["200 OK"],"Strict-Transport-Security":["max-age=31536000; includeSubDomains; preload"],"X-Powered-By":["Phusion Passenger Enterprise"],"X-Rack-Cache":["invalidate, pass"],"X-Request-Id":["282573a485764039cd40cf2887216752"],"X-Runtime":["0.172276"],"X-Tracker-Client-Pinger-Interval":["20"],"X-Tracker-Project-Version":["160"],"X-Ua-Compatible":["IE=Edge,chrome=1"],"X-Vcap-Request-Id":["3e5db7e3-0bc7-4a46-4da7-758e70c07e0f"],"Content-Length":["845"],"Connection":["keep-alive"]},"body":{"encoding":"ASCII-8BIT","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\":[{\"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\"},{\"kind\":\"label\",\"id\":14060665,\"project_id\":1027488,\"name\":\"super-special-label\",\"created_at\":\"2016-02-12T23:45:13Z\",\"updated_at\":\"2016-02-12T23:45:13Z\"}],\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2017-01-05T00:38:23Z\",\"url\":\"https://www.pivotaltracker.com/story/show/66728004\"}"},"http_version":null},"recorded_at":"Thu, 05 Jan 2017 00:38:24 GMT"}],"recorded_with":"VCR 2.9.3"}
1 change: 0 additions & 1 deletion test/vcr/cassettes/save_story_with_owner_ids_cchanged.json

This file was deleted.

1 change: 0 additions & 1 deletion test/vcr/cassettes/save_story_with_owner_ids_changed.json

This file was deleted.

1 change: 1 addition & 0 deletions test/vcr/cassettes/save_story_with_two_owners.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"http_interactions":[{"request":{"method":"put","uri":"https://www.pivotaltracker.com/services/v5/projects/1027488/stories/66728004","body":{"encoding":"UTF-8","string":"{\"owner_ids\":[1266314,1266316]}"},"headers":{"User-Agent":["Ruby/2.3.1 (x86_64-darwin15; ruby) TrackerApi/1.5.0 Faraday/0.9.2"],"X-TrackerToken":["d55c3bc1f74346b843ca84ba340b29bf"],"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":["Thu, 05 Jan 2017 00:40:49 GMT"],"Etag":["\"bffad4c85bc89fedfcbd56b6e5a4b70c\""],"Server":["nginx + Phusion Passenger"],"Status":["200 OK"],"Strict-Transport-Security":["max-age=31536000; includeSubDomains; preload"],"X-Powered-By":["Phusion Passenger Enterprise"],"X-Rack-Cache":["invalidate, pass"],"X-Request-Id":["4271c9b8ccb5d2cfaf0d86036cddd7ba"],"X-Runtime":["0.284607"],"X-Tracker-Client-Pinger-Interval":["20"],"X-Tracker-Project-Version":["162"],"X-Ua-Compatible":["IE=Edge,chrome=1"],"X-Vcap-Request-Id":["80702f75-b222-471c-6e28-490a427614da"],"Content-Length":["853"],"Connection":["keep-alive"]},"body":{"encoding":"ASCII-8BIT","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\"},{\"kind\":\"label\",\"id\":14060665,\"project_id\":1027488,\"name\":\"super-special-label\",\"created_at\":\"2016-02-12T23:45:13Z\",\"updated_at\":\"2016-02-12T23:45:13Z\"}],\"created_at\":\"2014-02-17T00:00:00Z\",\"updated_at\":\"2017-01-05T00:40:49Z\",\"url\":\"https://www.pivotaltracker.com/story/show/66728004\"}"},"http_version":null},"recorded_at":"Thu, 05 Jan 2017 00:40:49 GMT"}],"recorded_with":"VCR 2.9.3"}