tracker_api 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a725b042575ce91d5fe34fae3754d7f14ebad3b
4
- data.tar.gz: 3922fb5873893235e94de37dc705954965215604
3
+ metadata.gz: 574ce0412dc95a283aa0c113ed1721ae17b82a69
4
+ data.tar.gz: fc97cfdea9564ff36ff84ce3ff6a3799d3d457fc
5
5
  SHA512:
6
- metadata.gz: dc75849fe80c0a8a4614149dc1ad7d77b7bf9d6b036d0d305120ad2f8a1201e4fac7815a71b1496ce3894c7e96796e9a87f25132278353635cb0fa4383f2fba4
7
- data.tar.gz: e639910732c78410d570e198f965dfa0ae00ec39ce0e7171e2cc89e3d11976627acc46c4c0a16870c9476a7e87eea7eb8367a6b89584d634da5db01a66cebbe5
6
+ metadata.gz: c6c7088ba55869b3bd0002d341a451da492078568cf6e40cb8b1d82426f5b6e8c83d94e77f090dfdaa360f211437e14a8e6ce3b3d380152edc6f8d5914dcc38f
7
+ data.tar.gz: 613f22bb5629304b2ff241a211c16bbaf2a2908c4ec1405cba963d56edaf38c79b8c32c6113ebb91a53cb0bdf31b63e19d87aeaf6ef9cf9a981e1c1ae76041b5
@@ -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
@@ -20,7 +20,7 @@ module TrackerApi
20
20
  super
21
21
 
22
22
  # always reset dirty tracking on initialize
23
- reset_changes
23
+ clear_changes_information
24
24
  end
25
25
 
26
26
  private
@@ -68,4 +68,4 @@ module TrackerApi
68
68
  end
69
69
  end
70
70
  end
71
- end
71
+ 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 = {})
@@ -1,3 +1,3 @@
1
1
  module TrackerApi
2
- VERSION = '0.2.7'
2
+ VERSION = '0.2.8'
3
3
  end
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