lazylead 0.1.2 → 0.4.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 +4 -4
- data/.0pdd.yml +4 -1
- data/.circleci/config.yml +14 -4
- data/.docker/Dockerfile +5 -4
- data/.docker/vcs.dockerfile +10 -0
- data/.docs/accuracy.md +107 -0
- data/.docs/accuracy_email.jpg +0 -0
- data/.docs/accuracy_jira_comment.jpg +0 -0
- data/.docs/duedate_expired.md +92 -0
- data/.docs/propagate_down.md +89 -0
- data/.pdd +1 -1
- data/.rubocop.yml +7 -1
- data/.rultor.yml +2 -2
- data/.simplecov +0 -6
- data/bin/lazylead +13 -5
- data/lazylead.gemspec +4 -16
- data/lib/lazylead/cc.rb +180 -0
- data/lib/lazylead/cli/app.rb +4 -3
- data/lib/lazylead/exchange.rb +15 -2
- data/lib/lazylead/home.rb +38 -0
- data/lib/lazylead/log.rb +30 -8
- data/lib/lazylead/model.rb +60 -16
- data/lib/lazylead/opts.rb +68 -0
- data/lib/lazylead/postman.rb +15 -15
- data/lib/lazylead/schedule.rb +6 -4
- data/lib/lazylead/smtp.rb +1 -1
- data/lib/lazylead/system/fake.rb +1 -1
- data/lib/lazylead/system/jira.rb +55 -12
- data/lib/lazylead/system/synced.rb +2 -1
- data/lib/lazylead/task/accuracy/accuracy.rb +140 -0
- data/lib/lazylead/task/accuracy/affected_build.rb +43 -0
- data/lib/lazylead/task/accuracy/requirement.rb +40 -0
- data/lib/lazylead/task/alert.rb +8 -6
- data/lib/lazylead/task/confluence_ref.rb +4 -3
- data/lib/lazylead/task/echo.rb +4 -0
- data/lib/lazylead/task/fix_version.rb +10 -6
- data/lib/lazylead/task/missing_comment.rb +7 -5
- data/lib/lazylead/task/propagate_down.rb +126 -0
- data/lib/lazylead/task/savepoint.rb +58 -0
- data/lib/lazylead/task/touch.rb +102 -0
- data/lib/lazylead/version.rb +1 -1
- data/lib/messages/accuracy.erb +118 -0
- data/lib/messages/due_date_expired.erb +8 -7
- data/lib/messages/illegal_fixversion_change.erb +9 -8
- data/lib/messages/missing_comment.erb +10 -9
- data/lib/messages/savepoint.erb +43 -0
- data/lib/messages/svn_touch.erb +147 -0
- data/readme.md +37 -34
- data/test/lazylead/cc_test.rb +153 -0
- data/test/lazylead/cli/app_test.rb +3 -4
- data/test/lazylead/exchange_test.rb +22 -2
- data/test/lazylead/model_test.rb +14 -3
- data/test/lazylead/opts_test.rb +66 -0
- data/test/lazylead/postman_test.rb +57 -0
- data/test/lazylead/smtp_test.rb +1 -1
- data/test/lazylead/system/jira_test.rb +43 -1
- data/test/lazylead/task/accuracy/accuracy_test.rb +73 -0
- data/test/lazylead/task/accuracy/affected_build_test.rb +42 -0
- data/test/lazylead/task/assignee_alert_test.rb +47 -0
- data/test/lazylead/task/duedate_test.rb +52 -30
- data/test/lazylead/task/fix_version_test.rb +11 -10
- data/test/lazylead/task/missing_comment_test.rb +13 -13
- data/test/lazylead/task/propagate_down_test.rb +88 -0
- data/test/lazylead/task/savepoint_test.rb +51 -0
- data/test/lazylead/task/touch_test.rb +63 -0
- data/test/test.rb +11 -0
- data/upgrades/sqlite/001-install-main-lazylead-tables.sql +0 -1
- data/upgrades/sqlite/999.testdata.sql +8 -2
- metadata +43 -176
- data/todo.yml +0 -6
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2020 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require_relative "../../../test"
|
26
|
+
require_relative "../../../../lib/lazylead/smtp"
|
27
|
+
require_relative "../../../../lib/lazylead/task/accuracy/accuracy"
|
28
|
+
require_relative "../../../../lib/lazylead/opts"
|
29
|
+
require_relative "../../../../lib/lazylead/postman"
|
30
|
+
require_relative "../../../../lib/lazylead/cli/app"
|
31
|
+
require_relative "../../../../lib/lazylead/system/jira"
|
32
|
+
|
33
|
+
module Lazylead
|
34
|
+
class AccuracyTest < Lazylead::Test
|
35
|
+
test "detect affected build" do
|
36
|
+
Lazylead::Smtp.new.enable
|
37
|
+
Task::Accuracy.new.run(
|
38
|
+
NoAuthJira.new("https://jira.spring.io"),
|
39
|
+
Postman.new,
|
40
|
+
Opts.new(
|
41
|
+
"from" => "ll@fake.com",
|
42
|
+
"to" => "lead@fake.com",
|
43
|
+
"rules" => "Lazylead::RequirementAffectedBuild",
|
44
|
+
"silent" => "true",
|
45
|
+
"colors" => {
|
46
|
+
"0" => "#FF4F33",
|
47
|
+
"35" => "#FF9F33",
|
48
|
+
"57" => "#19DD1E",
|
49
|
+
"90" => "#0FA81A"
|
50
|
+
}.to_json.to_s,
|
51
|
+
"docs" => "https://github.com/dgroup/lazylead/blob/master/.github/ISSUE_TEMPLATE/bug_report.md",
|
52
|
+
"jql" => "key in (DATAJDBC-490, DATAJDBC-492, DATAJDBC-493)",
|
53
|
+
"max_results" => 200,
|
54
|
+
"subject" => "[LL] Raised tickets",
|
55
|
+
"template" => "lib/messages/accuracy.erb"
|
56
|
+
)
|
57
|
+
)
|
58
|
+
assert_email "[LL] Raised tickets",
|
59
|
+
%w[DATAJDBC-493 0.5 100% MyeongHyeonLee Deadlock\ occurs]
|
60
|
+
end
|
61
|
+
|
62
|
+
test "construct accuracy from orm" do
|
63
|
+
CLI::App.new(Log.new, NoSchedule.new).run(
|
64
|
+
home: ".",
|
65
|
+
sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
|
66
|
+
vcs4sql: "upgrades/sqlite",
|
67
|
+
testdata: true
|
68
|
+
)
|
69
|
+
assert_kind_of Lazylead::Task::Accuracy,
|
70
|
+
ORM::Task.find(195).action.constantize.new
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2020 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require_relative "../../../test"
|
26
|
+
require_relative "../../../../lib/lazylead/task/accuracy/affected_build"
|
27
|
+
|
28
|
+
module Lazylead
|
29
|
+
class AffectedBuildTest < Lazylead::Test
|
30
|
+
test "affected version absent" do
|
31
|
+
refute RequirementAffectedBuild.new.passed(
|
32
|
+
OpenStruct.new(fields: { "versions" => [] })
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
test "affected version provided" do
|
37
|
+
assert RequirementAffectedBuild.new.passed(
|
38
|
+
OpenStruct.new(fields: { "versions" => ["0.4.0"] })
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2020 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require_relative "../../test"
|
26
|
+
require_relative "../../../lib/lazylead/log"
|
27
|
+
require_relative "../../../lib/lazylead/smtp"
|
28
|
+
require_relative "../../../lib/lazylead/postman"
|
29
|
+
require_relative "../../../lib/lazylead/schedule"
|
30
|
+
require_relative "../../../lib/lazylead/model"
|
31
|
+
require_relative "../../../lib/lazylead/cli/app"
|
32
|
+
require_relative "../../../lib/lazylead/system/jira"
|
33
|
+
require_relative "../../../lib/lazylead/task/alert"
|
34
|
+
|
35
|
+
module Lazylead
|
36
|
+
class AssigneeAlertTest < Lazylead::Test
|
37
|
+
test "issue #154 undefined method to_hash for nil object" do
|
38
|
+
CLI::App.new(Log.new, NoSchedule.new).run(
|
39
|
+
home: ".",
|
40
|
+
sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
|
41
|
+
vcs4sql: "upgrades/sqlite",
|
42
|
+
testdata: true
|
43
|
+
)
|
44
|
+
assert_equal "lead@fake.com", ORM::Task.find(154).props["cc"]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -41,10 +41,12 @@ module Lazylead
|
|
41
41
|
Task::AssigneeAlert.new.run(
|
42
42
|
NoAuthJira.new("https://jira.spring.io"),
|
43
43
|
Postman.new,
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
Opts.new(
|
45
|
+
"from" => "fake@email.com",
|
46
|
+
"sql" => "filter=16743",
|
47
|
+
"subject" => "[DD] PDTN!",
|
48
|
+
"template" => "lib/messages/due_date_expired.erb"
|
49
|
+
)
|
48
50
|
)
|
49
51
|
assert_equal 2,
|
50
52
|
Mail::TestMailer.deliveries
|
@@ -53,7 +55,7 @@ module Lazylead
|
|
53
55
|
end
|
54
56
|
|
55
57
|
test "configuration properties merged successfully" do
|
56
|
-
CLI::App.new(Log
|
58
|
+
CLI::App.new(Log.new, NoSchedule.new).run(
|
57
59
|
home: ".",
|
58
60
|
sqlite: "test/resources/#{no_ext(__FILE__)}.#{__method__}.db",
|
59
61
|
vcs4sql: "upgrades/sqlite",
|
@@ -75,15 +77,15 @@ module Lazylead
|
|
75
77
|
Task::AssigneeAlert.new.run(
|
76
78
|
NoAuthJira.new("https://jira.spring.io"),
|
77
79
|
Postman.new,
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
Opts.new(
|
81
|
+
"from" => "fake@email.com",
|
82
|
+
"sql" => "key in ('STS-3599')",
|
83
|
+
"subject" => "[DD] HMCHT!",
|
84
|
+
"template" => "lib/messages/due_date_expired.erb"
|
85
|
+
)
|
82
86
|
)
|
83
|
-
|
84
|
-
|
85
|
-
.filter { |m| m.subject.eql? "[DD] HMCHT!" }
|
86
|
-
.first.body.parts.first.body
|
87
|
+
assert_email "[DD] HMCHT!",
|
88
|
+
%w[STS-3599 2013-11-08 Major Miles\ Parker Use JavaFX WebView]
|
87
89
|
end
|
88
90
|
|
89
91
|
test "send notification about bunch of tickets" do
|
@@ -91,17 +93,17 @@ module Lazylead
|
|
91
93
|
Task::Alert.new.run(
|
92
94
|
NoAuthJira.new("https://jira.spring.io"),
|
93
95
|
Postman.new,
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
Opts.new(
|
97
|
+
"from" => "fake@email.com",
|
98
|
+
"sql" => "key in ('STS-3599')",
|
99
|
+
"subject" => "ALRT: Frozen",
|
100
|
+
"template" => "lib/messages/due_date_expired.erb",
|
101
|
+
"to" => "big.boss@example.com",
|
102
|
+
"addressee" => "Boss"
|
103
|
+
)
|
100
104
|
)
|
101
|
-
|
102
|
-
|
103
|
-
.filter { |m| m.subject.eql? "ALRT: Frozen" }
|
104
|
-
.first.body.parts.first.body
|
105
|
+
assert_email "ALRT: Frozen",
|
106
|
+
%w[Hi Boss STS-3599 2013-11-08 Major Miles\ Parker Use JavaFX WebView]
|
105
107
|
end
|
106
108
|
|
107
109
|
test "cc got notification" do
|
@@ -109,18 +111,38 @@ module Lazylead
|
|
109
111
|
Task::Alert.new.run(
|
110
112
|
NoAuthJira.new("https://jira.spring.io"),
|
111
113
|
Postman.new,
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
Opts.new(
|
115
|
+
"from" => "fake@email.com",
|
116
|
+
"sql" => "key in ('STS-3599')",
|
117
|
+
"subject" => "CC: Watching",
|
118
|
+
"template" => "lib/messages/due_date_expired.erb",
|
119
|
+
"to" => "big.boss@example.com",
|
120
|
+
"addressee" => "Boss",
|
121
|
+
"cc" => "another.boss@example.com,mom@home.com"
|
122
|
+
)
|
119
123
|
)
|
120
124
|
assert_equal %w[another.boss@example.com mom@home.com],
|
121
125
|
Mail::TestMailer.deliveries
|
122
126
|
.filter { |m| m.subject.eql? "CC: Watching" }
|
123
127
|
.first.cc
|
124
128
|
end
|
129
|
+
|
130
|
+
test "reporter got alert about his/her tickets with expired DD" do
|
131
|
+
Smtp.new.enable
|
132
|
+
Task::ReporterAlert.new.run(
|
133
|
+
NoAuthJira.new("https://jira.spring.io"),
|
134
|
+
Postman.new,
|
135
|
+
Opts.new(
|
136
|
+
"from" => "fake@email.com",
|
137
|
+
"sql" => "filter=16743",
|
138
|
+
"subject" => "DD Expired!",
|
139
|
+
"template" => "lib/messages/due_date_expired.erb"
|
140
|
+
)
|
141
|
+
)
|
142
|
+
assert_equal 2,
|
143
|
+
Mail::TestMailer.deliveries
|
144
|
+
.filter { |m| m.subject.eql? "DD Expired!" }
|
145
|
+
.length
|
146
|
+
end
|
125
147
|
end
|
126
148
|
end
|
@@ -26,6 +26,7 @@ require "mail"
|
|
26
26
|
|
27
27
|
require_relative "../../test"
|
28
28
|
require_relative "../../../lib/lazylead/smtp"
|
29
|
+
require_relative "../../../lib/lazylead/opts"
|
29
30
|
require_relative "../../../lib/lazylead/postman"
|
30
31
|
require_relative "../../../lib/lazylead/task/fix_version"
|
31
32
|
|
@@ -36,17 +37,17 @@ module Lazylead
|
|
36
37
|
Task::FixVersion.new.run(
|
37
38
|
NoAuthJira.new("https://jira.spring.io"),
|
38
39
|
Postman.new,
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
Opts.new(
|
41
|
+
"to" => "lead@company.com",
|
42
|
+
"from" => "ll@company.com",
|
43
|
+
"jql" => "key in ('DATAJDBC-480') and fixVersion is not empty",
|
44
|
+
"allowed" => "tom,mike,bob",
|
45
|
+
"subject" => "FixVersion: How dare you?",
|
46
|
+
"template" => "lib/messages/illegal_fixversion_change.erb"
|
47
|
+
)
|
45
48
|
)
|
46
|
-
|
47
|
-
|
48
|
-
.filter { |m| m.subject.eql? "FixVersion: How dare you?" }
|
49
|
-
.first.body.parts.first.body
|
49
|
+
assert_email "FixVersion: How dare you?",
|
50
|
+
%w[DATAJDBC-480 01-Apr-2020 Minor Mark\ Paluch tom,mike,bob EntityInstantiators]
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
@@ -37,20 +37,20 @@ module Lazylead
|
|
37
37
|
Task::MissingComment.new.run(
|
38
38
|
NoAuthJira.new("https://jira.spring.io"),
|
39
39
|
Postman.new,
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
Opts.new(
|
41
|
+
"to" => "lead@company.com",
|
42
|
+
"addressee" => "Tom",
|
43
|
+
"from" => "ll@company.com",
|
44
|
+
"jql" => "key=DATAJDBC-523",
|
45
|
+
"text" => "ftp.com/demo.avi",
|
46
|
+
"details" => "reference to <code>ftp.com/demo.avi</code>",
|
47
|
+
"subject" => "Expected ftp link is missing",
|
48
|
+
"template" => "lib/messages/missing_comment.erb",
|
49
|
+
"template_details" => "reference to <a href='file://ftp/path'>ftp</a>"
|
50
|
+
)
|
49
51
|
)
|
50
|
-
|
51
|
-
|
52
|
-
.filter { |m| m.subject.eql? "Expected ftp link is missing" }
|
53
|
-
.first.body.parts.first.body
|
52
|
+
assert_email "Expected ftp link is missing",
|
53
|
+
%w[DATAJDBC-523 Major Mark\ Paluch https://github.com/spring-projects/spring-data-jdbc/commit/aadbb667ed1d61139d5ac51a06eb3dd1b39316db#diff-510a5041bb8a0575e97fedf105606b83R130]
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2020 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require_relative "../../test"
|
26
|
+
require_relative "../../../lib/lazylead/system/jira"
|
27
|
+
require_relative "../../../lib/lazylead/task/propagate_down"
|
28
|
+
|
29
|
+
module Lazylead
|
30
|
+
class PropagateDownTest < Lazylead::Test
|
31
|
+
test "propagate fields from parent ticket to sub-tasks" do
|
32
|
+
parent = OpenStruct.new(
|
33
|
+
id: 1,
|
34
|
+
key: "PRJ-1",
|
35
|
+
fields: {
|
36
|
+
subtasks: [{ id: 2 }.stringify_keys],
|
37
|
+
customfield_101: "Tomorrow",
|
38
|
+
customfield_102: "Yesterday"
|
39
|
+
}.stringify_keys
|
40
|
+
)
|
41
|
+
Child = Struct.new(:id, :key, :fields, :comment) do
|
42
|
+
def save(diff)
|
43
|
+
fields.merge! diff[:fields]
|
44
|
+
end
|
45
|
+
|
46
|
+
def comments
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
def build
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
def save!(body)
|
55
|
+
self[:comment] = body[:body]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
child = Child.new(
|
59
|
+
2, "PRJ-2",
|
60
|
+
{
|
61
|
+
subtasks: [],
|
62
|
+
customfield_101: nil,
|
63
|
+
customfield_102: nil
|
64
|
+
}.stringify_keys
|
65
|
+
)
|
66
|
+
Task::PropagateDown.new.run(
|
67
|
+
Fake.new([parent, child]),
|
68
|
+
[],
|
69
|
+
Opts.new(
|
70
|
+
"jql" => "type=Defect and updated>-1h and subtasks without fields",
|
71
|
+
"propagate" => "customfield_101,customfield_102"
|
72
|
+
)
|
73
|
+
)
|
74
|
+
assert_entries(
|
75
|
+
{
|
76
|
+
"customfield_101" => "Tomorrow",
|
77
|
+
"customfield_102" => "Yesterday"
|
78
|
+
},
|
79
|
+
child.fields
|
80
|
+
)
|
81
|
+
assert_words %w[The following fields were propagated from PRJ-1:
|
82
|
+
||Field||Value||
|
83
|
+
|customfield_101|Tomorrow|
|
84
|
+
|customfield_102|Yesterday|],
|
85
|
+
child.comment
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2020 Yurii Dubinka
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"),
|
9
|
+
# to deal in the Software without restriction, including without limitation
|
10
|
+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
11
|
+
# and/or sell copies of the Software, and to permit persons to whom
|
12
|
+
# the Software is furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
22
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
23
|
+
# OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
require_relative "../../test"
|
26
|
+
require_relative "../../../lib/lazylead/smtp"
|
27
|
+
require_relative "../../../lib/lazylead/postman"
|
28
|
+
require_relative "../../../lib/lazylead/task/savepoint"
|
29
|
+
|
30
|
+
module Lazylead
|
31
|
+
class SavepointTest < Lazylead::Test
|
32
|
+
test "send lazylead config as a mail attachment" do
|
33
|
+
Smtp.new.enable
|
34
|
+
ARGV[2] = "--sqlite"
|
35
|
+
ARGV[3] = "readme.md"
|
36
|
+
Task::Savepoint.new.run(
|
37
|
+
[],
|
38
|
+
Postman.new,
|
39
|
+
"from" => "fake@email.com",
|
40
|
+
"subject" => "[LL] Configuration backup",
|
41
|
+
"template" => "lib/messages/savepoint.erb",
|
42
|
+
"to" => "big.boss@example.com"
|
43
|
+
)
|
44
|
+
assert_equal 'text/markdown; filename="readme.md"',
|
45
|
+
Mail::TestMailer.deliveries
|
46
|
+
.filter { |m| m.subject.eql? "[LL] Configuration backup" }
|
47
|
+
.first.attachments.first.header.fields[0]
|
48
|
+
.unparsed_value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|