shipit-engine 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -106
  3. data/app/assets/images/timedout.svg +14 -0
  4. data/app/assets/stylesheets/_pages/_commits.scss +11 -2
  5. data/app/controllers/shipit/stacks_controller.rb +1 -7
  6. data/app/controllers/shipit/webhooks_controller.rb +102 -66
  7. data/app/helpers/shipit/github_url_helper.rb +2 -2
  8. data/app/helpers/shipit/shipit_helper.rb +3 -31
  9. data/app/jobs/shipit/destroy_job.rb +9 -0
  10. data/app/jobs/shipit/github_sync_job.rb +1 -1
  11. data/app/jobs/shipit/setup_github_hook_job.rb +1 -3
  12. data/app/models/shipit/anonymous_user.rb +4 -1
  13. data/app/models/shipit/commit.rb +8 -8
  14. data/app/models/shipit/commit_deployment.rb +3 -3
  15. data/app/models/shipit/commit_deployment_status.rb +2 -2
  16. data/app/models/shipit/deploy.rb +3 -3
  17. data/app/models/shipit/deploy_spec/file_system.rb +3 -3
  18. data/app/models/shipit/deploy_spec/kubernetes_discovery.rb +10 -2
  19. data/app/models/shipit/github_hook.rb +2 -99
  20. data/app/models/shipit/github_status.rb +1 -1
  21. data/app/models/shipit/hook.rb +1 -1
  22. data/app/models/shipit/pull_request.rb +10 -10
  23. data/app/models/shipit/rollback.rb +1 -1
  24. data/app/models/shipit/stack.rb +27 -26
  25. data/app/models/shipit/task.rb +2 -2
  26. data/app/models/shipit/team.rb +4 -17
  27. data/app/models/shipit/user.rb +3 -3
  28. data/app/serializers/shipit/task_serializer.rb +2 -2
  29. data/app/serializers/shipit/user_serializer.rb +1 -1
  30. data/app/views/shipit/missing_settings.html.erb +5 -36
  31. data/app/views/shipit/stacks/new.html.erb +1 -1
  32. data/app/views/shipit/stacks/settings.html.erb +0 -4
  33. data/config/routes.rb +3 -13
  34. data/config/secrets.development.shopify.yml +10 -15
  35. data/config/secrets.development.yml +1 -1
  36. data/db/migrate/20180417130436_remove_all_github_hooks.rb +11 -0
  37. data/lib/shipit.rb +13 -56
  38. data/lib/shipit/command.rb +1 -1
  39. data/lib/shipit/engine.rb +2 -8
  40. data/lib/shipit/github_app.rb +122 -0
  41. data/lib/shipit/octokit_bot_users_patch.rb +25 -0
  42. data/lib/shipit/octokit_iterator.rb +2 -2
  43. data/lib/shipit/version.rb +1 -1
  44. data/lib/tasks/teams.rake +8 -24
  45. data/test/controllers/stacks_controller_test.rb +3 -29
  46. data/test/controllers/webhooks_controller_test.rb +29 -46
  47. data/test/dummy/config/secrets.yml +40 -10
  48. data/test/dummy/db/development.sqlite3 +0 -0
  49. data/test/dummy/db/schema.rb +1 -1
  50. data/test/dummy/db/seeds.rb +0 -1
  51. data/test/dummy/db/test.sqlite3 +0 -0
  52. data/test/fixtures/payloads/push_master.json +7 -6
  53. data/test/fixtures/payloads/push_not_master.json +7 -6
  54. data/test/fixtures/shipit/users.yml +2 -2
  55. data/test/helpers/hooks_helper.rb +1 -1
  56. data/test/helpers/payloads_helper.rb +1 -2
  57. data/test/jobs/destroy_stack_job_test.rb +1 -1
  58. data/test/models/commits_test.rb +5 -5
  59. data/test/models/deploy_spec_test.rb +17 -5
  60. data/test/models/github_hook_test.rb +1 -40
  61. data/test/models/pull_request_test.rb +11 -11
  62. data/test/models/stacks_test.rb +4 -10
  63. data/test/models/team_test.rb +3 -3
  64. data/test/models/users_test.rb +7 -7
  65. data/test/test_helper.rb +1 -1
  66. data/test/unit/github_app_test.rb +44 -0
  67. data/test/unit/shipit_test.rb +2 -49
  68. metadata +9 -3
  69. data/lib/tasks/webhook.rake +0 -6
