caperoma 0.1.0 → 4.0.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.
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,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Finish' do
7
+ let!(:account) { create :account }
8
+ let!(:project) { create :project }
9
+ let!(:task) { create :task, project: project, finished_at: nil }
10
+
11
+ it 'finishes started task' do
12
+ expect do
13
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma finish`
14
+ end.to change {
15
+ Task.unfinished.count
16
+ }.by(-1)
17
+ end
18
+ 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 'Fix' 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 fix' do
13
+ expect do
14
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma fix -t "awesome work" -d "some description" -ptid 12345678`
15
+ end.to change {
16
+ Fix.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 fix' do
27
+ expect do
28
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma fix -t "awesome work" -d "some description" -ptid 12345678`
29
+ end.to change {
30
+ Fix.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 fix' do
42
+ expect do
43
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma fix -t "awesome work" -d "some description" -p 12345678 -a 23`
44
+ end.to change {
45
+ Fix.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 = Fix.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,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Meeting' do
7
+ let!(:project) { create :project, jira_project_id: '123' }
8
+
9
+ before { create_capefile('123') }
10
+
11
+ it 'submits a meeting' do
12
+ expect do
13
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma meeting -t "awesome meeting" -d "some description" -a 1`
14
+ end.to change {
15
+ Meeting.where(
16
+ title: 'awesome meeting',
17
+ description: 'some description',
18
+ project_id: project.id
19
+ ).count
20
+ }.by(1)
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Projects' do
7
+ before { Project.destroy_all }
8
+
9
+ it 'displays all projects' do
10
+ project1 = create :project, folder_path: '/MyProj', jira_project_id: '123', pivotal_tracker_project_id: '123456'
11
+ project2 = create :project, folder_path: '/MyProj2', jira_project_id: '321', pivotal_tracker_project_id: '765432'
12
+
13
+ result = `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma projects`
14
+ expect(result).to eq "#{project1.id}) /MyProj (jira_project_id: 123, pivotal_tracker_project_id: 123456)\n#{project2.id}) /MyProj2 (jira_project_id: 321, pivotal_tracker_project_id: 765432)\n"
15
+ # TODO: it should also include pivotal project id
16
+ end
17
+ end
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Report' do
7
+ describe 'Add' do
8
+ it 'flag creates report recipient' do
9
+ expect do
10
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients -a dude@example.com`
11
+ end.to change {
12
+ ReportRecipient.where(email: 'dude@example.com').count
13
+ }.by(1)
14
+ end
15
+
16
+ it 'command creates report recipient' do
17
+ expect do
18
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients add dude@example.com`
19
+ end.to change {
20
+ ReportRecipient.where(email: 'dude@example.com').count
21
+ }.by(1)
22
+ end
23
+
24
+ it 'command creates report recipient' do
25
+ expect do
26
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients --add dude@example.com`
27
+ end.to change {
28
+ ReportRecipient.where(email: 'dude@example.com').count
29
+ }.by(1)
30
+ end
31
+
32
+ it 'flag creates report recipient' do
33
+ expect do
34
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients -c dude@example.com`
35
+ end.to change {
36
+ ReportRecipient.where(email: 'dude@example.com').count
37
+ }.by(1)
38
+ end
39
+
40
+ it 'command creates report recipient' do
41
+ expect do
42
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients create dude@example.com`
43
+ end.to change {
44
+ ReportRecipient.where(email: 'dude@example.com').count
45
+ }.by(1)
46
+ end
47
+
48
+ it 'command creates report recipient' do
49
+ expect do
50
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients --create dude@example.com`
51
+ end.to change {
52
+ ReportRecipient.where(email: 'dude@example.com').count
53
+ }.by(1)
54
+ end
55
+ end
56
+
57
+ describe 'Destroy' do
58
+ let!(:recipient) { create :report_recipient, email: 'dude@example.com' }
59
+
60
+ it 'flag removes recipient' do
61
+ expect do
62
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients -r dude@example.com`
63
+ end.to change {
64
+ ReportRecipient.where(email: 'dude@example.com').count
65
+ }.by(-1)
66
+ end
67
+
68
+ it 'command removes recipient' do
69
+ expect do
70
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients remove dude@example.com`
71
+ end.to change {
72
+ ReportRecipient.where(email: 'dude@example.com').count
73
+ }.by(-1)
74
+ end
75
+
76
+ it 'command removes recipient' do
77
+ expect do
78
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients --remove dude@example.com`
79
+ end.to change {
80
+ ReportRecipient.where(email: 'dude@example.com').count
81
+ }.by(-1)
82
+ end
83
+
84
+ it 'flag removes recipient' do
85
+ expect do
86
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients -d dude@example.com`
87
+ end.to change {
88
+ ReportRecipient.where(email: 'dude@example.com').count
89
+ }.by(-1)
90
+ end
91
+
92
+ it 'command removes recipient' do
93
+ expect do
94
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients delete dude@example.com`
95
+ end.to change {
96
+ ReportRecipient.where(email: 'dude@example.com').count
97
+ }.by(-1)
98
+ end
99
+
100
+ it 'command removes recipient' do
101
+ expect do
102
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients --delete dude@example.com`
103
+ end.to change {
104
+ ReportRecipient.where(email: 'dude@example.com').count
105
+ }.by(-1)
106
+ end
107
+ end
108
+
109
+ describe 'List' do
110
+ let!(:recipient) { create :report_recipient, email: 'dude@example.com' }
111
+
112
+ it 'removes recipient' do
113
+ result = `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma recipients`
114
+ expect(result).to match /dude/
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Report' do
7
+ describe 'Daily Report' do
8
+ it 'creates daily report' do
9
+ expect do
10
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma report daily`
11
+ end.to change {
12
+ DailyReport.count
13
+ }.by(1)
14
+ end
15
+
16
+ it 'creates daily report' do
17
+ expect do
18
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma report -d`
19
+ end.to change {
20
+ DailyReport.count
21
+ }.by(1)
22
+ end
23
+ end
24
+
25
+ describe 'Three Day Report' do
26
+ it 'creates three day report' do
27
+ expect do
28
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma report three_day`
29
+ end.to change {
30
+ ThreeDayReport.count
31
+ }.by(1)
32
+ end
33
+
34
+ it 'creates three day report' do
35
+ expect do
36
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma report -t`
37
+ end.to change {
38
+ ThreeDayReport.count
39
+ }.by(1)
40
+ end
41
+ end
42
+
43
+ describe 'Weekly Report' do
44
+ it 'creates weekly report' do
45
+ expect do
46
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma report weekly`
47
+ end.to change {
48
+ RetrospectiveReport.count
49
+ }.by(1)
50
+ end
51
+
52
+ it 'creates weekly report' do
53
+ expect do
54
+ `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma report -w`
55
+ end.to change {
56
+ RetrospectiveReport.count
57
+ }.by(1)
58
+ end
59
+ end
60
+
61
+ describe 'auto' do
62
+ xit 'on'
63
+ xit 'off'
64
+ end
65
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'Status' do
7
+
8
+ context "not working on anything" do
9
+ it "should say I am not working" do
10
+ result = `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma status`
11
+ expect(result).to eq "You are not working on anything now.\n"
12
+ end
13
+ end
14
+
15
+ context "working on a feature", :unstub_time_now do
16
+ let!(:account) { create :account }
17
+ let!(:project) { create :project }
18
+ let!(:task) { create :feature, project: project, title: 'my title', jira_key: 'PBO-2', pivotal_id: 12345678, finished_at: nil }
19
+
20
+ before { task.update_column :started_at, 2.hours.ago }
21
+ before { task.update_column :parent_branch, 'master' }
22
+
23
+ it "should say I am not working" do
24
+ result = `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma status`
25
+ expect(result).to match /Type: Feature/
26
+ expect(result).to match /Title: my title/
27
+ expect(result).to match /Jira ID: PBO-2/
28
+ expect(result).to match /Pivotal ID: 12345678/
29
+ expect(result).to match /Time spent at the moment: 2h/
30
+ expect(result).to match /Pull request will be sent to this branch: master/
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+ ENV['spec_type'] = 'feature'
5
+
6
+ describe 'version' do
7
+ it 'outputs the current version' do
8
+ result = `CAPEROMA_INTEGRATION_TEST=true ruby -I./lib bin/caperoma -v`
9
+ expect(result).to start_with '4'
10
+ end
11
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ RSpec.describe Account, type: :model do
6
+ describe 'validations' do
7
+ it { expect(subject).to validate_presence_of(:email) }
8
+ it { expect(subject).to validate_presence_of(:password) }
9
+ # TODO: validate username for jira only (use STI)
10
+ it { expect(subject).to validate_presence_of(:type) }
11
+ it { expect(subject).to validate_inclusion_of(:type).in_array(%w[--jira --gmail --caperoma --pivotal --git]) }
12
+ end
13
+
14
+ describe 'class methods' do
15
+ let!(:caperoma) { create :account, type: '--caperoma' }
16
+ let!(:gmail) { create :account, type: '--gmail' }
17
+ let!(:jira) { create :account, type: '--jira' }
18
+ let!(:pivotal) { create :account, type: '--pivotal' }
19
+ let!(:git) { create :account, type: '--git' }
20
+
21
+ specify '::caperoma' do
22
+ expect(Account.caperoma).to eq caperoma
23
+ end
24
+
25
+ specify '::gmail' do
26
+ expect(Account.gmail).to eq gmail
27
+ end
28
+
29
+ specify '::jira' do
30
+ expect(Account.jira).to eq jira
31
+ end
32
+
33
+ specify '::pivotal' do
34
+ expect(Account.pivotal).to eq pivotal
35
+ end
36
+
37
+ specify '::git' do
38
+ expect(Account.git).to eq git
39
+ end
40
+ end
41
+
42
+ describe 'observers' do
43
+ it 'should overwrite accounts of same type' do
44
+ create :account, type: '--jira'
45
+ create :account, type: '--jira', email: 'new-email@example.com'
46
+
47
+ expect(Account.count).to eq 1
48
+ expect(Account.first.email).to eq 'new-email@example.com'
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ RSpec.describe Branch, type: :model do
6
+ it { expect(subject).to belong_to :project }
7
+ it { expect(subject).to have_many :tasks }
8
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ RSpec.describe Bug, type: :model do
6
+ describe 'inheritence' do
7
+ it { expect(subject).to be_a_kind_of TaskWithSeparateBranch }
8
+ end
9
+
10
+ describe 'private methods' do
11
+ describe '#issue_type' do
12
+ let!(:project) { create :project, bug_jira_task_id: '1234' }
13
+
14
+ let!(:task) { create :bug, project: project }
15
+
16
+ it { expect(task.send(:issue_type)).to eq '1234' }
17
+ end
18
+
19
+ describe '#story_type' do
20
+ let!(:task) { create :bug }
21
+
22
+ it { expect(task.send(:story_type)).to eq 'bug' }
23
+ end
24
+
25
+ describe '#this_is_a_type_a_user_wants_to_create' do
26
+ let!(:project) { create :project, create_bugs_in_pivotal: true }
27
+
28
+ let!(:task) { build :bug, project: project }
29
+
30
+ it { expect(task.send(:this_is_a_type_a_user_wants_to_create?)).to be_truthy }
31
+ end
32
+ end
33
+ end