Fix stoppable?

This commit is contained in:
Kamil Trzcinski 2017-02-07 13:30:33 +01:00
parent 1664354c65
commit bc66944248
No known key found for this signature in database
GPG key ID: 4505F5C7E12C6A5A
9 changed files with 18 additions and 18 deletions

View file

@ -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}
*/
isStoppable() {
return this.model['stoppable?'];
hasStopAction() {
return this.model['stop_action?'];
},
/**
@ -508,7 +508,7 @@ require('./environment_terminal_button');
</external-url-component>
</div>
<div v-if="isStoppable && canCreateDeployment"
<div v-if="hasStopAction && canCreateDeployment"
class="inline js-stop-component-container">
<stop-component
:stop-url="model.stop_path">

View file

@ -451,7 +451,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
deployment = environment.first_deployment_for(@merge_request.diff_head_commit)
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)
end

View file

@ -91,7 +91,7 @@ class Deployment < ActiveRecord::Base
@stop_action ||= manual_actions.find_by(name: on_stop)
end
def stoppable?
def stop_action?
stop_action.present?
end

View file

@ -7,7 +7,7 @@ class EnvironmentEntity < Grape::Entity
expose :external_url
expose :environment_type
expose :last_deployment, using: DeploymentEntity
expose :stoppable?
expose :stop_action?
expose :environment_path do |environment|
namespace_project_environment_path(

View file

@ -1,4 +1,4 @@
- if can?(current_user, :create_deployment, environment) && environment.stoppable?
- if can?(current_user, :create_deployment, environment) && environment.stop_action?
.inline
= 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

View file

@ -119,7 +119,7 @@ describe('Environment item', () => {
},
],
},
'stoppable?': true,
'stop_action?': true,
environment_path: 'root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-10T15:55:58.778Z',

View file

@ -50,7 +50,7 @@ const environmentsList = [
},
manual_actions: [],
},
'stoppable?': true,
'stop_action?': true,
environment_path: '/root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-07T11:11:16.525Z',
@ -105,7 +105,7 @@ const environmentsList = [
},
manual_actions: [],
},
'stoppable?': false,
'stop_action?': false,
environment_path: '/root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-07T11:11:16.525Z',
@ -116,7 +116,7 @@ const environmentsList = [
state: 'available',
environment_type: 'review',
last_deployment: null,
'stoppable?': true,
'stop_action?': true,
environment_path: '/root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-07T11:11:16.525Z',
@ -127,7 +127,7 @@ const environmentsList = [
state: 'available',
environment_type: 'review',
last_deployment: null,
'stoppable?': true,
'stop_action?': true,
environment_path: '/root/ci-folders/environments/31',
created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-07T11:11:16.525Z',
@ -143,7 +143,7 @@ const environment = {
external_url: 'http://production.',
environment_type: null,
last_deployment: {},
'stoppable?': false,
'stop_action?': false,
environment_path: '/root/review-app/environments/4',
stop_path: '/root/review-app/environments/4/stop',
created_at: '2016-12-16T11:51:04.690Z',

View file

@ -77,8 +77,8 @@ describe Deployment, models: true do
end
end
describe '#stoppable?' do
subject { deployment.stoppable? }
describe '#stop_action?' do
subject { deployment.stop_action? }
context 'when no other actions' do
let(:deployment) { build(:deployment) }

View file

@ -112,8 +112,8 @@ describe Environment, models: true do
end
end
describe '#stoppable?' do
subject { environment.stoppable? }
describe '#stop_action?' do
subject { environment.stop_action? }
context 'when no other actions' do
it { is_expected.to be_falsey }