@@ -4,14 +4,44 @@ test:
4
4
  secret_key_base: s3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3t
5
5
  host: shipit.com
6
6
  github_api:
7
- access_token: t0kEn
8
- # login:
9
- # password:
10
- # api_endpoint:
11
- github_oauth:
12
- id: 1d
13
- secret: s3cr37
14
- # teams:
15
- # -
16
- # -
7
+ token: t0k3n
8
+ github:
9
+ domain: # defaults to github.com
10
+ app_id: 42
11
+ installation_id: 43
12
+ bot_login: "shipit[bot]"
13
+ webhook_secret: # nil
14
+ # Randomly generated
15
+ private_key: |
16
+ -----BEGIN RSA PRIVATE KEY-----
17
+ MIIEpAIBAAKCAQEA7iUQC2uUq/gtQg0gxtyaccuicYgmq1LUr1mOWbmwM1Cv63+S
18
+ 73qo8h87FX+YyclY5fZF6SMXIys02JOkImGgbnvEOLcHnImCYrWs03msOzEIO/pG
19
+ M0YedAPtQ2MEiLIu4y8htosVxeqfEOPiq9kQgFxNKyETzjdIA9q1md8sofuJUmPv
20
+ ibacW1PecuAMnn+P8qf0XIDp7uh6noB751KvhCaCNTAPtVE9NZ18OmNG9GOyX/pu
21
+ pQHIrPgTpTG6KlAe3r6LWvemzwsMtuRGU+K+KhK9dFIlSE+v9rA32KScO8efOh6s
22
+ Gu3rWorV4iDu14U62rzEfdzzc63YL94sUbZxbwIDAQABAoIBADLJ8r8MxZtbhYN1
23
+ u0zOFZ45WL6v09dsBfITvnlCUeLPzYUDIzoxxcBFittN6C744x3ARS6wjimw+EdM
24
+ TZALlCSb/sA9wMDQzt7wchhz9Zh2H5RzDu+2f54sjDh38KqancdT8PO2fAFGxX/b
25
+ qicOVyeZB9gv6MJtJc20olBbuXAeBNfcDABF9oxF+0i+Ssg7B4VXiqgcjtGbr/Og
26
+ qRll7AqyTArVx2xEcVfZxeZ4zGnigzcJq4te7yYpxzwk+RxblkPh54Yt4WxZ+8DI
27
+ Rsn3r6ajlpwzpwvsJFU2Txq7xBTzGQMFmy/Pnjk83kP2cogxB2+tRyjITGqTwD8b
28
+ gg9PFCkCgYEA+7u8A0l0Cz6p0SI6c7ftVePVRiIhpawWN7og/wEmI6zUjm/3rA+R
29
+ hrhaVKuOD8QF/HdDsqTck5gjGAjTmJz6r33/cl1Tz+pr62znsrB4r0yMKvQbKN81
30
+ WGaWOsi2+ZXqLNv5h5wpUF0MTKlXHeKnwP5kuEvGwVn6WURFCh6PhLMCgYEA8i5e
31
+ JjulJVGyd5HuoY3xyO7E6DjidsqRnVRq+hYpORjnHvTmSwe4+tH4ha2p9Kv2Y6k3
32
+ C1NYY/fSMQoYCCRaYyJleI+la/9tsZqAmtms4ZB8KhFmPHf9fW75i6G0xKWyZ8K+
33
+ E2Ft/UaEiM282593cguV6+Kt5uExnyPxLLK4FlUCgYEAwRJ/JGI8/7bjFkTTYheq
34
+ j5q75BufhOrU6471acAe2XPgXxLfefdC3Xodxh0CS3NESBvNL4Ikr4sbN37lk4Kq
35
+ /th7iOKtuqUIeru/hZy2I3VpeDRbdGCmEJQ2GwYA2LKztg5Nd0Y9paaIHXAwIfrK
36
+ QUqcQ4HTAk8ZpUeoUBeaaeMCgYANLmbjb9WiPVsYVPIHCwHA7PX8qbPxwT7BsGmO
37
+ KQyfVfKmZa/vH4F67Vi4deZNMdrcO8aKMEQcVM2065a5QrlEsgeR00eupB1lUEJ1
38
+ qylUsZeAdqf43JMIc7TTW77KATa/nQLZbTEeWus1wvTngztuEqFbUGAks9cOkVc8
39
+ FpIcbQKBgQDVIL8gPLmn0f+4oLF8MBC+oxtKpz14X5iJ1saGFkzW5I+nIEskpS0S
40
+ qtirnTCnJFGdCrFwctnxiuiCmyGwpBYdjIfHyvYAHnqAtMnESzCUyeSFZiquVW5W
41
+ MvbMmDPoV27XOHU9kIq6NXtfrkpufiyo6/VEYWozXalxKLNuqLYfPQ==
42
+ -----END RSA PRIVATE KEY-----
43
+ oauth:
44
+ id: Iv1.bf2c2c45b449bfd9
45
+ secret: ef694cd6e45223075d78d138ef014049052665f1
46
+ teams:
17
47
  redis_url: "redis://127.0.0.1:6379/7"
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20180202220850) do
13
+ ActiveRecord::Schema.define(version: 20180417130436) do
14
14
 
