diff --git a/app/views/shipit/_variables.html.erb b/app/views/shipit/_variables.html.erb index c87397154..a43dd6c93 100644 --- a/app/views/shipit/_variables.html.erb +++ b/app/views/shipit/_variables.html.erb @@ -9,7 +9,7 @@ <% if variable.select %> <%= field.select variable.name, options_for_select([["Please select...", { disabled: "disabled" }]] + variable.select, variable.default || "Please select...") %> <% else %> - <%= field.text_field variable.name, value: variable.default %> + <%= field.text_field variable.name, value: params[variable.name].presence || variable.default %> <% end %> <%= field.label variable.name, variable.title || variable.name %>
diff --git a/test/controllers/tasks_controller_test.rb b/test/controllers/tasks_controller_test.rb index adbd9355c..ff5fc08c2 100644 --- a/test/controllers/tasks_controller_test.rb +++ b/test/controllers/tasks_controller_test.rb @@ -11,9 +11,16 @@ class TasksControllerTest < ActionController::TestCase session[:user_id] = shipit_users(:walrus).id end - test "tasks defined in the shipit.yml can be displayed" do + test "tasks defined in the shipit.yml can be displayed with default variable values" do get :new, params: { stack_id: @stack, definition_id: @definition.id } assert_response :ok + assert_select 'input[name="task[env][FOO]"][value="1"]' + end + + test "it is possible to provide a default value override for a task" do + get :new, params: { stack_id: @stack, definition_id: @definition.id, FOO: '42' } + assert_response :ok + assert_select 'input[name="task[env][FOO]"][value="42"]' end test "tasks defined in the shipit.yml can't be triggered if the stack is being deployed" do