shipit-engine 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -37
- data/app/assets/javascripts/task/tty.js.coffee +40 -22
- data/app/assets/stylesheets/_pages/_deploy.scss +1 -0
- data/app/controllers/shipit/api/locks_controller.rb +3 -3
- data/app/controllers/shipit/api/stacks_controller.rb +14 -1
- data/app/controllers/shipit/commit_checks_controller.rb +9 -2
- data/app/controllers/shipit/shipit_controller.rb +1 -1
- data/app/controllers/shipit/stacks_controller.rb +11 -5
- data/app/controllers/shipit/status_controller.rb +1 -1
- data/app/controllers/shipit/webhooks_controller.rb +15 -5
- data/app/helpers/shipit/deploys_helper.rb +1 -1
- data/app/helpers/shipit/shipit_helper.rb +2 -0
- data/app/jobs/shipit/perform_commit_checks_job.rb +2 -0
- data/app/jobs/shipit/perform_task_job.rb +18 -8
- data/app/models/shipit/commit.rb +22 -12
- data/app/models/shipit/commit_checks.rb +20 -53
- data/app/models/shipit/deploy.rb +1 -1
- data/app/models/shipit/ephemeral_commit_checks.rb +76 -0
- data/app/models/shipit/stack.rb +40 -10
- data/app/models/shipit/status.rb +14 -8
- data/app/models/shipit/status_group.rb +1 -1
- data/app/models/shipit/task.rb +2 -0
- data/app/models/shipit/unknown_status.rb +4 -0
- data/app/models/shipit/user.rb +9 -1
- data/app/serializers/shipit/stack_serializer.rb +6 -1
- data/app/views/shipit/commit_checks/_checks.html.erb +13 -0
- data/app/views/shipit/commit_checks/show.html.erb +5 -0
- data/app/views/shipit/stacks/_header.html.erb +1 -1
- data/app/views/shipit/stacks/show.html.erb +15 -0
- data/config/routes.rb +2 -1
- data/db/migrate/20140226233935_create_baseline.rb +10 -10
- data/db/migrate/20160802092812_add_continuous_delivery_delayed_since_to_stacks.rb +5 -0
- data/db/migrate/20160822131405_add_locked_since_to_stacks.rb +5 -0
- data/lib/shipit.rb +4 -0
- data/lib/shipit/command.rb +1 -1
- data/lib/shipit/commands.rb +10 -7
- data/lib/shipit/csv_serializer.rb +1 -1
- data/lib/shipit/stack_commands.rb +17 -5
- data/lib/shipit/task_commands.rb +2 -2
- data/lib/shipit/version.rb +1 -1
- data/lib/snippets/push-to-heroku +20 -16
- data/test/controllers/api/deploys_controller_test.rb +8 -8
- data/test/controllers/api/hooks_controller_test.rb +11 -9
- data/test/controllers/api/locks_controller_test.rb +16 -6
- data/test/controllers/api/outputs_controller_test.rb +1 -1
- data/test/controllers/api/stacks_controller_test.rb +48 -3
- data/test/controllers/api/tasks_controller_test.rb +6 -6
- data/test/controllers/commit_checks_controller_test.rb +3 -3
- data/test/controllers/deploys_controller_test.rb +13 -13
- data/test/controllers/rollbacks_controller_test.rb +7 -7
- data/test/controllers/stacks_controller_test.rb +36 -29
- data/test/controllers/tasks_controller_test.rb +14 -14
- data/test/controllers/webhooks_controller_test.rb +16 -25
- data/test/dummy/config/application.rb +0 -3
- data/test/dummy/config/environments/test.rb +2 -2
- data/test/dummy/data/stacks/byroot/junk/production/git/bar.txt +2 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/bin/slow +7 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/bin/timeout +10 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/dkfdsf +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/dskjfsd +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/dslkjfjsdf +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/plopfizz +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/sd +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/sdkfjsdf +1 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/sdlfjsdfdsfj +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/sdlkfjsdlkfjsdlkfjdsfsdfksdfjsldkfjsdlkfjsdf +0 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/shipit.yml +21 -0
- data/test/dummy/data/stacks/byroot/junk/production/git/toto.txt +2 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +15 -13
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/fixtures/shipit/commit_deployments.yml +8 -8
- data/test/fixtures/shipit/output_chunks.yml +12 -12
- data/test/fixtures/shipit/tasks.yml +9 -1
- data/test/fixtures/shipit/users.yml +9 -2
- data/test/jobs/perform_task_job_test.rb +14 -11
- data/test/models/commits_test.rb +33 -14
- data/test/models/stacks_test.rb +78 -4
- data/test/models/users_test.rb +16 -0
- data/test/unit/commands_test.rb +4 -0
- data/test/unit/deploy_commands_test.rb +1 -1
- metadata +133 -34
- data/app/jobs/shipit/git_mirror_update_job.rb +0 -14
- data/app/views/shipit/deploys/_checks.html.erb +0 -11
@@ -12,7 +12,7 @@ module Shipit
|
|
12
12
|
|
13
13
|
test "#create triggers a new deploy for the stack" do
|
14
14
|
assert_difference -> { @stack.deploys.count }, 1 do
|
15
|
-
post :create, stack_id: @stack.to_param, sha: @commit.sha
|
15
|
+
post :create, params: {stack_id: @stack.to_param, sha: @commit.sha}
|
16
16
|
end
|
17
17
|
assert_response :accepted
|
18
18
|
assert_json 'status', 'pending'
|
@@ -20,7 +20,7 @@ module Shipit
|
|
20
20
|
|
21
21
|
test "#create triggers a new deploy for whitelisted variables" do
|
22
22
|
correct_env = {'SAFETY_DISABLED' => 1}
|
23
|
-
post :create, stack_id: @stack.to_param, sha: @commit.sha, env: correct_env
|
23
|
+
post :create, params: {stack_id: @stack.to_param, sha: @commit.sha, env: correct_env}
|
24
24
|
assert_response :accepted
|
25
25
|
assert_json 'type', 'deploy'
|
26
26
|
assert_json 'status', 'pending'
|
@@ -28,26 +28,26 @@ module Shipit
|
|
28
28
|
|
29
29
|
test "#create refuses to trigger a new deploy with incorrect variables" do
|
30
30
|
incorrect_env = {'DANGEROUS_VARIABLE' => 1}
|
31
|
-
post :create, stack_id: @stack.to_param, sha: @commit.sha, env: incorrect_env
|
31
|
+
post :create, params: {stack_id: @stack.to_param, sha: @commit.sha, env: incorrect_env}
|
32
32
|
assert_response :unprocessable_entity
|
33
33
|
assert_json 'message', 'Variables DANGEROUS_VARIABLE have not been whitelisted'
|
34
34
|
end
|
35
35
|
|
36
36
|
test "#create use the claimed user as author" do
|
37
37
|
request.headers['X-Shipit-User'] = @user.login
|
38
|
-
post :create, stack_id: @stack.to_param, sha: @commit.sha
|
38
|
+
post :create, params: {stack_id: @stack.to_param, sha: @commit.sha}
|
39
39
|
deploy = Deploy.last
|
40
40
|
deploy.user == @user
|
41
41
|
end
|
42
42
|
|
43
43
|
test "#create renders a 422 if the sha isn't found" do
|
44
|
-
post :create, stack_id: @stack.to_param, sha: '123443543545'
|
44
|
+
post :create, params: {stack_id: @stack.to_param, sha: '123443543545'}
|
45
45
|
assert_response :unprocessable_entity
|
46
46
|
assert_json 'errors', 'sha' => ['Unknown revision']
|
47
47
|
end
|
48
48
|
|
49
49
|
test "#create renders a 422 if the sha format is invalid" do
|
50
|
-
post :create, stack_id: @stack.to_param, sha: '1'
|
50
|
+
post :create, params: {stack_id: @stack.to_param, sha: '1'}
|
51
51
|
assert_response :unprocessable_entity
|
52
52
|
assert_json 'errors', 'sha' => ['is too short (minimum is 6 characters)']
|
53
53
|
end
|
@@ -56,7 +56,7 @@ module Shipit
|
|
56
56
|
@stack.update!(lock_reason: 'Something broken')
|
57
57
|
|
58
58
|
assert_no_difference -> { @stack.deploys.count } do
|
59
|
-
post :create, stack_id: @stack.to_param, sha: @commit.sha
|
59
|
+
post :create, params: {stack_id: @stack.to_param, sha: @commit.sha}
|
60
60
|
end
|
61
61
|
assert_response :unprocessable_entity
|
62
62
|
assert_json 'errors.force', ["Can't deploy a locked stack"]
|
@@ -66,7 +66,7 @@ module Shipit
|
|
66
66
|
@stack.update!(lock_reason: 'Something broken')
|
67
67
|
|
68
68
|
assert_difference -> { @stack.deploys.count }, 1 do
|
69
|
-
post :create, stack_id: @stack.to_param, sha: @commit.sha, force: true
|
69
|
+
post :create, params: {stack_id: @stack.to_param, sha: @commit.sha, force: 'true'}
|
70
70
|
end
|
71
71
|
assert_response :accepted
|
72
72
|
assert_json 'status', 'pending'
|
@@ -26,7 +26,7 @@ module Shipit
|
|
26
26
|
test "#index with a stack_id returns the list of scoped hooks" do
|
27
27
|
hook = Hook.scoped_to(@stack).first
|
28
28
|
|
29
|
-
get :index, stack_id: @stack.to_param
|
29
|
+
get :index, params: {stack_id: @stack.to_param}
|
30
30
|
assert_response :ok
|
31
31
|
assert_json '0.id', hook.id
|
32
32
|
assert_json '0.delivery_url', hook.delivery_url
|
@@ -37,7 +37,7 @@ module Shipit
|
|
37
37
|
test "#show returns the hooks" do
|
38
38
|
hook = Hook.scoped_to(@stack).first
|
39
39
|
|
40
|
-
get :show, stack_id: @stack.to_param, id: hook.id
|
40
|
+
get :show, params: {stack_id: @stack.to_param, id: hook.id}
|
41
41
|
assert_response :ok
|
42
42
|
|
43
43
|
assert_json 'id', hook.id
|
@@ -48,7 +48,7 @@ module Shipit
|
|
48
48
|
|
49
49
|
test "#create adds a new hook" do
|
50
50
|
assert_difference -> { Hook.count }, 1 do
|
51
|
-
post :create, delivery_url: 'https://example.com/hook', events: %w(deploy rollback)
|
51
|
+
post :create, params: {delivery_url: 'https://example.com/hook', events: %w(deploy rollback)}
|
52
52
|
end
|
53
53
|
hook = Hook.last
|
54
54
|
assert_json 'delivery_url', 'https://example.com/hook'
|
@@ -57,28 +57,30 @@ module Shipit
|
|
57
57
|
end
|
58
58
|
|
59
59
|
test "#create do not allow to set protected attributes" do
|
60
|
-
post :create,
|
61
|
-
|
62
|
-
|
60
|
+
post :create, params: {
|
61
|
+
delivery_url: 'https://example.com/hook',
|
62
|
+
events: %w(deploy rollback),
|
63
|
+
created_at: 2.months.ago.to_s(:db),
|
64
|
+
}
|
63
65
|
Hook.last.created_at > 2.seconds.ago
|
64
66
|
end
|
65
67
|
|
66
68
|
test "#create returns validation errors" do
|
67
|
-
post :create, delivery_url: '../etc/passwd', events: %w(deploy)
|
69
|
+
post :create, params: {delivery_url: '../etc/passwd', events: %w(deploy)}
|
68
70
|
assert_response :unprocessable_entity
|
69
71
|
assert_json 'errors', 'delivery_url' => ['is not a valid URL']
|
70
72
|
end
|
71
73
|
|
72
74
|
test "#update changes an existing hook" do
|
73
75
|
hook = Hook.global.first
|
74
|
-
patch :update, id: hook.id, delivery_url: 'https://shipit.com/'
|
76
|
+
patch :update, params: {id: hook.id, delivery_url: 'https://shipit.com/'}
|
75
77
|
assert_response :ok
|
76
78
|
assert_json 'delivery_url', 'https://shipit.com/'
|
77
79
|
end
|
78
80
|
|
79
81
|
test "#destroy removes an existing hook" do
|
80
82
|
hook = Hook.global.first
|
81
|
-
delete :destroy, id: hook.id
|
83
|
+
delete :destroy, params: {id: hook.id}
|
82
84
|
assert_response :no_content
|
83
85
|
end
|
84
86
|
end
|
@@ -9,20 +9,21 @@ module Shipit
|
|
9
9
|
end
|
10
10
|
|
11
11
|
test "#create sets a lock" do
|
12
|
-
post :create, stack_id: @stack.to_param, reason: 'Just for fun!'
|
12
|
+
post :create, params: {stack_id: @stack.to_param, reason: 'Just for fun!'}
|
13
13
|
assert_response :ok
|
14
14
|
assert_json 'is_locked', true
|
15
15
|
assert_json 'lock_reason', 'Just for fun!'
|
16
|
+
assert_json { |json| assert_not_nil json['locked_since'] }
|
16
17
|
end
|
17
18
|
|
18
19
|
test "#create fails if already locked" do
|
19
20
|
@stack.update!(lock_reason: "Don't forget me")
|
20
|
-
post :create, stack_id: @stack.to_param, reason: 'Just for fun!'
|
21
|
+
post :create, params: {stack_id: @stack.to_param, reason: 'Just for fun!'}
|
21
22
|
assert_response :conflict
|
22
23
|
end
|
23
24
|
|
24
25
|
test "#update sets a lock" do
|
25
|
-
put :update, stack_id: @stack.to_param, reason: 'Just for fun!'
|
26
|
+
put :update, params: {stack_id: @stack.to_param, reason: 'Just for fun!'}
|
26
27
|
assert_response :ok
|
27
28
|
assert_json 'is_locked', true
|
28
29
|
assert_json 'lock_reason', 'Just for fun!'
|
@@ -30,17 +31,26 @@ module Shipit
|
|
30
31
|
|
31
32
|
test "#update can override a previous lock" do
|
32
33
|
@stack.update!(lock_reason: 'Meh...')
|
33
|
-
put :update, stack_id: @stack.to_param, reason: 'Just for fun!'
|
34
|
+
put :update, params: {stack_id: @stack.to_param, reason: 'Just for fun!'}
|
34
35
|
assert_response :ok
|
35
36
|
assert_json 'is_locked', true
|
36
37
|
assert_json 'lock_reason', 'Just for fun!'
|
37
38
|
end
|
38
39
|
|
40
|
+
test "#update does not override previous locked_since" do
|
41
|
+
since = Time.current.round
|
42
|
+
@stack.update!(lock_reason: 'Meh...', locked_since: since)
|
43
|
+
put :update, params: {stack_id: @stack.to_param, reason: 'Just for fun!'}
|
44
|
+
assert_response :ok
|
45
|
+
assert_json 'locked_since', since.utc.iso8601(3)
|
46
|
+
end
|
47
|
+
|
39
48
|
test "#destroy clears the lock" do
|
40
|
-
@stack.update!(lock_reason: 'Meh...')
|
41
|
-
delete :destroy, stack_id: @stack.to_param
|
49
|
+
@stack.update!(lock_reason: 'Meh...', locked_since: Time.current)
|
50
|
+
delete :destroy, params: {stack_id: @stack.to_param}
|
42
51
|
assert_response :ok
|
43
52
|
assert_json 'is_locked', false
|
53
|
+
assert_json { |json| assert_nil json['locked_since'] }
|
44
54
|
end
|
45
55
|
end
|
46
56
|
end
|
@@ -11,7 +11,7 @@ module Shipit
|
|
11
11
|
test "#show returns the task output as plain text" do
|
12
12
|
task = @stack.tasks.last
|
13
13
|
|
14
|
-
get :show, stack_id: @stack.to_param, task_id: task.id
|
14
|
+
get :show, params: {stack_id: @stack.to_param, task_id: task.id}
|
15
15
|
assert_response :ok
|
16
16
|
assert_equal 'text/plain', response.content_type
|
17
17
|
assert_equal task.chunk_output, response.body
|
@@ -8,6 +8,51 @@ module Shipit
|
|
8
8
|
@stack = shipit_stacks(:shipit)
|
9
9
|
end
|
10
10
|
|
11
|
+
test "#create fails with insufficient permissions" do
|
12
|
+
@client.permissions.delete('write:stack')
|
13
|
+
@client.save!
|
14
|
+
|
15
|
+
assert_no_difference 'Stack.count' do
|
16
|
+
post :create, params: {repo_name: 'rails', repo_owner: 'rails', environment: 'staging', branch: 'staging'}
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_response :forbidden
|
20
|
+
assert_json 'message', 'This operation requires the `write:stack` permission'
|
21
|
+
end
|
22
|
+
|
23
|
+
test "#create fails with invalid stack" do
|
24
|
+
assert_no_difference "Stack.count" do
|
25
|
+
post :create, params: {repo_owner: 'some', repo_name: 'owner/path'}
|
26
|
+
end
|
27
|
+
assert_response :unprocessable_entity
|
28
|
+
assert_json 'errors', 'repo_name' => ['is invalid']
|
29
|
+
end
|
30
|
+
|
31
|
+
test "#create creates a stack and renders it back" do
|
32
|
+
assert_difference -> { Stack.count } do
|
33
|
+
post :create, params: {repo_name: 'rails', repo_owner: 'rails', environment: 'staging', branch: 'staging'}
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_response :ok
|
37
|
+
assert_json 'id', Stack.last.id
|
38
|
+
end
|
39
|
+
|
40
|
+
test "#create fails to create stack if it already exists" do
|
41
|
+
Stack.create!(
|
42
|
+
repo_name: 'rails',
|
43
|
+
repo_owner: 'rails',
|
44
|
+
environment: 'staging',
|
45
|
+
branch: 'staging',
|
46
|
+
)
|
47
|
+
|
48
|
+
assert_no_difference -> { Stack.count } do
|
49
|
+
post :create, params: {repo_name: 'rails', repo_owner: 'rails', environment: 'staging', branch: 'staging'}
|
50
|
+
end
|
51
|
+
|
52
|
+
assert_response :unprocessable_entity
|
53
|
+
assert_json 'errors', 'repo_name' => ['cannot be used more than once with this environment']
|
54
|
+
end
|
55
|
+
|
11
56
|
test "#index returns a list of stacks" do
|
12
57
|
stack = Stack.last
|
13
58
|
|
@@ -20,7 +65,7 @@ module Shipit
|
|
20
65
|
end
|
21
66
|
|
22
67
|
test "#index is paginable" do
|
23
|
-
get :index, page_size: 1
|
68
|
+
get :index, params: {page_size: 1}
|
24
69
|
assert_json do |list|
|
25
70
|
assert_instance_of Array, list
|
26
71
|
assert_equal 1, list.size
|
@@ -32,7 +77,7 @@ module Shipit
|
|
32
77
|
end
|
33
78
|
|
34
79
|
test "the `next` link is not provided when the last page is reached" do
|
35
|
-
get :index, page_size: Stack.count
|
80
|
+
get :index, params: {page_size: Stack.count}
|
36
81
|
assert_no_link 'next'
|
37
82
|
end
|
38
83
|
|
@@ -52,7 +97,7 @@ module Shipit
|
|
52
97
|
end
|
53
98
|
|
54
99
|
test "#show renders the stack" do
|
55
|
-
get :show, id: @stack.to_param
|
100
|
+
get :show, params: {id: @stack.to_param}
|
56
101
|
assert_response :ok
|
57
102
|
assert_json 'id', @stack.id
|
58
103
|
end
|
@@ -11,7 +11,7 @@ module Shipit
|
|
11
11
|
test "#index returns a list of tasks" do
|
12
12
|
task = @stack.tasks.last
|
13
13
|
|
14
|
-
get :index, stack_id: @stack.to_param
|
14
|
+
get :index, params: {stack_id: @stack.to_param}
|
15
15
|
assert_response :ok
|
16
16
|
assert_json '0.id', task.id
|
17
17
|
end
|
@@ -19,13 +19,13 @@ module Shipit
|
|
19
19
|
test "#show returns a task" do
|
20
20
|
task = @stack.tasks.last
|
21
21
|
|
22
|
-
get :show, stack_id: @stack.to_param, id: task.id
|
22
|
+
get :show, params: {stack_id: @stack.to_param, id: task.id}
|
23
23
|
assert_response :ok
|
24
24
|
assert_json 'id', task.id
|
25
25
|
end
|
26
26
|
|
27
27
|
test "#trigger triggers a custom task" do
|
28
|
-
post :trigger, stack_id: @stack.to_param, task_name: 'restart'
|
28
|
+
post :trigger, params: {stack_id: @stack.to_param, task_name: 'restart'}
|
29
29
|
assert_response :accepted
|
30
30
|
assert_json 'type', 'task'
|
31
31
|
assert_json 'status', 'pending'
|
@@ -33,21 +33,21 @@ module Shipit
|
|
33
33
|
|
34
34
|
test "#trigger refuses to trigger a task with tasks not whitelisted" do
|
35
35
|
env = {'DANGEROUS_VARIABLE' => 'bar'}
|
36
|
-
post :trigger, stack_id: @stack.to_param, task_name: 'restart', env: env
|
36
|
+
post :trigger, params: {stack_id: @stack.to_param, task_name: 'restart', env: env}
|
37
37
|
assert_response :unprocessable_entity
|
38
38
|
assert_json 'message', 'Variables DANGEROUS_VARIABLE have not been whitelisted'
|
39
39
|
end
|
40
40
|
|
41
41
|
test "#trigger triggers a task with only whitelisted env variables" do
|
42
42
|
env = {'FOO' => 'bar'}
|
43
|
-
post :trigger, stack_id: @stack.to_param, task_name: 'restart', env: env
|
43
|
+
post :trigger, params: {stack_id: @stack.to_param, task_name: 'restart', env: env}
|
44
44
|
assert_response :accepted
|
45
45
|
assert_json 'type', 'task'
|
46
46
|
assert_json 'status', 'pending'
|
47
47
|
end
|
48
48
|
|
49
49
|
test "#trigger returns a 404 when the task doesn't exist" do
|
50
|
-
post :trigger, stack_id: @stack.to_param, task_name: 'doesnt_exist'
|
50
|
+
post :trigger, params: {stack_id: @stack.to_param, task_name: 'doesnt_exist'}
|
51
51
|
assert_response :not_found
|
52
52
|
end
|
53
53
|
end
|
@@ -12,7 +12,7 @@ module Shipit
|
|
12
12
|
end
|
13
13
|
|
14
14
|
test ":tail is success" do
|
15
|
-
get :tail, stack_id: @stack.to_param, sha: @commit.sha
|
15
|
+
get :tail, params: {stack_id: @stack.to_param, sha: @commit.sha}
|
16
16
|
assert_response :success
|
17
17
|
assert_json 'output', 'foobar'
|
18
18
|
assert_json 'url', stack_tail_commit_checks_path(@stack, sha: @commit.sha, since: 6)
|
@@ -21,14 +21,14 @@ module Shipit
|
|
21
21
|
|
22
22
|
test ":tail doesn't provide another url if the task is finished" do
|
23
23
|
@checks.status = 'success'
|
24
|
-
get :tail, stack_id: @stack.to_param, sha: @commit.sha
|
24
|
+
get :tail, params: {stack_id: @stack.to_param, sha: @commit.sha}
|
25
25
|
assert_response :success
|
26
26
|
assert_json 'url', nil
|
27
27
|
end
|
28
28
|
|
29
29
|
test ":tail returns only the output after the provided offset" do
|
30
30
|
@checks.status = 'success'
|
31
|
-
get :tail, stack_id: @stack.to_param, sha: @commit.sha, since: 5
|
31
|
+
get :tail, params: {stack_id: @stack.to_param, sha: @commit.sha, since: 5}
|
32
32
|
assert_response :success
|
33
33
|
assert_json 'output', 'r'
|
34
34
|
end
|
@@ -11,30 +11,30 @@ module Shipit
|
|
11
11
|
end
|
12
12
|
|
13
13
|
test ":show is success" do
|
14
|
-
get :show, stack_id: @stack.to_param, id: @deploy.id
|
14
|
+
get :show, params: {stack_id: @stack.to_param, id: @deploy.id}
|
15
15
|
assert_response :success
|
16
16
|
end
|
17
17
|
|
18
18
|
test "deploys can be observed as raw text" do
|
19
|
-
get :show, stack_id: @stack, id: @deploy.id, format:
|
19
|
+
get :show, params: {stack_id: @stack, id: @deploy.id, format: 'txt'}
|
20
20
|
assert_response :success
|
21
21
|
assert_equal("text/plain", @response.content_type)
|
22
22
|
end
|
23
23
|
|
24
24
|
test ":new is success" do
|
25
|
-
get :new, stack_id: @stack.to_param, sha: @commit.sha
|
25
|
+
get :new, params: {stack_id: @stack.to_param, sha: @commit.sha}
|
26
26
|
assert_response :success
|
27
27
|
end
|
28
28
|
|
29
29
|
test ":new works for not yet deployed stacks" do
|
30
30
|
@stack = shipit_stacks(:undeployed_stack)
|
31
|
-
get :new, stack_id: @stack.to_param, sha: @stack.commits.last.sha
|
31
|
+
get :new, params: {stack_id: @stack.to_param, sha: @stack.commits.last.sha}
|
32
32
|
end
|
33
33
|
|
34
34
|
test ":new shows a warning if a deploy is already running" do
|
35
35
|
shipit_deploys(:shipit_running).update_column(:status, 'running')
|
36
36
|
|
37
|
-
get :new, stack_id: @stack.to_param, sha: @commit.sha
|
37
|
+
get :new, params: {stack_id: @stack.to_param, sha: @commit.sha}
|
38
38
|
assert_response :success
|
39
39
|
assert_select '.warning.concurrent-deploy h2' do |elements|
|
40
40
|
assert_equal 'Lando Walrussian is already deploying!', elements.first.text
|
@@ -44,19 +44,19 @@ module Shipit
|
|
44
44
|
|
45
45
|
test ":create persists a new deploy" do
|
46
46
|
assert_difference '@stack.deploys.count', 1 do
|
47
|
-
post :create, stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id}
|
47
|
+
post :create, params: {stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id}}
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
test ":create can receive an :env hash" do
|
52
52
|
env = {'SAFETY_DISABLED' => '1'}
|
53
|
-
post :create, stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id, env: env}
|
53
|
+
post :create, params: {stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id, env: env}}
|
54
54
|
new_deploy = Deploy.last
|
55
55
|
assert_equal env, new_deploy.env
|
56
56
|
end
|
57
57
|
|
58
58
|
test ":create ignore :env keys not declared in the deploy spec" do
|
59
|
-
post :create, stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id, env: {'H4X0R' => '1'}}
|
59
|
+
post :create, params: {stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id, env: {'H4X0R' => '1'}}}
|
60
60
|
new_deploy = Deploy.last
|
61
61
|
assert_equal({}, new_deploy.env)
|
62
62
|
end
|
@@ -65,7 +65,7 @@ module Shipit
|
|
65
65
|
shipit_deploys(:shipit_running).update_column(:status, 'running')
|
66
66
|
|
67
67
|
assert_difference '@stack.deploys.count', 1 do
|
68
|
-
post :create, stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id}, force: true
|
68
|
+
post :create, params: {stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id}, force: 'true'}
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -73,26 +73,26 @@ module Shipit
|
|
73
73
|
shipit_deploys(:shipit_running).update_column(:status, 'running')
|
74
74
|
|
75
75
|
assert_no_difference '@stack.deploys.count' do
|
76
|
-
post :create, stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id}
|
76
|
+
post :create, params: {stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id}}
|
77
77
|
end
|
78
78
|
assert_redirected_to new_stack_deploy_path(@stack, sha: @commit.sha)
|
79
79
|
end
|
80
80
|
|
81
81
|
test ":create redirects to the new deploy" do
|
82
|
-
post :create, stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id}
|
82
|
+
post :create, params: {stack_id: @stack.to_param, deploy: {until_commit_id: @commit.id}}
|
83
83
|
new_deploy = Deploy.last
|
84
84
|
assert_redirected_to stack_deploy_path(@stack, new_deploy)
|
85
85
|
end
|
86
86
|
|
87
87
|
test ":rollback is success" do
|
88
|
-
get :rollback, stack_id: @stack.to_param, id: @deploy.id
|
88
|
+
get :rollback, params: {stack_id: @stack.to_param, id: @deploy.id}
|
89
89
|
assert_response :success
|
90
90
|
end
|
91
91
|
|
92
92
|
test ":rollback shows a warning if a deploy is already running" do
|
93
93
|
shipit_deploys(:shipit_running).update_column(:status, 'running')
|
94
94
|
|
95
|
-
get :rollback, stack_id: @stack.to_param, id: @deploy.id
|
95
|
+
get :rollback, params: {stack_id: @stack.to_param, id: @deploy.id}
|
96
96
|
assert_response :success
|
97
97
|
assert_select '.warning.concurrent-deploy h2' do |elements|
|
98
98
|
assert_equal 'Lando Walrussian is already deploying!', elements.first.text
|
@@ -11,37 +11,37 @@ module Shipit
|
|
11
11
|
|
12
12
|
test ":create persists a new rollback" do
|
13
13
|
assert_difference '@stack.rollbacks.count', 1 do
|
14
|
-
post :create, stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}
|
14
|
+
post :create, params: {stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}}
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
test ":create can receive an :env hash" do
|
19
19
|
env = {'SAFETY_DISABLED' => '1'}
|
20
|
-
post :create, stack_id: @stack.to_param, rollback: {parent_id: @deploy.id, env: env}
|
20
|
+
post :create, params: {stack_id: @stack.to_param, rollback: {parent_id: @deploy.id, env: env}}
|
21
21
|
new_rollback = Rollback.last
|
22
22
|
assert_equal env, new_rollback.env
|
23
23
|
end
|
24
24
|
|
25
25
|
test ":create ignore :env keys not declared in the deploy spec" do
|
26
|
-
post :create, stack_id: @stack.to_param, rollback: {parent_id: @deploy.id, env: {'H4X0R' => '1'}}
|
26
|
+
post :create, params: {stack_id: @stack.to_param, rollback: {parent_id: @deploy.id, env: {'H4X0R' => '1'}}}
|
27
27
|
new_rollback = Rollback.last
|
28
28
|
assert_equal({}, new_rollback.env)
|
29
29
|
end
|
30
30
|
|
31
31
|
test ":create redirects to the new deploy" do
|
32
|
-
post :create, stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}
|
32
|
+
post :create, params: {stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}}
|
33
33
|
assert_redirected_to stack_deploy_path(@stack, Rollback.last)
|
34
34
|
end
|
35
35
|
|
36
36
|
test ":create locks deploys" do
|
37
|
-
post :create, stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}
|
37
|
+
post :create, params: {stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}}
|
38
38
|
assert @stack.reload.locked?
|
39
39
|
end
|
40
40
|
|
41
41
|
test ":create redirects back to the :new page if there is an active deploy" do
|
42
42
|
shipit_deploys(:shipit_running).update_column(:status, 'running')
|
43
43
|
assert_no_difference '@stack.deploys.count' do
|
44
|
-
post :create, stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}
|
44
|
+
post :create, params: {stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}}
|
45
45
|
end
|
46
46
|
assert_redirected_to rollback_stack_deploy_path(@stack, @deploy)
|
47
47
|
end
|
@@ -49,7 +49,7 @@ module Shipit
|
|
49
49
|
test ":create with `force` option ignore the active deploys" do
|
50
50
|
shipit_deploys(:shipit_running).update_column(:status, 'running')
|
51
51
|
assert_difference '@stack.deploys.count', 1 do
|
52
|
-
post :create, stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}, force: true
|
52
|
+
post :create, params: {stack_id: @stack.to_param, rollback: {parent_id: @deploy.id}, force: 'true'}
|
53
53
|
end
|
54
54
|
assert_redirected_to stack_deploy_path(@stack, Rollback.last)
|
55
55
|
end
|