15
15
  create_table "api_clients", force: :cascade do |t|
16
16
  t.text "permissions", limit: 65535
@@ -6,7 +6,6 @@ FakeWeb.register_uri(:post, %r{https://example\.com/}, status: %w(200 OK))
6
6
 
7
7
  # Cheap hack to allow rake db:seed to work
8
8
  module Shipit
9
- Stack.send(:define_method, :setup_hooks) {}
10
9
  Stack.send(:define_method, :sync_github) {}
11
10
  Commit.send(:define_method, :fetch_stats!) {}
12
11
  Commit.send(:define_method, :refresh_statuses!) {}
Binary file
@@ -5,14 +5,14 @@
5
5
  "created": false,
6
6
  "deleted": false,
7
7
  "forced": false,
8
- "compare": "https://github.com/byroot/junk/compare/16c259864de2...79d29e99cb83",
8
+ "compare": "https://github.com/Shopify/shipit-engine/compare/16c259864de2...79d29e99cb83",
9
9
  "commits": [
10
10
  {
11
11
  "id": "79d29e99cb83e0ba16c9e30c502a60995e711e5f",
12
12
  "distinct": true,
13
13
  "message": "modif",
14
14
  "timestamp": "2014-02-28T10:27:42-08:00",
15
- "url": "https://github.com/byroot/junk/commit/79d29e99cb83e0ba16c9e30c502a60995e711e5f",
15
+ "url": "https://github.com/Shopify/shipit-engine/commit/79d29e99cb83e0ba16c9e30c502a60995e711e5f",
16
16
  "author": {
17
17
  "name": "Guillaume Malette",
18
18
  "email": "gmalette@gmail.com",
@@ -35,7 +35,7 @@
35
35
  "distinct": true,
36
36
  "message": "modif",
37
37
  "timestamp": "2014-02-28T10:27:42-08:00",
38
- "url": "https://github.com/byroot/junk/commit/79d29e99cb83e0ba16c9e30c502a60995e711e5f",
38
+ "url": "https://github.com/Shopify/shipit-engine/commit/79d29e99cb83e0ba16c9e30c502a60995e711e5f",
39
39
  "author": {
40
40
  "name": "Guillaume Malette",
41
41
  "email": "gmalette@gmail.com",
@@ -54,8 +54,9 @@
54
54
  },
55
55
  "repository": {
56
56
  "id": 17266426,
57
- "name": "junk",
58
- "url": "https://github.com/byroot/junk",
57
+ "name": "shipit-engine",
58
+ "full_name": "Shopify/shipit-engine",
59
+ "url": "https://github.com/Shopify/shipit-engine",
59
60
  "description": "Pure test repo, look elsewhere please.",
60
61
  "watchers": 0,
61
62
  "stargazers": 0,
@@ -63,7 +64,7 @@
63
64
  "fork": false,
64
65
  "size": 0,
65
66
  "owner": {
66
- "name": "byroot",
67
+ "name": "Shopify",
67
68
  "email": "jean.boussier@gmail.com"
68
69
  },
69
70
  "private": false,
@@ -5,14 +5,14 @@
5
5
  "created": false,
6
6
  "deleted": false,
7
7
  "forced": false,
8
- "compare": "https://github.com/byroot/junk/compare/16c259864de2...79d29e99cb83",
8
+ "compare": "https://github.com/Shopify/shipit-engine/compare/16c259864de2...79d29e99cb83",
9
9
  "commits": [
10
10
  {
11
11
  "id": "79d29e99cb83e0ba16c9e30c502a60995e711e5f",
12
12
  "distinct": true,
13
13
  "message": "modif",
14
14
  "timestamp": "2014-02-28T10:27:42-08:00",
15
- "url": "https://github.com/byroot/junk/commit/79d29e99cb83e0ba16c9e30c502a60995e711e5f",
15
+ "url": "https://github.com/Shopify/shipit-engine/commit/79d29e99cb83e0ba16c9e30c502a60995e711e5f",
16
16
  "author": {
17
17
  "name": "Guillaume Malette",
18
18
  "email": "gmalette@gmail.com",
@@ -35,7 +35,7 @@
35
35
  "distinct": true,
36
36
  "message": "modif",
37
37
  "timestamp": "2014-02-28T10:27:42-08:00",
38
- "url": "https://github.com/byroot/junk/commit/79d29e99cb83e0ba16c9e30c502a60995e711e5f",
38
+ "url": "https://github.com/Shopify/shipit-engine/commit/79d29e99cb83e0ba16c9e30c502a60995e711e5f",
39
39
  "author": {
40
40
  "name": "Guillaume Malette",
41
41
  "email": "gmalette@gmail.com",
@@ -54,8 +54,9 @@
54
54
  },
55
55
  "repository": {
56
56
  "id": 17266426,
57
- "name": "junk",
58
- "url": "https://github.com/byroot/junk",
57
+ "name": "shipit-engine",
58
+ "full_name": "Shopify/shipit-engine",
59
+ "url": "https://github.com/Shopify/shipit-engine",
59
60
  "description": "Pure test repo, look elsewhere please.",
60
61
  "watchers": 0,
61
62
  "stargazers": 0,
@@ -63,7 +64,7 @@
63
64
  "fork": false,
64
65
  "size": 0,
65
66
  "owner": {
66
- "name": "byroot",
67
+ "name": "Shopify",
67
68
  "email": "jean.boussier@gmail.com"
68
69
  },
69
70
  "private": false,
@@ -18,8 +18,8 @@ anonymous:
18
18
 
19
19
  shipit:
20
20
  name: Shipit
21
- email: shipit@example.com
22
- login: shipit
21
+ github_id: 38352116
22
+ login: "shipit[bot]"
23
23
 
24
24
  legacy:
25
25
  name: Legacy Walrussian
@@ -23,7 +23,7 @@ module HooksHelper
23
23
  args.map.with_index.all? { |value, index| value == call.args[index] }
24
24
  end
25
25
  matcher = args.map(&:inspect).join(', ')
26
- got = called && called.args.map(&:inspect).join(', ')
26
+ got = called&.args&.map(&:inspect)&.join(', ')
27
27
  refute called, "Expected no hook matching: (#{matcher})\n got: (#{got})"
28
28
  end
29
29
 
@@ -1,6 +1,5 @@
1
1
  module PayloadsHelper
2
2
  def payload(name)
3
- file = Shipit::Engine.root.join('test/fixtures/payloads', "#{name}.json")
4
- JSON.parse(file.read)
3
+ Shipit::Engine.root.join('test/fixtures/payloads', "#{name}.json").read
5
4
  end
6
5
  end
@@ -8,7 +8,7 @@ module Shipit
8
8
  end
9
9
 
10
10
  test "perform destroys the received stack" do
11
- Shipit.github_api.expects(:remove_hook).times(@stack.github_hooks.count)
11
+ Shipit.github.api.expects(:remove_hook).times(@stack.github_hooks.count)
12
12
 
13
13
  assert_difference -> { Stack.count }, -1 do
14
14
  @job.perform(@stack)
@@ -16,9 +16,9 @@ module Shipit
16
16
  end
17
17
 
18
18
  test "#pull_request? detects pull requests with unusual branch names" do
19
- @pr.message = "Merge pull request #7 from Shopify/bump-👉-v1.0.1\n\nBump 👉 v1.0.1"
19
+ @pr.message = "Merge pull request #7 from Shopify/bump--v1.0.1\n\nBump v1.0.1"
20
20
  assert @pr.pull_request?
21
- assert_equal "Bump 👉 v1.0.1", @pr.pull_request_title
21
+ assert_equal "Bump v1.0.1", @pr.pull_request_title
22
22
  end
23
23
 
24
24
  test "#pull_request_number extract the pull request id from the message" do
@@ -162,7 +162,7 @@ module Shipit
162
162
  target_url: 'http://example.com',
163
163
  created_at: 1.day.ago,
164
164
  )
165
- Shipit.github_api.expects(:statuses).with(@stack.github_repo_name, @commit.sha).returns([status])
165
+ Shipit.github.api.expects(:statuses).with(@stack.github_repo_name, @commit.sha).returns([status])
166
166
  assert_difference '@commit.statuses.count', 1 do
167
167
  @commit.refresh_statuses!
168
168
  end
@@ -186,7 +186,7 @@ module Shipit
186
186
 
187
187
  test "fetch_stats! pulls additions and deletions from github" do
188
188
  commit = stub(stats: stub(additions: 4242, deletions: 2424))
189
- Shipit.github_api.expects(:commit).with(@stack.github_repo_name, @commit.sha).returns(commit)
189
+ Shipit.github.api.expects(:commit).with(@stack.github_repo_name, @commit.sha).returns(commit)
190
190
  @commit.fetch_stats!
191
191
  assert_equal 4242, @commit.additions
192
192
  assert_equal 2424, @commit.deletions
@@ -194,7 +194,7 @@ module Shipit
194
194
 
195
195
  test "fetch_stats! doesn't fail if the commits have no stats" do
196
196
  commit = stub(stats: nil)
197
- Shipit.github_api.expects(:commit).with(@stack.github_repo_name, @commit.sha).returns(commit)
197
+ Shipit.github.api.expects(:commit).with(@stack.github_repo_name, @commit.sha).returns(commit)
198
198
  assert_nothing_raised do
199
199
  @commit.fetch_stats!
200
200
  end
@@ -123,6 +123,17 @@ module Shipit
123
123
  'context' => 'bar',
124
124
  },
125
125
  )
126
+ assert_equal ["kubernetes-deploy --max-watch-seconds 900 foo bar"], @spec.deploy_steps
127
+ end
128
+
129
+ test "#deploy_steps `kubernetes` respects timeout false" do
130
+ @spec.stubs(:load_config).returns(
131
+ 'kubernetes' => {
132
+ 'namespace' => 'foo',
133
+ 'context' => 'bar',
134
+ 'timeout' => false,
135
+ },
136
+ )
126
137
  assert_equal ["kubernetes-deploy foo bar"], @spec.deploy_steps
127
138
  end
128
139
 
@@ -135,7 +146,7 @@ module Shipit
135
146
  'context' => 'bar',
136
147
  },
137
148
  )
138
- assert_equal ["kubernetes-deploy foo bar"], @spec.deploy_steps
149
+ assert_equal ["kubernetes-deploy --max-watch-seconds 900 foo bar"], @spec.deploy_steps
139
150
  end
140
151
 
141
152
  test "#deploy_steps returns kubernetes command if `kubernetes` is present and template_dir is set" do
@@ -146,7 +157,7 @@ module Shipit
146
157
  'template_dir' => 'k8s_templates/',
147
158
  },
148
159
  )
149
- assert_equal ["kubernetes-deploy --template-dir k8s_templates/ foo bar"], @spec.deploy_steps
160
+ assert_equal ["kubernetes-deploy --max-watch-seconds 900 --template-dir k8s_templates/ foo bar"], @spec.deploy_steps
150
161
  end
151
162
 
152
163
  test "#deploy_steps prepend and append pre and post steps" do
@@ -188,7 +199,7 @@ module Shipit
188
199
  'context' => 'bar',
189
200
  },
190
201
  )
191
- assert_equal ["kubernetes-deploy foo bar"], @spec.rollback_steps
202
+ assert_equal ["kubernetes-deploy --max-watch-seconds 900 foo bar"], @spec.rollback_steps
192
203
  end
193
204
 
194
205
  test "#rollback_steps returns kubernetes-deploy command when both capfile and `kubernetes` are present" do
@@ -200,7 +211,7 @@ module Shipit
200
211
  'context' => 'bar',
201
212
  },
