caperoma 0.1.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -0
  3. data/Capefile +48 -0
  4. data/Capefile.template +48 -0
  5. data/Capefile.test +20 -0
  6. data/Gemfile +25 -10
  7. data/Gemfile.lock +196 -77
  8. data/HELP +321 -0
  9. data/README.md +528 -0
  10. data/Rakefile +73 -18
  11. data/VERSION +1 -1
  12. data/bin/caperoma +47 -11
  13. data/caperoma.gemspec +144 -45
  14. data/config/crontab +10 -0
  15. data/config/schedule.rb +21 -0
  16. data/lib/caperoma.rb +409 -9
  17. data/lib/caperoma/models/account.rb +47 -0
  18. data/lib/caperoma/models/application_record.rb +5 -0
  19. data/lib/caperoma/models/branch.rb +6 -0
  20. data/lib/caperoma/models/project.rb +14 -0
  21. data/lib/caperoma/models/property.rb +5 -0
  22. data/lib/caperoma/models/report.rb +177 -0
  23. data/lib/caperoma/models/report_recipient.rb +6 -0
  24. data/lib/caperoma/models/reports/daily_report.rb +23 -0
  25. data/lib/caperoma/models/reports/retrospective_report.rb +19 -0
  26. data/lib/caperoma/models/reports/three_day_report.rb +19 -0
  27. data/lib/caperoma/models/task.rb +368 -0
  28. data/lib/caperoma/models/tasks/bug.rb +36 -0
  29. data/lib/caperoma/models/tasks/chore.rb +40 -0
  30. data/lib/caperoma/models/tasks/feature.rb +27 -0
  31. data/lib/caperoma/models/tasks/fix.rb +56 -0
  32. data/lib/caperoma/models/tasks/meeting.rb +40 -0
  33. data/lib/caperoma/models/tasks/modules/git.rb +65 -0
  34. data/lib/caperoma/models/tasks/task_with_commit.rb +40 -0
  35. data/lib/caperoma/models/tasks/task_with_separate_branch.rb +42 -0
  36. data/lib/caperoma/services/airbrake_email_processor.rb +47 -0
  37. data/lib/caperoma/services/pivotal_fetcher.rb +108 -0
  38. data/lib/caperoma/version.rb +9 -0
  39. data/spec/caperoma_spec.rb +3 -21
  40. data/spec/factories/accounts.rb +10 -0
  41. data/spec/factories/branches.rb +9 -0
  42. data/spec/factories/projects.rb +8 -0
  43. data/spec/factories/report_recipients.rb +7 -0
  44. data/spec/factories/reports.rb +16 -0
  45. data/spec/factories/tasks.rb +37 -0
  46. data/spec/features/bug_spec.rb +60 -0
  47. data/spec/features/chore_spec.rb +60 -0
  48. data/spec/features/command_unknown_spec.rb +14 -0
  49. data/spec/features/config_spec.rb +161 -0
  50. data/spec/features/feature_spec.rb +60 -0
  51. data/spec/features/finish_spec.rb +18 -0
  52. data/spec/features/fix_spec.rb +60 -0
  53. data/spec/features/meeting_spec.rb +22 -0
  54. data/spec/features/projects_spec.rb +17 -0
  55. data/spec/features/report_recipientss_spec.rb +117 -0
  56. data/spec/features/reports_spec.rb +65 -0
  57. data/spec/features/status_spec.rb +33 -0
  58. data/spec/features/version_spec.rb +11 -0
  59. data/spec/models/account_spec.rb +51 -0
  60. data/spec/models/branch_spec.rb +8 -0
  61. data/spec/models/bug_spec.rb +33 -0
  62. data/spec/models/chore_spec.rb +33 -0
  63. data/spec/models/daily_report_spec.rb +38 -0
  64. data/spec/models/feature_spec.rb +33 -0
  65. data/spec/models/fix_spec.rb +55 -0
  66. data/spec/models/meeting_spec.rb +33 -0
  67. data/spec/models/project_spec.rb +11 -0
  68. data/spec/models/report_recipient_spec.rb +22 -0
  69. data/spec/models/report_spec.rb +16 -0
  70. data/spec/models/retrospective_report_spec.rb +38 -0
  71. data/spec/models/task_spec.rb +613 -0
  72. data/spec/models/task_with_commit_spec.rb +105 -0
  73. data/spec/models/task_with_separate_branch_spec.rb +97 -0
  74. data/spec/models/three_day_report_spec.rb +49 -0
  75. data/spec/spec_helper.rb +26 -16
  76. data/spec/support/capefile_generator.rb +36 -0
  77. data/spec/support/database_cleaner.rb +21 -0
  78. data/spec/support/stubs.rb +178 -9
  79. metadata +283 -42
  80. data/.document +0 -5
  81. data/README.rdoc +0 -26
  82. data/lib/caperoma/credentials.rb +0 -13
  83. data/lib/caperoma/jira_client.rb +0 -57
  84. data/spec/caperoma/credentials_spec.rb +0 -25
  85. data/spec/caperoma/jira_spec.rb +0 -35
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Caperoma
4
+ module Version
5
+ MAJOR, MINOR, PATCH = File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).split('.')
6
+
7
+ STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
@@ -1,25 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
4
 
