reviewlette 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +27 -0
- data/.rspec +1 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +114 -0
- data/Guardfile +24 -0
- data/LICENSE +21 -0
- data/README.md +95 -0
- data/Rakefile +5 -0
- data/bin/reviewlette +7 -0
- data/lib/matching.rb +0 -0
- data/lib/reviewlette.rb +202 -0
- data/lib/reviewlette/database.rb +77 -0
- data/lib/reviewlette/exceptions.rb +7 -0
- data/lib/reviewlette/github_connection.rb +45 -0
- data/lib/reviewlette/graph_gen.rb +62 -0
- data/lib/reviewlette/mail.rb +27 -0
- data/lib/reviewlette/trello_connection.rb +79 -0
- data/lib/reviewlette/vacations.rb +38 -0
- data/lib/reviewlette/version.rb +3 -0
- data/prophet.rb +4 -0
- data/reviewlette.gemspec +26 -0
- data/spec/database_spec.rb +34 -0
- data/spec/github_connection_spec.rb +96 -0
- data/spec/reviewlette_spec.rb +367 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/request_stubbing.rb +305 -0
- data/spec/trello_connection_spec.rb +202 -0
- data/spec/vacation_spec.rb +12 -0
- data/task +1 -0
- metadata +145 -0
@@ -0,0 +1,367 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Reviewlette do
|
4
|
+
|
5
|
+
# set instance variable from local variable
|
6
|
+
def instance_variable!(variable_name)
|
7
|
+
Reviewlette.instance_variable_set("@#{variable_name}", send(variable_name.to_sym))
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:number) { 23 }
|
11
|
+
let(:title) { 'title' }
|
12
|
+
let(:body) { 'body' }
|
13
|
+
let(:githubname) { 'gitty' }
|
14
|
+
let(:trelloname) { 'jschmid' }
|
15
|
+
let(:github_stub) { github_stub }
|
16
|
+
let(:board) { stub_boards_call }
|
17
|
+
let(:repo) { 'repo/repo' }
|
18
|
+
let(:id) { 23 }
|
19
|
+
let(:card) { stub_card_call }
|
20
|
+
let(:logger) { double 'logger' }
|
21
|
+
let(:repos) { %w[repo/repo, repos/repos] }
|
22
|
+
let(:trello_connection) { double 'trello_connection' }
|
23
|
+
let(:reviewer) {double 'reviewer'}
|
24
|
+
let(:db) {Reviewlette::Database.new}
|
25
|
+
let(:github_connection) { double 'github_connection' }
|
26
|
+
let(:full_comment) { @full_comment = "@#{trelloname} will review https://github.com/#{repo}/issues/#{number.to_s}" }
|
27
|
+
let(:exp) { AlreadyAssignedException }
|
28
|
+
|
29
|
+
describe '.spin' do
|
30
|
+
before do
|
31
|
+
instance_variable! :github_connection
|
32
|
+
instance_variable! :repo
|
33
|
+
instance_variable! :trello_connection
|
34
|
+
instance_variable! :id
|
35
|
+
instance_variable! :repos
|
36
|
+
instance_variable! :title
|
37
|
+
instance_variable! :body
|
38
|
+
instance_variable! :number
|
39
|
+
instance_variable! :logger
|
40
|
+
instance_variable! :repos
|
41
|
+
issue = { number: 1, title: 'Title', body: 'Body' }
|
42
|
+
expect(Reviewlette).to receive(:setup)
|
43
|
+
expect(Reviewlette).to receive(:get_available_repos).and_return [repo]
|
44
|
+
expect(Reviewlette).to receive(:get_unassigned_github_issues).and_return [issue]
|
45
|
+
expect(Reviewlette).to receive(:find_card).and_return true
|
46
|
+
expect(Reviewlette).to receive(:update_vacations)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'spins until find_id' do
|
50
|
+
expect(Reviewlette).to receive(:find_id).and_return false
|
51
|
+
expect(Reviewlette).to_not receive(:set_reviewer)
|
52
|
+
expect(Reviewlette).to_not receive(:transform_name)
|
53
|
+
expect(Reviewlette).to_not receive(:add_reviewer_on_github)
|
54
|
+
expect(Reviewlette).to_not receive(:comment_on_github)
|
55
|
+
expect(Reviewlette).to_not receive(:add_to_trello_card)
|
56
|
+
expect(Reviewlette).to_not receive(:comment_on_trello)
|
57
|
+
expect(Reviewlette).to_not receive(:move_to_list)
|
58
|
+
expect(Reviewlette).to_not receive(:comment_on_error)
|
59
|
+
Reviewlette.spin
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'spins until set_reviewer' do
|
63
|
+
expect(Reviewlette).to receive(:find_id).and_return true
|
64
|
+
expect(Reviewlette).to receive(:set_reviewer)
|
65
|
+
expect(Reviewlette).to_not receive(:transform_name)
|
66
|
+
expect(Reviewlette).to_not receive(:add_reviewer_on_github)
|
67
|
+
expect(Reviewlette).to_not receive(:comment_on_github)
|
68
|
+
expect(Reviewlette).to_not receive(:add_to_trello_card)
|
69
|
+
expect(Reviewlette).to_not receive(:comment_on_trello)
|
70
|
+
expect(Reviewlette).to_not receive(:move_to_list)
|
71
|
+
expect(Reviewlette).to receive(:comment_on_error)
|
72
|
+
Reviewlette.spin
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'spins until set_reviewer' do
|
76
|
+
expect(Reviewlette).to receive(:find_id).and_return true
|
77
|
+
expect(Reviewlette).to receive(:set_reviewer).and_return true
|
78
|
+
expect(Reviewlette).to receive(:transform_name)
|
79
|
+
expect(Reviewlette).to receive(:add_reviewer_on_github)
|
80
|
+
expect(Reviewlette).to receive(:comment_on_github)
|
81
|
+
# expect(Reviewlette).to receive(:add_to_trello_card)
|
82
|
+
expect(Reviewlette).to receive(:comment_on_trello)
|
83
|
+
expect(Reviewlette).to receive(:move_to_list)
|
84
|
+
Reviewlette.instance_variable_set(:@reviewer, 'hi')
|
85
|
+
Reviewlette.instance_variable_set(:@db, db)
|
86
|
+
allow(@reviewer).to receive(:username)
|
87
|
+
expect(db).to receive(:add_pr_to_db).with('Title', @reviewer.username)
|
88
|
+
expect(Reviewlette.instance_variable_set(:@reviewer, nil))
|
89
|
+
expect(Reviewlette).to_not receive(:comment_on_error)
|
90
|
+
Reviewlette.spin
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '.get_available_repos' do
|
95
|
+
|
96
|
+
it 'pulls in an array on avaialble repos' do
|
97
|
+
|
98
|
+
instance_variable! :repos
|
99
|
+
expect(Reviewlette.instance_variable_get(:@repos)).to be_kind_of Array #ok
|
100
|
+
Reviewlette.get_available_repos
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#find_card' do
|
105
|
+
|
106
|
+
it 'finds the card by Github title' do
|
107
|
+
line = 'Review_1337_name_of_pr_trello_shortid_454'
|
108
|
+
pulls = { number: 1 }
|
109
|
+
expect(Reviewlette).to receive(:match_pr_id_with_issue_id).and_return [pulls]
|
110
|
+
allow(Reviewlette.find_card(line)).to receive(:match_pr_id_with_issue_id).and_return Array
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '.fetch_branch' do
|
116
|
+
|
117
|
+
it 'gets the branch_name from github' do
|
118
|
+
branch_name = 'review_github_branch_name_trello_23'
|
119
|
+
subject.instance_variable_set(:@pullreq_ids, {number: 1})
|
120
|
+
split_branch_name = branch_name.split('_')
|
121
|
+
instance_variable! :github_connection
|
122
|
+
expect(Reviewlette.instance_variable_get(:@pullreq_ids)).to receive_message_chain(:values, :index => 0).and_return number
|
123
|
+
expect(github_connection).to receive(:get_branch_name).and_return branch_name
|
124
|
+
expect(branch_name).to receive(:split).with('_').and_return split_branch_name
|
125
|
+
expect(split_branch_name).to receive_message_chain(:last, :to_i)
|
126
|
+
Reviewlette.fetch_branch
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '.comment_on_error' do
|
131
|
+
it 'posts a comment with the arror message on trello' do
|
132
|
+
instance_variable! :trello_connection
|
133
|
+
expect(trello_connection).to receive(:comment_on_card).with("Skipped Issue 1 because everyone on the team is assigned to the card", nil)
|
134
|
+
Reviewlette.comment_on_error
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '.get_unassigned_github_issues' do
|
139
|
+
it 'returns all unassigned issues' do
|
140
|
+
instance_variable! :github_connection
|
141
|
+
expect(github_connection).to receive_message_chain(:list_issues, :select)
|
142
|
+
Reviewlette.get_unassigned_github_issues
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe '.match_pr_id_with_issue_id' do
|
147
|
+
|
148
|
+
it 'matches issue id with pr id' do
|
149
|
+
instance_variable! :github_connection
|
150
|
+
instance_variable! :repo
|
151
|
+
pulls = {number: 1}
|
152
|
+
allow(github_connection).to receive(:list_pulls).and_return [pulls]
|
153
|
+
allow(pulls).to receive(:number).and_return [1]
|
154
|
+
Reviewlette.match_pr_id_with_issue_id
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
describe '.transform_name' do
|
160
|
+
it 'transforms trelloname to github name' do
|
161
|
+
instance_variable! :trelloname
|
162
|
+
Reviewlette.transform_name
|
163
|
+
expect(Reviewlette.instance_variable_get("@githubname")).to be_a_kind_of String
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe '.find_id' do
|
168
|
+
before do
|
169
|
+
instance_variable! :id
|
170
|
+
instance_variable! :trello_connection
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'finds the id' do
|
174
|
+
expect(trello_connection).to receive(:find_card_by_id).with(id).and_return card
|
175
|
+
Reviewlette.find_id
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'does not find the id' do
|
179
|
+
Reviewlette.instance_variable_set("@id", 0)
|
180
|
+
Reviewlette.instance_variable_set("@logger", logger)
|
181
|
+
expect(logger).to receive(:warn)
|
182
|
+
expect(Reviewlette.find_id).to be false
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '.set_reviewer' do
|
187
|
+
|
188
|
+
before do
|
189
|
+
Reviewlette.instance_variable_set("@reviewer", nil)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'sets the reviewer' do
|
193
|
+
reviewer = double('reviewer')
|
194
|
+
instance_variable! :trello_connection
|
195
|
+
instance_variable! :card
|
196
|
+
expect(trello_connection).to receive(:determine_reviewer).with(card).and_return reviewer
|
197
|
+
expect(reviewer).to receive(:username).and_return String
|
198
|
+
expect(reviewer).to receive(:username).and_return String
|
199
|
+
Reviewlette.set_reviewer
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'fails to set the reviewer because everyone on the team is assigned to the card' do
|
203
|
+
reviewer = double('reviewer')
|
204
|
+
instance_variable! :trello_connection
|
205
|
+
instance_variable! :card
|
206
|
+
Reviewlette.instance_variable_set("@logger", logger)
|
207
|
+
expect(trello_connection).to receive(:determine_reviewer).with(card).and_raise(Reviewlette::AlreadyAssignedException)
|
208
|
+
allow(card).to receive(:short_id).and_return 3
|
209
|
+
expect($stdout).to receive(:puts)
|
210
|
+
expect(logger).to receive(:warn)
|
211
|
+
expect(Reviewlette.set_reviewer).to eq false
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe '.add_reviewer_on_github' do
|
216
|
+
it 'adds the reviewer on github as assignee' do
|
217
|
+
instance_variable! :github_connection
|
218
|
+
instance_variable! :title
|
219
|
+
instance_variable! :body
|
220
|
+
instance_variable! :number
|
221
|
+
instance_variable! :githubname
|
222
|
+
expect(github_connection).to receive(:add_assignee).with('repo/repo', 23, 'title', 'body', 'gitty').and_return true
|
223
|
+
Reviewlette.add_reviewer_on_github
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe '.comment_on_github' do
|
228
|
+
it 'comments on the issue' do
|
229
|
+
instance_variable! :card
|
230
|
+
instance_variable! :number
|
231
|
+
instance_variable! :githubname
|
232
|
+
instance_variable! :github_connection
|
233
|
+
expect(card).to receive(:url).and_return 'www.example.url'
|
234
|
+
expect(github_connection).to receive(:comment_on_issue).with('repo/repo', 23, 'gitty', 'www.example.url').and_return true
|
235
|
+
Reviewlette.comment_on_github
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
describe '.add_to_trello_card' do
|
240
|
+
it 'adds a reviewer to the right trello card' do
|
241
|
+
instance_variable! :trello_connection
|
242
|
+
instance_variable! :reviewer
|
243
|
+
instance_variable! :card
|
244
|
+
expect(trello_connection).to receive(:add_reviewer_to_card).with(reviewer, card).and_return true
|
245
|
+
Reviewlette.add_to_trello_card
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'rescues with: already assigned' do
|
249
|
+
instance_variable! :trello_connection
|
250
|
+
expect{Reviewlette.add_to_trello_card}.to raise_exception
|
251
|
+
# Reviewlette.add_to_trello_card
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe '.comment_on_trello' do
|
256
|
+
before do
|
257
|
+
instance_variable! :repo
|
258
|
+
instance_variable! :trelloname
|
259
|
+
instance_variable! :number
|
260
|
+
instance_variable! :trello_connection
|
261
|
+
instance_variable! :full_comment
|
262
|
+
instance_variable! :card
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'puts a comment on the trello card ' do
|
266
|
+
expect(full_comment).to eq '@jschmid will review https://github.com/repo/repo/issues/23'
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'actually posts' do
|
270
|
+
expect(trello_connection).to receive(:comment_on_card).with(full_comment, card).and_return true
|
271
|
+
Reviewlette.comment_on_trello
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
describe '.move_to_list' do
|
276
|
+
before do
|
277
|
+
instance_variable! :github_connection
|
278
|
+
instance_variable! :trello_connection
|
279
|
+
instance_variable! :card
|
280
|
+
instance_variable! :repo
|
281
|
+
instance_variable! :id
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'moves the card to #Done list if the pull is merged' do
|
285
|
+
expect(trello_connection).to receive(:find_column).with('Done').and_return 'Done'
|
286
|
+
expect(trello_connection).to receive(:move_card_to_list).with(card,'Done').and_return Object
|
287
|
+
expect(github_connection).to receive(:pull_merged?).with(repo, id).and_return true
|
288
|
+
Reviewlette.move_to_list
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'moves the card to #in-Review list if the pull is not merged' do
|
292
|
+
expect(trello_connection).to receive(:find_column).with('In review').and_return 'In review'
|
293
|
+
expect(trello_connection).to receive(:move_card_to_list).with(card,'In review').and_return Object
|
294
|
+
expect(github_connection).to receive(:pull_merged?).with(repo, id).and_return false
|
295
|
+
Reviewlette.move_to_list
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
describe '.setup' do
|
300
|
+
before do
|
301
|
+
instance_variable! :github_connection
|
302
|
+
instance_variable! :trello_connection
|
303
|
+
instance_variable! :board
|
304
|
+
instance_variable! :repo
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'sets up repo variable' do
|
308
|
+
Reviewlette.setup
|
309
|
+
expect(Reviewlette.instance_variable_get('@repo')).to be_kind_of String #ok
|
310
|
+
end
|
311
|
+
it 'sets up the github_connection' do
|
312
|
+
Reviewlette.setup
|
313
|
+
expect(github_connection).to be_kind_of Object #how to call this kind of structure
|
314
|
+
end
|
315
|
+
|
316
|
+
it 'sets up the trello_connection' do
|
317
|
+
Reviewlette.setup
|
318
|
+
expect(Reviewlette.instance_variable_get('@trello_connection')).to be_kind_of Object #same
|
319
|
+
end
|
320
|
+
|
321
|
+
it 'sets up the board' do
|
322
|
+
Reviewlette.setup
|
323
|
+
expect(Reviewlette.instance_variable_get('@board')).to be_kind_of Object #same
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
describe '.update_vacations' do
|
328
|
+
|
329
|
+
it 'updates vacationsstatus based on tel vacation output' do
|
330
|
+
vacations = ['2015-01-07', '2015-01-25']
|
331
|
+
instance_variable_set(:@vacations, vacations)
|
332
|
+
instance_variable_set(:@db, db)
|
333
|
+
expect(Reviewlette::Vacations).to receive(:find_vacations).at_least(:once)
|
334
|
+
expect(Reviewlette).to receive(:evaluate_vacations).at_least(:once)
|
335
|
+
Reviewlette.update_vacations
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
describe '.evaluate_vacations' do
|
340
|
+
|
341
|
+
it 'checks if vacation state is true' do
|
342
|
+
today = Date.today
|
343
|
+
allow(subject).to receive(:parse_vacations).and_return [[today]]
|
344
|
+
subject.evaluate_vacations('jschmid')
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'checks if vacation state is false' do
|
348
|
+
allow(subject).to receive(:parse_vacations).and_return [1,2]
|
349
|
+
subject.evaluate_vacations('jschmid')
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
|
354
|
+
describe '.parse_vacations' do
|
355
|
+
|
356
|
+
it 'parses Date in proper format' do
|
357
|
+
# vacations = ["2014-08-23 - 2014-09-14", "2014-10-03 - 2014-10-05", "2014-12-24 - 2014-12-28"]
|
358
|
+
# split = [["2014-08-23", "2014-09-14"], ["2014-10-03", "2014-10-05"], ["2014-12-24", "2014-12-28"]]
|
359
|
+
# ret = [['Sat, 23 Aug 2014', 'Sun, 14 Sep 2014'], ['Fri, 03 Oct 2014', 'Sun, 05 Oct 2014'], ['Wed, 24 Dec 2014', 'Sun, 28 Dec 2014']]
|
360
|
+
# instance_variable_set(:@vacations, vacations)
|
361
|
+
# instance_variable_set(:@split, split)
|
362
|
+
# expect(instance_variable_get(:@vacations)).to receive(:map).and_return split
|
363
|
+
# expect(instance_variable_get(:@split)).to receive(:map).and_return ret
|
364
|
+
# subject.parse_vacations
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__))) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.minimum_coverage 80
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
9
|
+
SimpleCov.start do
|
10
|
+
add_filter '/spec/'
|
11
|
+
#add_filter 'vendor'
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
require 'webmock/rspec'
|
16
|
+
require 'rspec'
|
17
|
+
require_relative '../lib/reviewlette/exceptions'
|
18
|
+
require_relative '../lib/reviewlette/vacations'
|
19
|
+
require_relative '../lib/reviewlette/database'
|
20
|
+
require 'reviewlette'
|
21
|
+
require 'support/request_stubbing'
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,305 @@
|
|
1
|
+
module Helpers
|
2
|
+
|
3
|
+
def user_details
|
4
|
+
{
|
5
|
+
'id' => 'abcdef123456789012345678',
|
6
|
+
'fullName' => 'Test User',
|
7
|
+
'username' => 'me',
|
8
|
+
'intials' => 'TU',
|
9
|
+
'avatarHash' => 'abcdef1234567890abcdef1234567890',
|
10
|
+
'bio' => 'a rather dumb user',
|
11
|
+
'url' => 'https://trello.com/me',
|
12
|
+
'email' => 'johnsmith@example.com'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def user_payload
|
17
|
+
JSON.generate(user_details)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.boards_details
|
21
|
+
[{
|
22
|
+
'id' => 'abcdef123456789123456789',
|
23
|
+
'name' => 'Test',
|
24
|
+
'desc' => 'This is a test board',
|
25
|
+
'closed' => false,
|
26
|
+
'idOrganization' => 'abcdef123456789123456789',
|
27
|
+
'url' => 'https://trello.com/board/test/abcdef123456789123456789'
|
28
|
+
}]
|
29
|
+
end
|
30
|
+
|
31
|
+
def boards_payload
|
32
|
+
JSON.generate(boards_details)
|
33
|
+
end
|
34
|
+
|
35
|
+
def checklists_details
|
36
|
+
[{
|
37
|
+
'id' => 'abcdef123456789123456789',
|
38
|
+
'name' => 'Test Checklist',
|
39
|
+
'desc' => 'A marvelous little checklist',
|
40
|
+
'closed' => false,
|
41
|
+
'position' => 16384,
|
42
|
+
'url' => 'https://trello.com/blah/blah',
|
43
|
+
'idBoard' => 'abcdef123456789123456789',
|
44
|
+
'idList' => 'abcdef123456789123456789',
|
45
|
+
'idMembers' => ['abcdef123456789123456789'],
|
46
|
+
'checkItems' => { 'id' => 'ghijk987654321' }
|
47
|
+
}]
|
48
|
+
end
|
49
|
+
|
50
|
+
def checklists_payload
|
51
|
+
JSON.generate(checklists_details)
|
52
|
+
end
|
53
|
+
|
54
|
+
def lists_details
|
55
|
+
[{
|
56
|
+
'id' => 'abcdef123456789123456789',
|
57
|
+
'name' => 'To Do',
|
58
|
+
'closed' => false,
|
59
|
+
'idBoard' => 'abcdef123456789123456789',
|
60
|
+
'cards' => cards_details
|
61
|
+
}]
|
62
|
+
end
|
63
|
+
|
64
|
+
def lists_payload
|
65
|
+
JSON.generate(lists_details)
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.cards_details
|
69
|
+
[{
|
70
|
+
'id' => 'abcdef123456789123456789',
|
71
|
+
'idShort' => '1',
|
72
|
+
'name' => 'Do something awesome',
|
73
|
+
'desc' => 'Awesome things are awesome.',
|
74
|
+
'closed' => false,
|
75
|
+
'idList' => 'abcdef123456789123456789',
|
76
|
+
'idBoard' => 'abcdef123456789123456789',
|
77
|
+
'idAttachmentCover' => 'abcdef123456789123456789',
|
78
|
+
'idMembers' => ['abcdef123456789123456789'],
|
79
|
+
'url' => 'https://trello.com/card/board/specify-the-type-and-scope-of-the-jit-in-a-lightweight-spec/abcdef123456789123456789/abcdef123456789123456789',
|
80
|
+
'shortUrl' => 'https://trello.com/c/abcdef12',
|
81
|
+
'pos' => 12,
|
82
|
+
'dateLastActivity' => '2012-12-07T18:40:24.314Z'
|
83
|
+
}]
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def cards_payload
|
88
|
+
JSON.generate(cards_details)
|
89
|
+
end
|
90
|
+
|
91
|
+
def attachments_details
|
92
|
+
[{
|
93
|
+
'id' => 'abcdef123456789123456789',
|
94
|
+
'name' => 'attachment1.png',
|
95
|
+
'url' => 'http://trello-assets.domain.tld/attachment1.png',
|
96
|
+
'bytes' => 98765,
|
97
|
+
'idMember' => 'abcdef123456789123456781',
|
98
|
+
'isUpload' => false,
|
99
|
+
'date' => '2013-02-28T17:12:28.497Z',
|
100
|
+
},
|
101
|
+
{
|
102
|
+
'id' => 'abcdef123456789123456781',
|
103
|
+
'name' => 'attachment2.png',
|
104
|
+
'url' => 'http://trello-assets.domain.tld/attachment2.png',
|
105
|
+
'bytes' => 89123,
|
106
|
+
'idMember' => 'abcdef123456789123456782',
|
107
|
+
'isUpload' => true,
|
108
|
+
'date' => '2013-03-01T14:01:25.212Z',
|
109
|
+
}]
|
110
|
+
end
|
111
|
+
|
112
|
+
def attachments_payload
|
113
|
+
JSON.generate(attachments_details)
|
114
|
+
end
|
115
|
+
|
116
|
+
def card_payload
|
117
|
+
JSON.generate(cards_details.first)
|
118
|
+
end
|
119
|
+
|
120
|
+
def orgs_details
|
121
|
+
[{
|
122
|
+
'id' => 'abcdef123456789123456789',
|
123
|
+
'name' => 'test',
|
124
|
+
'displayName' => 'Test Organization',
|
125
|
+
'desc' => 'This is a test organization',
|
126
|
+
'url' => 'https://trello.com/test'
|
127
|
+
}]
|
128
|
+
end
|
129
|
+
|
130
|
+
def orgs_payload
|
131
|
+
JSON.generate(orgs_details)
|
132
|
+
end
|
133
|
+
|
134
|
+
def actions_details
|
135
|
+
[{
|
136
|
+
'id' => '4ee2482134a81a757a08af47',
|
137
|
+
'idMemberCreator' => 'abcdef123456789123456789',
|
138
|
+
'data'=> {
|
139
|
+
'card' => {
|
140
|
+
'id' => '4ee2482134a81a757a08af45',
|
141
|
+
'name' => 'Bytecode outputter'
|
142
|
+
},
|
143
|
+
'board' => {
|
144
|
+
'id' => '4ec54f2f73820a0dea0d1f0e',
|
145
|
+
'name' => 'Caribou VM'
|
146
|
+
},
|
147
|
+
'list' => {
|
148
|
+
'id' => '4ee238b034a81a757a05cda0',
|
149
|
+
'name' => 'Assembler'
|
150
|
+
}
|
151
|
+
},
|
152
|
+
'date' => '2012-02-10T11:32:17Z',
|
153
|
+
'type' => 'createCard'
|
154
|
+
}]
|
155
|
+
end
|
156
|
+
|
157
|
+
def actions_payload
|
158
|
+
JSON.generate(actions_details)
|
159
|
+
end
|
160
|
+
|
161
|
+
def notification_details
|
162
|
+
{
|
163
|
+
'id' => '4f30d084d5b0f7ab453bee51',
|
164
|
+
'unread' => false,
|
165
|
+
'type' => 'commentCard',
|
166
|
+
'date' => '2012-02-07T07:19:32.393Z',
|
167
|
+
'data' => {
|
168
|
+
'board' => {
|
169
|
+
'id' => 'abcdef123456789123456789',
|
170
|
+
'name' => 'Test'
|
171
|
+
},
|
172
|
+
'card'=>{
|
173
|
+
'id' => 'abcdef123456789123456789',
|
174
|
+
'name' => 'Do something awesome'
|
175
|
+
},
|
176
|
+
'text' => 'test'
|
177
|
+
},
|
178
|
+
'idMemberCreator' => 'abcdef123456789012345678'
|
179
|
+
}
|
180
|
+
end
|
181
|
+
|
182
|
+
def notification_payload
|
183
|
+
JSON.generate(notification_details)
|
184
|
+
end
|
185
|
+
|
186
|
+
def organization_details
|
187
|
+
{
|
188
|
+
'id' => '4ee7e59ae582acdec8000291',
|
189
|
+
'name' => 'publicorg',
|
190
|
+
'desc' => 'This is a test organization',
|
191
|
+
'members' => [{
|
192
|
+
'id' => '4ee7df3ce582acdec80000b2',
|
193
|
+
'username' => 'alicetester',
|
194
|
+
'fullName' => 'Alice Tester'
|
195
|
+
}, {
|
196
|
+
'id' => '4ee7df74e582acdec80000b6',
|
197
|
+
'username' => 'davidtester',
|
198
|
+
'fullName' => 'David Tester'
|
199
|
+
}, {
|
200
|
+
'id' => '4ee7e2e1e582acdec8000112',
|
201
|
+
'username' => 'edtester',
|
202
|
+
'fullName' => 'Ed Tester'
|
203
|
+
}]
|
204
|
+
}
|
205
|
+
end
|
206
|
+
|
207
|
+
def organization_payload
|
208
|
+
JSON.generate(organization_details)
|
209
|
+
end
|
210
|
+
|
211
|
+
def token_details
|
212
|
+
{
|
213
|
+
'id' => '4f2c10c7b3eb95a45b294cd5',
|
214
|
+
'idMember' => 'abcdef123456789123456789',
|
215
|
+
'dateCreated' => '2012-02-03T16:52:23.661Z',
|
216
|
+
'permissions' => [
|
217
|
+
{
|
218
|
+
'idModel' => 'me',
|
219
|
+
'modelType' => 'Member',
|
220
|
+
'read' => true,
|
221
|
+
'write' => true
|
222
|
+
},
|
223
|
+
{
|
224
|
+
'idModel' => '*',
|
225
|
+
'modelType' => 'Board',
|
226
|
+
'read' => true,
|
227
|
+
'write' => true
|
228
|
+
},
|
229
|
+
{
|
230
|
+
'idModel' => '*',
|
231
|
+
'modelType' => 'Organization',
|
232
|
+
'read' => true,
|
233
|
+
'write' => true
|
234
|
+
}
|
235
|
+
]
|
236
|
+
}
|
237
|
+
end
|
238
|
+
|
239
|
+
def token_payload
|
240
|
+
JSON.generate(token_details)
|
241
|
+
end
|
242
|
+
|
243
|
+
def label_details
|
244
|
+
[
|
245
|
+
{'color' => 'yellow', 'name' => 'iOS'},
|
246
|
+
{'color' => 'purple', 'name' => 'Issue or bug'}
|
247
|
+
]
|
248
|
+
end
|
249
|
+
|
250
|
+
def label_payload
|
251
|
+
JSON.generate(label_details)
|
252
|
+
end
|
253
|
+
|
254
|
+
def label_name_details
|
255
|
+
[
|
256
|
+
{'yellow' => 'bug'},
|
257
|
+
{'red' => 'urgent'},
|
258
|
+
{'green' => 'deploy'},
|
259
|
+
{'blue' => 'on hold'},
|
260
|
+
{'orange' => 'new feature'},
|
261
|
+
{'purple' => 'experimental'}
|
262
|
+
]
|
263
|
+
end
|
264
|
+
|
265
|
+
def label_name_payload
|
266
|
+
JSON.generate(label_name_details)
|
267
|
+
end
|
268
|
+
|
269
|
+
def webhooks_details
|
270
|
+
[
|
271
|
+
{
|
272
|
+
'id' => 'webhookid',
|
273
|
+
'description' => 'Test webhook',
|
274
|
+
'idModel' => '1234',
|
275
|
+
'callbackURL' => 'http://example.org/webhook',
|
276
|
+
'active' => true
|
277
|
+
}
|
278
|
+
]
|
279
|
+
end
|
280
|
+
|
281
|
+
def webhooks_payload
|
282
|
+
JSON.generate(webhooks_details)
|
283
|
+
end
|
284
|
+
|
285
|
+
def webhook_payload
|
286
|
+
JSON.generate(webhooks_details.first)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def oauth_client
|
291
|
+
Octokit::Client.new(:access_token => '13131313131313131313131313')
|
292
|
+
end
|
293
|
+
|
294
|
+
|
295
|
+
def stub_boards_call
|
296
|
+
trello_config = Reviewlette::TRELLO_CONFIG1
|
297
|
+
stub_request(:get, "https://api.trello.com/1/boards/UuKxYj6M?key=#{trello_config['consumerkey']}&token=#{trello_config['oauthtoken']}")
|
298
|
+
.to_return(:status => 200, :body => Helpers.boards_details.first.to_json)
|
299
|
+
end
|
300
|
+
|
301
|
+
def stub_card_call
|
302
|
+
trello_config = Reviewlette::TRELLO_CONFIG1
|
303
|
+
stub_request(:get, "https://api.trello.com/cards/8SoYLG6A?key=#{trello_config['consumerkey']}&token=#{trello_config['oauthtoken']}")
|
304
|
+
.to_return(:status => 200, :body => Helpers.cards_details.first.to_json)
|
305
|
+
end
|