202
213
  )
203
- assert_equal ["kubernetes-deploy foo bar"], @spec.rollback_steps
214
+ assert_equal ["kubernetes-deploy --max-watch-seconds 900 foo bar"], @spec.rollback_steps
204
215
  end
205
216
 
206
217
  test '#machine_env returns an environment hash' do
@@ -344,13 +355,14 @@ module Shipit
344
355
  'kubernetes' => {
345
356
  'namespace' => 'foo',
346
357
  'context' => 'bar',
358
+ 'timeout' => '20m',
347
359
  },
348
360
  )
349
361
  tasks = @spec.task_definitions
350
362
  assert_equal 2, tasks.size
351
363
 
352
364
  restart_task = tasks.find { |t| t.id == "restart" }
353
- assert_equal ["kubernetes-restart foo bar"], restart_task.steps
365
+ assert_equal ["kubernetes-restart foo bar --max-watch-seconds 1200"], restart_task.steps
354
366
  end
355
367
 
356
368
  test "task definitions returns an array of VariableDefinition instances" do
@@ -7,47 +7,8 @@ module Shipit
7
7
  @hook = shipit_github_hooks(:shipit_push)
8
8
  end
9
9
 
10
- test "#verify_signature is true if the signature matches" do
11
- assert @hook.verify_signature('sha1=9fb52fecc2b97b7a912aca27685149d2ce571900', 'hello shipit')
12
- end
13
-
14
- test "#verify_signature is false if the signature doesn't match" do
15
- refute @hook.verify_signature('sha1=9fb52fecc2b97b7a912aca27685149d2ce571900', 'hello toto')
16
- end
17
-
18
- test "#setup! create the hook on Github side" do
19
- @hook = shipit_github_hooks(:cyclimse_push)
20
-
21
- response = mock(id: 44, rels: {self: mock(href: 'https://api.github.com/somestuff')})
22
- Shipit.github_api.expects(:create_hook).with(
23
- @hook.github_repo_name,
24
- 'web',
25
- includes(:url, :content_type, :secret),
26
- includes(:events, :active),
27
- ).returns(response)
28
- @hook.setup!
29
- @hook.reload
30
- assert_equal 44, @hook.github_id
31
- assert_equal 'https://api.github.com/somestuff', @hook.api_url
32
- end
33
-
34
- test "#setup! update the hook it it already exist" do
35
- response = mock(id: 44, rels: {self: mock(href: 'https://api.github.com/somestuff')})
36
- Shipit.github_api.expects(:edit_hook).with(
37
- @hook.github_repo_name,
38
- @hook.github_id,
39
- 'web',
40
- includes(:url, :content_type, :secret),
41
- includes(:events, :active),
42
- ).returns(response)
43
- @hook.setup!
44
- @hook.reload
45
- assert_equal 44, @hook.github_id
46
- assert_equal 'https://api.github.com/somestuff', @hook.api_url
47
- end
48
-
49
10
  test "#destroy starts by removing the hook" do