3
5
  describe 'Caperoma' do
4
- describe '#chore' do
5
- it 'triggers chore creation' do
6
- expect_any_instance_of(JiraClient).to receive(:create_chore).with([1, 2])
7
- Caperoma.chore([1, 2])
8
- end
9
- end
10
-
11
- describe '#config' do
12
- it 'saves jira email/password' do
13
- expect(Credentials).to receive(:write).with('args')
14
-
15
- Caperoma.config('args')
16
- end
17
- end
18
-
19
- describe '#test' do
20
- it 'outputs msg' do
21
- expect(STDOUT).to receive(:puts).with('works')
22
- Caperoma.test
23
- end
24
- end
6
+ pending 'all this is tested using feature tests for now'
25
7
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :account do
5
+ sequence(:email) { |n| "email#{n}@example.com" }
6
+ sequence(:password) { |n| "password#{n}" }
7
+ sequence(:username) { |n| "username#{n}" }
8
+ type '--jira'
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :branch do
5
+ project
6
+
7
+ sequence(:name) { |n| "ruc-#{n}-branch" }
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :project do
5
+ sequence(:name) { |n| "Refactoring some thunk of code ##{n}" }
6
+ sequence(:jira_project_id) { |n| 123_456 + n }
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :report_recipient do
5
+ email 'dude@example.com'
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :report do
5
+ content 'did this and that'
6
+ end
7
+
8
+ factory :daily_report, parent: :report, class: 'DailyReport' do
9
+ end
10
+
11
+ factory :three_day_report, parent: :report, class: 'ThreeDayReport' do
12
+ end
13
+
14
+ factory :retrospective_report, parent: :report, class: 'RetrospectiveReport' do
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :task do
5
+ project
6
+
7
+ sequence(:title) { |n| "Refactoring some thunk of code ##{n}" }
8
+ sequence(:description) { |n| "This was a very nice task, solved it #{n}" }
9
+ sequence(:jira_key) { |n| "RUC-#{n}" }
10
+ sequence(:url) { |n| "http://www.my_jira_site.com/tasks/RUC-#{n}" }
11
+
12
+ started_at Time.now
13
+ finished_at Time.now
14
+ end
15
+
16
+ factory :chore, parent: :task, class: 'Chore' do
17
+ end
18
+
19
+ factory :meeting, parent: :task, class: 'Meeting' do
20
+ end
21
+
22
+ factory :task_with_commit, parent: :task, class: 'TaskWithCommit' do
23
+ branch
24
+ end
25
+
26
+ factory :fix, parent: :task_with_commit, class: 'Fix' do
27
+ end
28
+
29
+ factory :task_with_separate_branch, parent: :task_with_commit, class: 'TaskWithSeparateBranch' do
30
+ end
31
+
32
+ factory :feature, parent: :task_with_separate_branch, class: 'Feature' do
33
+ end
34
+
35
+ factory :bug, parent: :task_with_separate_branch, class: 'Bug' do
36
+ end
37
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Bug' do
7
+ let!(:project) { create :project, jira_project_id: '123' }
8
+
9
+ before { create_capefile('123') }
10
+
11
+ context 'pivotal id blank' do
12
+ it 'submits a bug' do
13
+ expect do
14
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma bug -t "awesome bug" -d "some description" `
15
+ end.to change {
16
+ Bug.where(
17
+ title: 'awesome bug',
18
+ description: 'some description',
19
+ project_id: project.id
20
+ ).count
21
+ }.by(1)
22
+ end
23
+ end
24
+
25
+ context 'pivotal id present' do
26
+ it 'submits a bug' do
27
+ expect do
28
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma bug --title "awesome bug" --description "some description" -ptid 12345678`
29
+ end.to change {
30
+ Bug.where(
31
+ title: 'awesome bug',
32
+ description: 'some description',
33
+ project_id: project.id,
34
+ pivotal_id: '12345678'
35
+ ).count
36
+ }.by(1)
37
+ end
38
+ end
39
+
40
+ context 'pivotal id and additional_time present', :unstub_time_now do
41
+ it 'submits a bug' do
42
+ expect do
43
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma bug -t "awesome bug" -d "some description" -ptid 12345678 -a 23`
44
+ end.to change {
45
+ Bug.where(
46
+ title: 'awesome bug',
47
+ description: 'some description',
48
+ project_id: project.id,
49
+ pivotal_id: '12345678'
50
+ ).count
51
+ }.by(1)
52
+
53
+ time = Time.now
54
+ created = Bug.first.started_at
55
+ time_difference = TimeDifference.between(time, created).in_minutes.to_i
56
+
57
+ expect(time_difference).to eq 23
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Chore' do
7
+ let!(:project) { create :project, jira_project_id: '123' }
8
+
9
+ before { create_capefile('123') }
10
+
11
+ context 'pivotal id blank' do
12
+ it 'submits a chore' do
13
+ expect do
14
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma chore -t "awesome work" -d "some description"`
15
+ end.to change {
16
+ Chore.where(
17
+ title: 'awesome work',
18
+ description: 'some description',
19
+ project_id: project.id
20
+ ).count
21
+ }.by(1)
22
+ end
23
+ end
24
+
25
+ context 'pivotal id present' do
26
+ it 'submits a chore' do
27
+ expect do
28
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma chore -t "awesome work" -d "some description" -ptid 12345678`
29
+ end.to change {
30
+ Chore.where(
31
+ title: 'awesome work',
32
+ description: 'some description',
33
+ project_id: project.id,
34
+ pivotal_id: '12345678'
35
+ ).count
36
+ }.by(1)
37
+ end
38
+ end
39
+
40
+ context 'pivotal id present, additional_time present', :unstub_time_now do
41
+ it 'submits a chore' do
42
+ expect do
43
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma chore --title "awesome work" --description "some description" --pivotal_task_id 12345678 --additional_time 23`
44
+ end.to change {
45
+ Chore.where(
46
+ title: 'awesome work',
47
+ description: 'some description',
48
+ project_id: project.id,
49
+ pivotal_id: '12345678'
50
+ ).count
51
+ }.by(1)
52
+
53
+ time = Time.now
54
+ created = Chore.first.started_at
55
+ time_difference = TimeDifference.between(time, created).in_minutes
56
+
57
+ expect(time_difference).to eq 23
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Command unknown' do
7
+ let!(:project) { create :project }
8
+ let!(:current_branch) { create :branch, project: project }
9
+
10
+ it 'submits a chore' do
11
+ result = `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma boogie woogie`
12
+ expect(result).to match /Available commands/
13
+ end
14
+ end
@@ -0,0 +1,161 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Config' do
7
+ describe 'adding accounts' do
8
+ it 'saves Jira account using -a flag' do
9
+ expect do
10
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts -a --jira "email@example.com" "password123"`
11
+ end.to change {
12
+ Account.where(
13
+ email: 'email@example.com',
14
+ password: 'password123',
15
+ type: '--jira'
16
+ ).count
17
+ }.by(1)
18
+ end
19
+
20
+ it 'saves Jira account using add flag' do
21
+ expect do
22
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts add --jira "email@example.com" "password123"`
23
+ end.to change {
24
+ Account.where(
25
+ email: 'email@example.com',
26
+ password: 'password123',
27
+ type: '--jira'
28
+ ).count
29
+ }.by(1)
30
+ end
31
+
32
+ it 'saves Jira account using --add flag' do
33
+ expect do
34
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts --add --jira "email@example.com" "password123"`
35
+ end.to change {
36
+ Account.where(
37
+ email: 'email@example.com',
38
+ password: 'password123',
39
+ type: '--jira'
40
+ ).count
41
+ }.by(1)
42
+ end
43
+
44
+ it 'saves Jira account using -c flag' do
45
+ expect do
46
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts -c --jira "email@example.com" "password123"`
47
+ end.to change {
48
+ Account.where(
49
+ email: 'email@example.com',
50
+ password: 'password123',
51
+ type: '--jira'
52
+ ).count
53
+ }.by(1)
54
+ end
55
+
56
+ it 'saves Jira account using create flag' do
57
+ expect do
58
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts create --jira "email@example.com" "password123"`
59
+ end.to change {
60
+ Account.where(
61
+ email: 'email@example.com',
62
+ password: 'password123',
63
+ type: '--jira'
64
+ ).count
65
+ }.by(1)
66
+ end
67
+
68
+ it 'saves Jira account using --create flag' do
69
+ expect do
70
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts --create --jira "email@example.com" "password123"`
71
+ end.to change {
72
+ Account.where(
73
+ email: 'email@example.com',
74
+ password: 'password123',
75
+ type: '--jira'
76
+ ).count
77
+ }.by(1)
78
+ end
79
+ end
80
+
81
+ describe 'removing accounts' do
82
+ let!(:account) { create :account, type: '--jira' }
83
+
84
+ it 'removes Jira account using -r flag' do
85
+ expect do
86
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts -r --jira`
87
+ end.to change {
88
+ Account.where(
89
+ type: '--jira'
90
+ ).count
91
+ }.by(-1)
92
+ end
93
+
94
+ it 'saves Jira account using remove command' do
95
+ expect do
96
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts remove --jira`
97
+ end.to change {
98
+ Account.where(
99
+ type: '--jira'
100
+ ).count
101
+ }.by(-1)
102
+ end
103
+
104
+ it 'saves Jira account using --remove command' do
105
+ expect do
106
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts --remove --jira`
107
+ end.to change {
108
+ Account.where(
109
+ type: '--jira'
110
+ ).count
111
+ }.by(-1)
112
+ end
113
+
114
+ it 'removes Jira account using -d flag' do
115
+ expect do
116
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts -d --jira`
117
+ end.to change {
118
+ Account.where(
119
+ type: '--jira'
120
+ ).count
121
+ }.by(-1)
122
+ end
123
+
124
+ it 'saves Jira account using delete command' do
125
+ expect do
126
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts delete --jira`
127
+ end.to change {
128
+ Account.where(
129
+ type: '--jira'
130
+ ).count
131
+ }.by(-1)
132
+ end
133
+
134
+ it 'saves Jira account using --delete command' do
135
+ expect do
136
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts --delete --jira`
137
+ end.to change {
138
+ Account.where(
139
+ type: '--jira'
140
+ ).count
141
+ }.by(-1)
142
+ end
143
+ end
144
+
145
+ describe 'listing' do
146
+ let!(:account1) { create :account, type: '--jira', email: 'one@gmail.com' }
147
+ let!(:account2) { create :account, type: '--git', email: 'two@gmail.com' }
148
+ let!(:account3) { create :account, type: '--pivotal', email: 'three@gmail.com' }
149
+ let!(:account4) { create :account, type: '--gmail', email: 'four@gmail.com' }
150
+ let!(:account5) { create :account, type: '--caperoma', email: 'five@gmail.com' }
151
+
152
+ it 'should list the accounts' do
153
+ result = `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma accounts`
154
+ expect(result).to match /Jira: one@gmail.com/
155
+ expect(result).to match /Git: two@gmail.com/
156
+ expect(result).to match /Pivotal: three@gmail.com/
157
+ expect(result).to match /Gmail: four@gmail.com/
158
+ expect(result).to match /Caperoma: five@gmail.com/
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Feature' do
7
+ let!(:project) { create :project, jira_project_id: '123' }
8
+
9
+ before { create_capefile('123') }
10
+
11
+ context 'pivotal id blank' do
12
+ it 'submits a feature' do
13
+ expect do
14
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma feature -t "awesome feature" --description "some description" `
15
+ end.to change {
16
+ Feature.where(
17
+ title: 'awesome feature',
18
+ description: 'some description',
19
+ project_id: project.id
20
+ ).count
21
+ }.by(1)
22
+ end
23
+ end
24
+
25
+ context 'pivotal id present' do
26
+ it 'submits a feature' do
27
+ expect do
28
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma feature --title "awesome feature" -d "some description" --pivotal_task_id 12345678`
29
+ end.to change {
30
+ Feature.where(
31
+ title: 'awesome feature',
32
+ description: 'some description',
33
+ project_id: project.id,
34
+ pivotal_id: '12345678'
35
+ ).count
36
+ }.by(1)
37
+ end
38
+ end
39
+
40
+ context 'pivotal id present, additional_time present', :unstub_time_now do
41
+ it 'submits a feature' do
42
+ expect do
43
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma feature -t "awesome feature" --description "some description" -ptid 12345678 --additional_time 23`
44
+ end.to change {
45
+ Feature.where(
46
+ title: 'awesome feature',
47
+ description: 'some description',
48
+ project_id: project.id,
49
+ pivotal_id: '12345678'
50
+ ).count
51
+ }.by(1)
52
+
53
+ time = Time.now
54
+ created = Feature.first.started_at
55
+ time_difference = TimeDifference.between(time, created).in_minutes.to_i
56
+
57
+ expect(time_difference).to eq 23
58
+ end
59
+ end
60
+ end