Skip to content
Snippets Groups Projects
Unverified Commit bc669442 authored by Kamil Trzcinski's avatar Kamil Trzcinski
Browse files

Fix stoppable?

parent 1664354c
No related branches found
No related tags found
No related merge requests found
Loading
@@ -147,12 +147,12 @@ require('./environment_terminal_button');
Loading
@@ -147,12 +147,12 @@ require('./environment_terminal_button');
}, },
   
/** /**
* Returns the value of the `stoppable?` key provided in the response. * Returns the value of the `stop_action?` key provided in the response.
* *
* @returns {Boolean} * @returns {Boolean}
*/ */
isStoppable() { hasStopAction() {
return this.model['stoppable?']; return this.model['stop_action?'];
}, },
   
/** /**
Loading
@@ -508,7 +508,7 @@ require('./environment_terminal_button');
Loading
@@ -508,7 +508,7 @@ require('./environment_terminal_button');
</external-url-component> </external-url-component>
</div> </div>
   
<div v-if="isStoppable && canCreateDeployment" <div v-if="hasStopAction && canCreateDeployment"
class="inline js-stop-component-container"> class="inline js-stop-component-container">
<stop-component <stop-component
:stop-url="model.stop_path"> :stop-url="model.stop_path">
Loading
Loading
Loading
@@ -451,7 +451,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -451,7 +451,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
deployment = environment.first_deployment_for(@merge_request.diff_head_commit) deployment = environment.first_deployment_for(@merge_request.diff_head_commit)
   
stop_url = stop_url =
if environment.stoppable? && can?(current_user, :create_deployment, environment) if environment.stop_action? && can?(current_user, :create_deployment, environment)
stop_namespace_project_environment_path(project.namespace, project, environment) stop_namespace_project_environment_path(project.namespace, project, environment)
end end
   
Loading
Loading
Loading
@@ -91,7 +91,7 @@ class Deployment < ActiveRecord::Base
Loading
@@ -91,7 +91,7 @@ class Deployment < ActiveRecord::Base
@stop_action ||= manual_actions.find_by(name: on_stop) @stop_action ||= manual_actions.find_by(name: on_stop)
end end
   
def stoppable? def stop_action?
stop_action.present? stop_action.present?
end end
   
Loading
Loading
Loading
@@ -7,7 +7,7 @@ class EnvironmentEntity < Grape::Entity
Loading
@@ -7,7 +7,7 @@ class EnvironmentEntity < Grape::Entity
expose :external_url expose :external_url
expose :environment_type expose :environment_type
expose :last_deployment, using: DeploymentEntity expose :last_deployment, using: DeploymentEntity
expose :stoppable? expose :stop_action?
   
expose :environment_path do |environment| expose :environment_path do |environment|
namespace_project_environment_path( namespace_project_environment_path(
Loading
Loading
- if can?(current_user, :create_deployment, environment) && environment.stoppable? - if can?(current_user, :create_deployment, environment) && environment.stop_action?
.inline .inline
= link_to stop_namespace_project_environment_path(@project.namespace, @project, environment), method: :post, = link_to stop_namespace_project_environment_path(@project.namespace, @project, environment), method: :post,
class: 'btn stop-env-link', rel: 'nofollow', data: { confirm: 'Are you sure you want to stop this environment?' } do class: 'btn stop-env-link', rel: 'nofollow', data: { confirm: 'Are you sure you want to stop this environment?' } do
Loading
Loading
Loading
@@ -119,7 +119,7 @@ describe('Environment item', () => {
Loading
@@ -119,7 +119,7 @@ describe('Environment item', () => {
}, },
], ],
}, },
'stoppable?': true, 'stop_action?': true,
environment_path: 'root/ci-folders/environments/31', environment_path: 'root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z', created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-10T15:55:58.778Z', updated_at: '2016-11-10T15:55:58.778Z',
Loading
Loading
Loading
@@ -50,7 +50,7 @@ const environmentsList = [
Loading
@@ -50,7 +50,7 @@ const environmentsList = [
}, },
manual_actions: [], manual_actions: [],
}, },
'stoppable?': true, 'stop_action?': true,
environment_path: '/root/ci-folders/environments/31', environment_path: '/root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z', created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-07T11:11:16.525Z', updated_at: '2016-11-07T11:11:16.525Z',
Loading
@@ -105,7 +105,7 @@ const environmentsList = [
Loading
@@ -105,7 +105,7 @@ const environmentsList = [
}, },
manual_actions: [], manual_actions: [],
}, },
'stoppable?': false, 'stop_action?': false,
environment_path: '/root/ci-folders/environments/31', environment_path: '/root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z', created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-07T11:11:16.525Z', updated_at: '2016-11-07T11:11:16.525Z',
Loading
@@ -116,7 +116,7 @@ const environmentsList = [
Loading
@@ -116,7 +116,7 @@ const environmentsList = [
state: 'available', state: 'available',
environment_type: 'review', environment_type: 'review',
last_deployment: null, last_deployment: null,
'stoppable?': true, 'stop_action?': true,
environment_path: '/root/ci-folders/environments/31', environment_path: '/root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z', created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-07T11:11:16.525Z', updated_at: '2016-11-07T11:11:16.525Z',
Loading
@@ -127,7 +127,7 @@ const environmentsList = [
Loading
@@ -127,7 +127,7 @@ const environmentsList = [
state: 'available', state: 'available',
environment_type: 'review', environment_type: 'review',
last_deployment: null, last_deployment: null,
'stoppable?': true, 'stop_action?': true,
environment_path: '/root/ci-folders/environments/31', environment_path: '/root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z', created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-07T11:11:16.525Z', updated_at: '2016-11-07T11:11:16.525Z',
Loading
@@ -143,7 +143,7 @@ const environment = {
Loading
@@ -143,7 +143,7 @@ const environment = {
external_url: 'http://production.', external_url: 'http://production.',
environment_type: null, environment_type: null,
last_deployment: {}, last_deployment: {},
'stoppable?': false, 'stop_action?': false,
environment_path: '/root/review-app/environments/4', environment_path: '/root/review-app/environments/4',
stop_path: '/root/review-app/environments/4/stop', stop_path: '/root/review-app/environments/4/stop',
created_at: '2016-12-16T11:51:04.690Z', created_at: '2016-12-16T11:51:04.690Z',
Loading
Loading
Loading
@@ -77,8 +77,8 @@ describe Deployment, models: true do
Loading
@@ -77,8 +77,8 @@ describe Deployment, models: true do
end end
end end
   
describe '#stoppable?' do describe '#stop_action?' do
subject { deployment.stoppable? } subject { deployment.stop_action? }
   
context 'when no other actions' do context 'when no other actions' do
let(:deployment) { build(:deployment) } let(:deployment) { build(:deployment) }
Loading
Loading
Loading
@@ -112,8 +112,8 @@ describe Environment, models: true do
Loading
@@ -112,8 +112,8 @@ describe Environment, models: true do
end end
end end
   
describe '#stoppable?' do describe '#stop_action?' do
subject { environment.stoppable? } subject { environment.stop_action? }
   
context 'when no other actions' do context 'when no other actions' do
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment