tracker_api 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tracker_api/client.rb +7 -0
- data/lib/tracker_api/endpoints/comments.rb +20 -0
- data/lib/tracker_api/resources/base.rb +2 -2
- data/lib/tracker_api/resources/comment.rb +20 -0
- data/lib/tracker_api/resources/story.rb +13 -0
- data/lib/tracker_api/version.rb +1 -1
- data/lib/tracker_api.rb +2 -0
- data/test/project_test.rb +11 -0
- data/test/vcr/cassettes/client_get_all_stories_with_pagination.json +1 -1
- data/test/vcr/cassettes/client_get_limited_stories_with_no_pagination.json +1 -1
- data/test/vcr/cassettes/client_get_single_story_by_story_id.json +1 -1
- data/test/vcr/cassettes/create_story.json +1 -1
- data/test/vcr/cassettes/create_story_with_lengthy_params.json +1 -0
- data/test/vcr/cassettes/get_tasks.json +1 -1
- data/test/vcr/cassettes/get_tasks_when_stories_filtered.json +1 -1
- data/test/vcr/cassettes/get_unscheduled_stories.json +1 -1
- data/test/vcr/cassettes/save_story.json +1 -1
- data/test/vcr/cassettes/save_story_with_multiple_changes.json +1 -1
- data/test/vcr/cassettes/update_story_to_create_activity.json +1 -1
- data/tracker_api.gemspec +0 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 574ce0412dc95a283aa0c113ed1721ae17b82a69
|
4
|
+
data.tar.gz: fc97cfdea9564ff36ff84ce3ff6a3799d3d457fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c7088ba55869b3bd0002d341a451da492078568cf6e40cb8b1d82426f5b6e8c83d94e77f090dfdaa360f211437e14a8e6ce3b3d380152edc6f8d5914dcc38f
|
7
|
+
data.tar.gz: 613f22bb5629304b2ff241a211c16bbaf2a2908c4ec1405cba963d56edaf38c79b8c32c6113ebb91a53cb0bdf31b63e19d87aeaf6ef9cf9a981e1c1ae76041b5
|
data/lib/tracker_api/client.rb
CHANGED
@@ -186,6 +186,13 @@ module TrackerApi
|
|
186
186
|
body = options[:body]
|
187
187
|
headers = options[:headers]
|
188
188
|
|
189
|
+
if (method == :post || method == :put) && options[:body].blank?
|
190
|
+
body = params.to_json
|
191
|
+
headers['Content-Type'] = 'application/json'
|
192
|
+
|
193
|
+
params = {}
|
194
|
+
end
|
195
|
+
|
189
196
|
@last_response = response = connection.send(method) do |req|
|
190
197
|
req.url(url)
|
191
198
|
req.headers.merge!(headers)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module TrackerApi
|
2
|
+
module Endpoints
|
3
|
+
class Comments
|
4
|
+
attr_accessor :client
|
5
|
+
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def get(project_id, story_id, params={})
|
11
|
+
data = client.paginate("/projects/#{project_id}/stories/#{story_id}/comments", params: params)
|
12
|
+
raise TrackerApi::Errors::UnexpectedData, 'Array of comments expected' unless data.is_a? Array
|
13
|
+
|
14
|
+
data.map do |comment|
|
15
|
+
Resources::Comment.new({ story_id: story_id }.merge(comment))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module TrackerApi
|
2
|
+
module Resources
|
3
|
+
class Comment
|
4
|
+
include Virtus.model
|
5
|
+
|
6
|
+
attribute :id, Integer
|
7
|
+
attribute :story_id, Integer
|
8
|
+
attribute :epic_id, Integer
|
9
|
+
attribute :text, String
|
10
|
+
attribute :person_id, Integer
|
11
|
+
attribute :created_at, DateTime
|
12
|
+
attribute :updated_at, DateTime
|
13
|
+
attribute :file_attachment_ids, Array[Integer]
|
14
|
+
attribute :google_attachment_ids, Array[Integer]
|
15
|
+
attribute :commit_identifier, String
|
16
|
+
attribute :commit_type, String
|
17
|
+
attribute :kind, String
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -7,6 +7,7 @@ module TrackerApi
|
|
7
7
|
|
8
8
|
attribute :accepted_at, DateTime
|
9
9
|
attribute :comment_ids, Array[Integer]
|
10
|
+
attribute :comments, Array[TrackerApi::Resources::Comment]
|
10
11
|
attribute :created_at, DateTime
|
11
12
|
attribute :current_state, String # (accepted, delivered, finished, started, rejected, planned, unstarted, unscheduled)
|
12
13
|
attribute :deadline, DateTime
|
@@ -44,6 +45,18 @@ module TrackerApi
|
|
44
45
|
Endpoints::Activity.new(client).get_story(project_id, id, params)
|
45
46
|
end
|
46
47
|
|
48
|
+
# Provides a list of all the comments on the story.
|
49
|
+
#
|
50
|
+
# @param [Hash] params
|
51
|
+
# @return [Array[Comment]]
|
52
|
+
def comments(params = {})
|
53
|
+
if @comments.any?
|
54
|
+
@comments
|
55
|
+
else
|
56
|
+
@comments = Endpoints::Comments.new(client).get(project_id, id, params)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
47
60
|
# @param [Hash] params
|
48
61
|
# @return [Array[Task]]
|
49
62
|
def tasks(params = {})
|
data/lib/tracker_api/version.rb
CHANGED
data/lib/tracker_api.rb
CHANGED
@@ -32,6 +32,7 @@ module TrackerApi
|
|
32
32
|
autoload :Stories, 'tracker_api/endpoints/stories'
|
33
33
|
autoload :Story, 'tracker_api/endpoints/story'
|
34
34
|
autoload :Tasks, 'tracker_api/endpoints/tasks'
|
35
|
+
autoload :Comments, 'tracker_api/endpoints/comments'
|
35
36
|
end
|
36
37
|
|
37
38
|
module Resources
|
@@ -52,5 +53,6 @@ module TrackerApi
|
|
52
53
|
autoload :Story, 'tracker_api/resources/story'
|
53
54
|
autoload :Task, 'tracker_api/resources/task'
|
54
55
|
autoload :TimeZone, 'tracker_api/resources/time_zone'
|
56
|
+
autoload :Comment, 'tracker_api/resources/comment'
|
55
57
|
end
|
56
58
|
end
|
data/test/project_test.rb
CHANGED
@@ -115,6 +115,17 @@ describe TrackerApi::Resources::Project do
|
|
115
115
|
story.name.must_equal 'Test story'
|
116
116
|
end
|
117
117
|
end
|
118
|
+
|
119
|
+
it 'can create story with lengthy params' do
|
120
|
+
VCR.use_cassette('create story with lengthy params') do
|
121
|
+
story = project.create_story(name: 'Test story', description: ('Test description ' * 500))
|
122
|
+
|
123
|
+
story.must_be_instance_of TrackerApi::Resources::Story
|
124
|
+
story.id.wont_be_nil
|
125
|
+
story.id.must_be :>, 0
|
126
|
+
story.description.must_equal ('Test description ' * 500)
|
127
|
+
end
|
128
|
+
end
|
118
129
|
end
|
119
130
|
|
120
131
|
describe '.activity' do
|