50
- Shipit.github_api.expects(:remove_hook).with(@hook.github_repo_name, @hook.github_id)
11
+ Shipit.legacy_github_api.expects(:remove_hook).with(@hook.github_repo_name, @hook.github_id)
51
12
  assert_difference -> { GithubHook.count }, -1 do
52
13
  @hook.destroy!
53
14
  end
@@ -59,7 +59,7 @@ module Shipit
59
59
 
60
60
  assert_nil PullRequest.extract_number(@stack, 'https://github.com/ACME/shipit-engine/pull/42')
61
61
 
62
- Shipit.expects(:github_domain).returns('github.acme.com').at_least_once
62
+ Shipit.github.expects(:domain).returns('github.acme.com').at_least_once
63
63
  assert_equal 42, PullRequest.extract_number(@stack, 'https://github.acme.com/Shopify/shipit-engine/pull/42')
64
64
  assert_nil PullRequest.extract_number(@stack, 'https://github.com/Shopify/shipit-engine/pull/42')
65
65
  end
@@ -69,7 +69,7 @@ module Shipit
69
69
 
70
70
  head_sha = '64b3833d39def7ec65b57b42f496eb27ab4980b6'
71
71
  base_sha = 'ba7ab50e02286f7d6c60c1ef75258133dd9ea763'
