itriagetestrail 0.3.0 → 0.3.1

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: 48fd5bf4593acf9c2c1752e83e1348e6f8ccaceb
4
- data.tar.gz: f7058a9004e1362966da144cfd6f75f31480bd63
3
+ metadata.gz: 44ad143da93506b4a1d678405bf4bfadc376434f
4
+ data.tar.gz: 7fafe7e9215c948e47740c1cadb8268640f5795b
5
5
  SHA512:
6
- metadata.gz: 6abbc8adf2e336daa0a9734026ea0161d2cec1cc3e536cd7e3f0860fd47e0fcc0b195a844733e9ecc578c7e80f92b86b4225e5f5075da67d8bb383745816a1c4
7
- data.tar.gz: 47fa313f6e72d0ccf45248cb7e65fc16f37fa84dd1185cbfac2f19400ef54cc75849043a4eb017d423b04786e23e61a3d537317df2847eff02c0f17eb9e608fc
6
+ metadata.gz: 98adeed205e172d515937130a926ed6933d196711a571d71bdc03d59b30a398596aa0e1845b9d026d5a4919fa9287cca7db6f3837526dd85e1830cf39de73fee
7
+ data.tar.gz: 4acac7a2c65415fabaeb2c38248d38b8503ba59a8607c5d6850672bb76ca59176d02216155255c181507bf51776e498b1345f7704ab2d04aabee301b368b5d37
@@ -1,3 +1,3 @@
1
1
  module Itriagetestrail
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -61,6 +61,9 @@ module Itriagetestrail
61
61
  # Get the test rail ids
62
62
  testrail_ids
63
63
 
64
+ reset_milestone('Master')
65
+ reset_milestone('Dev Branch')
66
+
64
67
  @milestone_id = fetch_milestone(@milestone_name)
65
68
 
66
69
  add_testrail_run if @run_id == 0
@@ -125,6 +128,42 @@ module Itriagetestrail
125
128
  end
126
129
  end
127
130
 
131
+ # returns timestamp for begining of first day of current quarter
132
+ def milestone_period_start
133
+ time_zone = TZInfo::Timezone.get('America/Denver')
134
+ current_year = time_zone.now.year
135
+ month = time_zone.now.mon
136
+
137
+ # determine which quarter we are in
138
+ if month <= 3
139
+ time_zone.utc_to_local(Time.utc(current_year, 1, 1))
140
+ elsif month <= 6
141
+ time_zone.utc_to_local(Time.utc(current_year, 4, 1))
142
+ elsif month <= 9
143
+ time_zone.utc_to_local(Time.utc(current_year, 7, 1))
144
+ else
145
+ time_zone.utc_to_local(Time.utc(current_year, 10, 1))
146
+ end
147
+ end
148
+
149
+ # determine the due date (end of quarter) for milestone being added
150
+ def milestone_due_date
151
+ time_zone = TZInfo::Timezone.get('America/Denver')
152
+ current_year = time_zone.now.year
153
+ month = time_zone.now.mon
154
+
155
+ # determine which quarter we are in
156
+ if month <= 3
157
+ time_zone.utc_to_local(Time.utc(current_year, 3, 31)).strftime('%s')
158
+ elsif month <= 6
159
+ time_zone.utc_to_local(Time.utc(current_year, 6, 30)).strftime('%s')
160
+ elsif month <= 9
161
+ time_zone.utc_to_local(Time.utc(current_year, 9, 30)).strftime('%s')
162
+ else
163
+ time_zone.utc_to_local(Time.utc(current_year, 12, 31)).strftime('%s')
164
+ end
165
+ end
166
+
128
167
  def fetch_milestone(requested_milestone_name)
129
168
  milestones = @client.send_get("get_milestones/#{@project_id}")
130
169
  res = -1
@@ -136,7 +175,8 @@ module Itriagetestrail
136
175
  # We need to add the milestone to TestRail
137
176
 
138
177
  body = {
139
- name: requested_milestone_name
178
+ name: requested_milestone_name,
179
+ due_on: milestone_due_date
140
180
  }
141
181
 
142
182
  res = @client.send_post("add_milestone/#{@project_id}", body)['id']
@@ -144,6 +184,45 @@ module Itriagetestrail
144
184
  res
145
185
  end
146
186
 
187
+ def milestone_archive_name(milestone_name, date)
188
+ year = date.year
189
+ month = date.mon
190
+
191
+ if month <= 3
192
+ "#{milestone_name} #{year}-Q1"
193
+ elsif month <= 6
194
+ "#{milestone_name} #{year}-Q2"
195
+ elsif month <= 9
196
+ "#{milestone_name} #{year}-Q3"
197
+ else
198
+ "#{milestone_name} #{year}-Q4"
199
+ end
200
+ end
201
+
202
+ def milestone_runs(milestone_name)
203
+ # use the matching milestone id for project
204
+ milestone_id = fetch_milestone(milestone_name)
205
+
206
+ # fetch all test runs associated with the milestone id for project
207
+ @client.send_get("get_runs/#{@project_id}&milestone_id=#{milestone_id}") || []
208
+ end
209
+
210
+ def rename_milestone(id, new_name)
211
+ # todo: rename milestone with previous_milestone
212
+ body = { name: new_name }
213
+ res = @client.send_post("update_milestone/#{id}", body)['id']
214
+ end
215
+
216
+ def reset_milestone(milestone_name)
217
+ runs = milestone_runs(milestone_name)
218
+ if runs.size > 0
219
+ last_run_time = Time.at(runs.last['completed_on'])
220
+ if last_run_time < milestone_period_start
221
+ rename_milestone(@milestone_id, milestone_archive_name(milestone_name, last_run_time))
222
+ end
223
+ end
224
+ end
225
+
147
226
  def add_testrail_section(section_title)
148
227
  body = {
149
228
  name: section_title
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itriagetestrail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - a801069
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-03 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler