Skip to content

Commit

Permalink
Disabled Does not deploy code
Browse files Browse the repository at this point in the history
  • Loading branch information
sathishavm committed Sep 27, 2018
1 parent 3ad3934 commit 78ff0cc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/controllers/stages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def stage_permitted_params
:email_committers_on_automated_deploy_failure,
:is_template,
:name,
:no_code_deployed,
:no_reference_selection,
:notify_email_address,
:periodical_deploy,
Expand All @@ -142,6 +141,9 @@ def stage_permitted_params
deploy_group_ids: [],
command_ids: []
}
] + Samson::Hooks.fire(:stage_permitted_params).flatten
].tap do |params|
params << :no_code_deployed if current_user.admin?
params << Samson::Hooks.fire(:stage_permitted_params)
end.flatten
end
end
6 changes: 4 additions & 2 deletions app/views/stages/_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
" When selected with '#{no_code_label}' and '#{confirm_label}' is disabled the stage can be directly executed."
%>

<% help = "Bypass " + [("buddy check" if BuddyCheck.enabled?), "release tracking"].compact.to_sentence %>
<%= form.input :no_code_deployed, as: :check_box, label: no_code_label, help: help %>
<% help = "Bypass " + [("buddy check" if BuddyCheck.enabled?), "release tracking"].compact.to_sentence \
+ (", Only global admin can alter." if !current_user.admin?).to_s
%>
<%= form.input :no_code_deployed, as: :check_box, label: no_code_label, help: help, input_html: {disabled: !current_user.admin?} %>

<%= form.input :run_in_parallel, as: :check_box, label: "Can run in parallel", help: "Deploys are not queued. Executed immediately" %>

Expand Down
28 changes: 28 additions & 0 deletions test/controllers/stages_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@
it 'adds no commands by default' do
assigns(:stage).command_ids.must_equal []
end

it 'disabled to alter `does not deploy code`' do
assert_select "#stage_no_code_deployed" do |input|
assert input.attr("disabled").present?
end
end
end

it 'fails for non-existent project' do
Expand Down Expand Up @@ -396,4 +402,26 @@ def clone(method, format, extra = {})
end
end
end

as_an_admin do
describe '#new' do
it 'can alter `does not deploy code`' do
get :new, params: {project_id: subject.project.to_param}
assert_select "#stage_no_code_deployed" do |input|
refute input.attr("disabled").present?
end
end
end

describe '#create' do
subject { assigns(:stage) }
it 'permits `no_code_deployed` as params' do
params = {project_id: projects(:test).to_param, stage: {name: 'test', no_code_deployed: true}}
post :create, params: params
subject.reload
subject.persisted?.must_equal(true)
assert subject.no_code_deployed
end
end
end
end

0 comments on commit 78ff0cc

Please sign in to comment.