72
- Shipit.github_api.expects(:pull_request).with(@stack.github_repo_name, pull_request.number).returns(
72
+ Shipit.github.api.expects(:pull_request).with(@stack.github_repo_name, pull_request.number).returns(
73
73
  stub(
74
74
  id: 4_857_578,
75
75
  url: 'https://api.github.com/repos/Shopify/shipit-engine/pulls/64',
@@ -98,7 +98,7 @@ module Shipit
98
98
  )
99
99
 
100
100
  [head_sha, base_sha].each do |sha|
101
- Shipit.github_api.expects(:commit).with(@stack.github_repo_name, sha).returns(
101
+ Shipit.github.api.expects(:commit).with(@stack.github_repo_name, sha).returns(
102
102
  stub(
103
103
  sha: sha,
104
104
  author: author,
@@ -116,7 +116,7 @@ module Shipit
116
116
  )
117
117
  end
118
118
 
119
- Shipit.github_api.expects(:statuses).with(@stack.github_repo_name, head_sha).returns([stub(
119
+ Shipit.github.api.expects(:statuses).with(@stack.github_repo_name, head_sha).returns([stub(
120
120
  state: 'success',
121
121
  description: nil,
122
122
  context: 'default',
@@ -213,16 +213,16 @@ module Shipit
213
213
  end
214
214
 
215
215
  test "#merge! doesnt delete the branch if there are open PRs against it" do
216
- Shipit.github_api.expects(:merge_pull_request).once.returns(true)
217
- Shipit.github_api.expects(:pull_requests).once.with(@stack.github_repo_name, base: @pr.branch).returns([1])
218
- Shipit.github_api.expects(:delete_branch).never.returns(false)
216
+ Shipit.github.api.expects(:merge_pull_request).once.returns(true)
217
+ Shipit.github.api.expects(:pull_requests).once.with(@stack.github_repo_name, base: @pr.branch).returns([1])
218
+ Shipit.github.api.expects(:delete_branch).never.returns(false)
219
219
  assert_equal true, @pr.merge!
220
220
  end
221
221
 
222
222
  test "#merge! increments undeployed_commits_count" do
223
- Shipit.github_api.expects(:merge_pull_request).once.returns(true)
224
- Shipit.github_api.expects(:pull_requests).once.returns([])
225
- Shipit.github_api.expects(:delete_branch).once.returns(true)
223
+ Shipit.github.api.expects(:merge_pull_request).once.returns(true)
224
+ Shipit.github.api.expects(:pull_requests).once.returns([])
225
+ Shipit.github.api.expects(:delete_branch).once.returns(true)
226
226
  assert_difference '@stack.undeployed_commits_count' do
227
227
  @pr.merge!
228
228
  @stack.reload
@@ -241,7 +241,7 @@ module Shipit
241
241
  test "#stale? returns true when the branch falls behind the maximum commits" do
242
242
  @pr.base_commit = shipit_commits(:second)
243
243
  @pr.base_ref = 'default-branch'
244
- Shipit.github_api.expects(:compare).with(@stack.github_repo_name, @pr.base_ref, @pr.head.sha).returns(
244
+ Shipit.github.api.expects(:compare).with(@stack.github_repo_name, @pr.base_ref, @pr.head.sha).returns(
245
245
  stub(
246
246
  behind_by: 10,
247
247
  ),
@@ -213,12 +213,6 @@ module Shipit
213
213
  @stack.update_deployed_revision(last_deploy.since_commit.sha)
214
214
  end
215
215
 
216
- test "#create queues 2 GithubSetupWebhooksJob" do
217
- assert_enqueued_with(job: SetupGithubHookJob) do
218
- Stack.create!(repo_name: 'rails', repo_owner: 'rails')
219
- end
220
- end
221
-
222
216
  test "#create queues a GithubSyncJob" do
223
217
  assert_enqueued_with(job: GithubSyncJob) do
224
218
  Stack.create!(repo_name: 'rails', repo_owner: 'rails')
@@ -455,16 +449,16 @@ module Shipit
455
449
  repo_permalink = 'https://api.github.com/repositories/42'
456
450
 
457
451
  commits_redirection = stub(message: 'Moved Permanently', url: File.join(repo_permalink, '/commits'))
458
- Shipit.github_api.expects(:commits).with(@stack.github_repo_name, sha: 'master').returns(commits_redirection)
452
+ Shipit.github.api.expects(:commits).with(@stack.github_repo_name, sha: 'master').returns(commits_redirection)
459
453
 
460
454
  repo_redirection = stub(message: 'Moved Permanently', url: repo_permalink)
461
- Shipit.github_api.expects(:repo).with('shopify/shipit-engine').returns(repo_redirection)
455
+ Shipit.github.api.expects(:repo).with('shopify/shipit-engine').returns(repo_redirection)
462
456
 
463
457
  repo_resource = stub(name: 'shipster', owner: stub(login: 'george'))
464
- Shipit.github_api.expects(:get).with(repo_permalink).returns(repo_resource)
458
+ Shipit.github.api.expects(:get).with(repo_permalink).returns(repo_resource)
465
459
 
466
460
  commits_resource = stub
467
- Shipit.github_api.expects(:commits).with('george/shipster', sha: 'master').returns(commits_resource)
461
+ Shipit.github.api.expects(:commits).with('george/shipster', sha: 'master').returns(commits_resource)
468
462
 
469
463
  assert_equal 'shopify/shipit-engine', @stack.github_repo_name
470
464
  assert_equal commits_resource, @stack.github_commits