From 049daeb0b314bcd7579490c1363470d2e3593c97 Mon Sep 17 00:00:00 2001 From: Ashton South Date: Tue, 26 Nov 2024 09:29:54 -0500 Subject: [PATCH] Change "script" to "launcher" in variables (#3976) Change "script" to "launcher" in variables, method names and localization keys. --- .../app/controllers/launchers_controller.rb | 66 +++++------ .../app/controllers/projects_controller.rb | 4 +- apps/dashboard/app/models/launcher.rb | 34 +++--- apps/dashboard/app/models/project.rb | 10 +- .../app/views/launchers/edit.html.erb | 8 +- .../_edit_fixed_field.html.erb | 2 +- .../app/views/launchers/new.html.erb | 2 +- .../app/views/launchers/show.html.erb | 6 +- .../views/projects/_launcher_buttons.html.erb | 2 +- .../app/views/projects/show.html.erb | 2 +- apps/dashboard/config/locales/en.yml | 16 +-- .../test/system/project_manager_test.rb | 110 +++++++++--------- 12 files changed, 131 insertions(+), 131 deletions(-) diff --git a/apps/dashboard/app/controllers/launchers_controller.rb b/apps/dashboard/app/controllers/launchers_controller.rb index 51d9f3575b..750b3fa19a 100644 --- a/apps/dashboard/app/controllers/launchers_controller.rb +++ b/apps/dashboard/app/controllers/launchers_controller.rb @@ -4,9 +4,9 @@ class LaunchersController < ApplicationController before_action :find_project - before_action :find_script, only: [:show, :edit, :destroy, :submit, :save] + before_action :find_launcher, only: [:show, :edit, :destroy, :submit, :save] - SAVE_SCRIPT_KEYS = [ + SAVE_LAUNCHER_KEYS = [ :cluster, :auto_accounts, :auto_accounts_exclude, :auto_accounts_fixed, :auto_cores, :auto_cores_fixed, :auto_cores_min, :auto_cores_max, :auto_scripts, :auto_scripts_exclude, :auto_scripts_fixed, @@ -19,21 +19,21 @@ class LaunchersController < ApplicationController ].freeze def new - @script = Launcher.new(project_dir: @project.directory) + @launcher = Launcher.new(project_dir: @project.directory) end # POST /dashboard/projects/:project_id/launchers def create - opts = { project_dir: @project.directory }.merge(create_script_params[:launcher]) - @script = Launcher.new(opts) - default_script_created = @script.create_default_script + opts = { project_dir: @project.directory }.merge(create_launcher_params[:launcher]) + @launcher = Launcher.new(opts) + default_script_created = @launcher.create_default_script - if @script.save - notice_messages = [I18n.t('dashboard.jobs_scripts_created')] - notice_messages << I18n.t('dashboard.jobs_scripts_default_created') if default_script_created + if @launcher.save + notice_messages = [I18n.t('dashboard.jobs_launchers_created')] + notice_messages << I18n.t('dashboard.jobs_launchers_default_created') if default_script_created redirect_to project_path(params[:project_id]), notice: notice_messages.join(' ') else - redirect_to project_path(params[:project_id]), alert: @script.errors[:save].last + redirect_to project_path(params[:project_id]), alert: @launcher.errors[:save].last end end @@ -44,69 +44,69 @@ def edit # DELETE /projects/:project_id/launchers/:id def destroy - if @script.destroy - redirect_to project_path(params[:project_id]), notice: I18n.t('dashboard.jobs_scripts_deleted') + if @launcher.destroy + redirect_to project_path(params[:project_id]), notice: I18n.t('dashboard.jobs_launchers_deleted') else - redirect_to project_path(params[:project_id]), alert: @script.errors[:destroy].last + redirect_to project_path(params[:project_id]), alert: @launcher.errors[:destroy].last end end # POST /projects/:project_id/launchers/:id/save # save the launcher after editing def save - @script.update(save_script_params[:launcher]) + @launcher.update(save_launcher_params[:launcher]) - if @script.save - redirect_to project_path(params[:project_id]), notice: I18n.t('dashboard.jobs_scripts_updated') + if @launcher.save + redirect_to project_path(params[:project_id]), notice: I18n.t('dashboard.jobs_launchers_updated') else - redirect_to project_path(params[:project_id]), alert: @script.errors[:save].last + redirect_to project_path(params[:project_id]), alert: @launcher.errors[:save].last end end # POST /projects/:project_id/launchers/:id/submit # submit the job def submit - opts = submit_script_params[:launcher].to_h.symbolize_keys + opts = submit_launcher_params[:launcher].to_h.symbolize_keys - if (job_id = @script.submit(opts)) - redirect_to(project_path(params[:project_id]), notice: I18n.t('dashboard.jobs_scripts_submitted', job_id: job_id)) + if (job_id = @launcher.submit(opts)) + redirect_to(project_path(params[:project_id]), notice: I18n.t('dashboard.jobs_launchers_submitted', job_id: job_id)) else - redirect_to(project_path(params[:project_id]), alert: @script.errors[:submit].last) + redirect_to(project_path(params[:project_id]), alert: @launcher.errors[:submit].last) end end private - def find_script - @script = Launcher.find(show_script_params[:id], @project.directory) - redirect_to(project_path(@project.id), alert: "Cannot find script #{show_script_params[:id]}") if @script.nil? + def find_launcher + @launcher = Launcher.find(show_launcher_params[:id], @project.directory) + redirect_to(project_path(@project.id), alert: "Cannot find launcher #{show_launcher_params[:id]}") if @launcher.nil? end - def create_script_params + def create_launcher_params params.permit({ launcher: [:title] }, :project_id) end - def show_script_params + def show_launcher_params params.permit(:id, :project_id) end - def submit_script_params - keys = @script.smart_attributes.map { |sm| sm.id.to_s } + def submit_launcher_params + keys = @launcher.smart_attributes.map { |sm| sm.id.to_s } params.permit({ launcher: keys }, :project_id, :id) end - def save_script_params + def save_launcher_params auto_env_params = params[:launcher].keys.select do |k| k.match?('auto_environment_variable') end - - allowlist = SAVE_SCRIPT_KEYS + auto_env_params + + allowlist = SAVE_LAUNCHER_KEYS + auto_env_params params.permit({ launcher: allowlist }, :project_id, :id) end def find_project - @project = Project.find(show_script_params[:project_id]) - redirect_to(projects_path, alert: "Cannot find project: #{show_script_params[:project_id]}") if @project.nil? + @project = Project.find(show_launcher_params[:project_id]) + redirect_to(projects_path, alert: "Cannot find project: #{show_launcher_params[:project_id]}") if @project.nil? end end diff --git a/apps/dashboard/app/controllers/projects_controller.rb b/apps/dashboard/app/controllers/projects_controller.rb index cb77117e73..d69c9838d3 100644 --- a/apps/dashboard/app/controllers/projects_controller.rb +++ b/apps/dashboard/app/controllers/projects_controller.rb @@ -13,13 +13,13 @@ def show format.json { render json: { message: message }, status: :not_found } end else - @scripts = Launcher.all(@project.directory) + @launchers = Launcher.all(@project.directory) @valid_project = Launcher.clusters? @valid_scripts = Launcher.scripts?(@project.directory) alert_messages = [] alert_messages << I18n.t('dashboard.jobs_project_invalid_configuration_clusters') unless @valid_project - alert_messages << I18n.t('dashboard.jobs_project_invalid_configuration_scripts') if @scripts.any? && !@valid_scripts + alert_messages << I18n.t('dashboard.jobs_project_invalid_configuration_scripts') if @launchers.any? && !@valid_scripts flash.now[:alert] = alert_messages.join(' ') if alert_messages.any? respond_to do |format| format.html diff --git a/apps/dashboard/app/models/launcher.rb b/apps/dashboard/app/models/launcher.rb index c433199238..e06f3d7787 100644 --- a/apps/dashboard/app/models/launcher.rb +++ b/apps/dashboard/app/models/launcher.rb @@ -14,8 +14,8 @@ def launchers_dir(project_dir) end def find(id, project_dir) - script_path = Launcher.script_path(project_dir, id) - file = script_form_file(script_path) + path = Launcher.path(project_dir, id) + file = launcher_form_file(path) Launcher.from_yaml(file, project_dir) end @@ -37,7 +37,7 @@ def from_yaml(file, project_dir) new(opts) rescue StandardError, Errno::ENOENT => e - Rails.logger.warn("Did not find script due to error #{e}") + Rails.logger.warn("Did not find launcher due to error #{e}") nil end @@ -149,26 +149,26 @@ def save return false unless valid?(:save) @created_at = Time.now.to_i if @created_at.nil? - script_path = Launcher.script_path(project_dir, id) + path = Launcher.path(project_dir, id) - script_path.mkpath unless script_path.exist? - File.write(Launcher.script_form_file(script_path), to_yaml) + path.mkpath unless path.exist? + File.write(Launcher.launcher_form_file(path), to_yaml) true rescue StandardError => e errors.add(:save, e.message) - Rails.logger.warn("Cannot save script due to error: #{e.class}:#{e.message}") + Rails.logger.warn("Cannot save launcher due to error: #{e.class}:#{e.message}") false end def destroy return true unless id - script_path = Launcher.script_path(project_dir, id) - FileUtils.remove_dir(Launcher.script_path(project_dir, id)) if script_path.exist? + path = Launcher.path(project_dir, id) + FileUtils.remove_dir(Launcher.path(project_dir, id)) if path.exist? true rescue StandardError => e errors.add(:destroy, e.message) - Rails.logger.warn("Cannot delete script #{id} due to error: #{e.class}:#{e.message}") + Rails.logger.warn("Cannot delete launcher #{id} due to error: #{e.class}:#{e.message}") false end @@ -221,20 +221,20 @@ def create_default_script private - def self.script_path(root_dir, script_id) - unless script_id.to_s.match?(ID_REX) - raise(StandardError, "#{script_id} is invalid. Does not match #{ID_REX.inspect}") + def self.path(root_dir, launcher_id) + unless launcher_id.to_s.match?(ID_REX) + raise(StandardError, "#{launcher_id} is invalid. Does not match #{ID_REX.inspect}") end - Pathname.new(File.join(Launcher.launchers_dir(root_dir), script_id.to_s)) + Pathname.new(File.join(Launcher.launchers_dir(root_dir), launcher_id.to_s)) end def default_script_path Pathname(File.join(project_dir, 'hello_world.sh')) end - def self.script_form_file(script_path) - File.join(script_path, "form.yml") + def self.launcher_form_file(path) + File.join(path, "form.yml") end # parameters you got from the controller that affect the attributes, not form. @@ -284,7 +284,7 @@ def write_job_options_to_cache(opts) end def cache_file_path - Pathname.new(File.join(Launcher.script_path(project_dir, id), "cache.json")) + Pathname.new(File.join(Launcher.path(project_dir, id), "cache.json")) end def cache_file_exists? diff --git a/apps/dashboard/app/models/project.rb b/apps/dashboard/app/models/project.rb index be2522091b..9a7c39429e 100644 --- a/apps/dashboard/app/models/project.rb +++ b/apps/dashboard/app/models/project.rb @@ -271,11 +271,11 @@ def sync_template # This creates them _and_ serializes them to yml in the new directory. def save_new_launchers dir = Launcher.launchers_dir(template) - Dir.glob("#{dir}/*/form.yml").map do |script_yml| - Launcher.from_yaml(script_yml, project_dataroot) - end.map do |script| - saved_successfully = script.save - errors.add(:save, script.errors.full_messages) unless saved_successfully + Dir.glob("#{dir}/*/form.yml").map do |launcher_yml| + Launcher.from_yaml(launcher_yml, project_dataroot) + end.map do |launcher| + saved_successfully = launcher.save + errors.add(:save, launcher.errors.full_messages) unless saved_successfully saved_successfully end.all? do |saved_successfully| diff --git a/apps/dashboard/app/views/launchers/edit.html.erb b/apps/dashboard/app/views/launchers/edit.html.erb index 25d79fb6fe..35b8bf0052 100644 --- a/apps/dashboard/app/views/launchers/edit.html.erb +++ b/apps/dashboard/app/views/launchers/edit.html.erb @@ -1,11 +1,11 @@ -

Editing <%= @script.title %>

+

Editing <%= @launcher.title %>

<%= javascript_include_tag 'launcher_edit', nonce: true %> <%= link_to 'Back', project_path(params[:project_id]), class: 'btn btn-default my-3', title: 'Return to projects page' %> -<%= bootstrap_form_for(@script, url: save_project_launcher_path, html: { autocomplete: "off" }) do |f| %> - <% @script.smart_attributes.each do |attrib| %> +<%= bootstrap_form_for(@launcher, url: save_project_launcher_path, html: { autocomplete: "off" }) do |f| %> + <% @launcher.smart_attributes.each do |attrib| %> <%# TODO generate render_format %> <%= create_editable_widget(f, attrib, format: nil) %> <% end %> @@ -13,7 +13,7 @@ <%= render partial: 'add_new_field' %>
- <%= f.submit t('dashboard.save'), class: 'btn btn-primary', id: 'save_script_edit' %> + <%= f.submit t('dashboard.save'), class: 'btn btn-primary', id: 'save_launcher_edit' %>
<% end %> diff --git a/apps/dashboard/app/views/launchers/editable_form_fields/_edit_fixed_field.html.erb b/apps/dashboard/app/views/launchers/editable_form_fields/_edit_fixed_field.html.erb index a2670ec631..13d8caa940 100644 --- a/apps/dashboard/app/views/launchers/editable_form_fields/_edit_fixed_field.html.erb +++ b/apps/dashboard/app/views/launchers/editable_form_fields/_edit_fixed_field.html.erb @@ -7,6 +7,6 @@
data-fixed-toggler="<%= field_id %>"> - +
diff --git a/apps/dashboard/app/views/launchers/new.html.erb b/apps/dashboard/app/views/launchers/new.html.erb index b82f8dad2c..cda5dbafed 100644 --- a/apps/dashboard/app/views/launchers/new.html.erb +++ b/apps/dashboard/app/views/launchers/new.html.erb @@ -1,5 +1,5 @@ -<%= bootstrap_form_for(@script, url: project_launchers_path) do |form| %> +<%= bootstrap_form_for(@launcher, url: project_launchers_path) do |form| %>
<%= form.text_field :title, label: "Name" %> diff --git a/apps/dashboard/app/views/launchers/show.html.erb b/apps/dashboard/app/views/launchers/show.html.erb index 72ea8b8a9a..d565eec3de 100644 --- a/apps/dashboard/app/views/launchers/show.html.erb +++ b/apps/dashboard/app/views/launchers/show.html.erb @@ -1,12 +1,12 @@ -

<%= @script.title %>

+

<%= @launcher.title %>

<%= javascript_include_tag 'script_show', nonce: true %> <%= link_to 'Back', project_path(params[:project_id]), class: 'btn btn-default my-3', title: 'Return to projects page' %> -<%= bootstrap_form_for(@script, url: submit_project_launcher_path) do |f| %> - <% @script.smart_attributes.each do |attrib| %> +<%= bootstrap_form_for(@launcher, url: submit_project_launcher_path) do |f| %> + <% @launcher.smart_attributes.each do |attrib| %> <%# TODO generate render_format %> <%= create_widget(f, attrib, format: nil) %> <% end %> diff --git a/apps/dashboard/app/views/projects/_launcher_buttons.html.erb b/apps/dashboard/app/views/projects/_launcher_buttons.html.erb index 380bf89db6..f756298b5a 100644 --- a/apps/dashboard/app/views/projects/_launcher_buttons.html.erb +++ b/apps/dashboard/app/views/projects/_launcher_buttons.html.erb @@ -50,7 +50,7 @@ id: "delete_#{launcher.id}", class: "btn btn-danger launcher-button", title: delete_title, - data: { confirm: I18n.t('dashboard.jobs_scripts_delete_script_confirmation') }, + data: { confirm: I18n.t('dashboard.jobs_launchers_delete_script_confirmation') }, method: :delete) do %> <%= I18n.t('dashboard.delete') %> diff --git a/apps/dashboard/app/views/projects/show.html.erb b/apps/dashboard/app/views/projects/show.html.erb index 29d1522dc9..1ee5d2fe37 100644 --- a/apps/dashboard/app/views/projects/show.html.erb +++ b/apps/dashboard/app/views/projects/show.html.erb @@ -40,7 +40,7 @@
- <%- @scripts.each do |launcher| -%> + <%- @launchers.each do |launcher| -%>
diff --git a/apps/dashboard/config/locales/en.yml b/apps/dashboard/config/locales/en.yml index cbe6599f2f..d1ade2a844 100644 --- a/apps/dashboard/config/locales/en.yml +++ b/apps/dashboard/config/locales/en.yml @@ -253,14 +253,14 @@ en: jobs_project_job_deleted: "Successfully deleted job %{job_id}" jobs_project_job_not_deleted: "Cannot delete job %{job_id}" - jobs_scripts_created: "Script successfully created!" - jobs_scripts_default_created: "A 'hello_world.sh' was also added to this project." - jobs_scripts_updated: "Script manifest updated!" - jobs_scripts_not_found: "Cannot find script %{script_id}" - jobs_scripts_deleted: "Script successfully deleted!" - jobs_scripts_submitted: "Successfully submitted job %{job_id}." - jobs_scripts_delete_script_confirmation: "Delete all contents of script?" - jobs_scripts_fixed_field: "Fixed Value" + jobs_launchers_created: "Launcher successfully created!" + jobs_launchers_default_created: "A 'hello_world.sh' was also added to this project." + jobs_launchers_updated: "Launcher manifest updated!" + jobs_launchers_not_found: "Cannot find Launcher %{launcher_id}" + jobs_launchers_deleted: "Launcher successfully deleted!" + jobs_launchers_submitted: "Successfully submitted job %{job_id}." + jobs_launchers_delete_script_confirmation: "Delete all contents of launcher?" + jobs_launchers_fixed_field: "Fixed Value" settings_updated: "Settings updated" settings_invalid_request: "Invalid settings submitted" diff --git a/apps/dashboard/test/system/project_manager_test.rb b/apps/dashboard/test/system/project_manager_test.rb index ed7f29d649..296decab31 100644 --- a/apps/dashboard/test/system/project_manager_test.rb +++ b/apps/dashboard/test/system/project_manager_test.rb @@ -41,14 +41,14 @@ def setup_project(root_dir, override_project_dir = nil) project_id end - def setup_script(project_id) + def setup_launcher(project_id) visit project_path(project_id) click_on 'New Launcher' - find('#launcher_title').set('the script title') + find('#launcher_title').set('the launcher title') click_on 'Save' - script_element = all('#launcher_list div.list-group-item').first - script_element[:id].gsub('launcher_', '') + launcher_element = all('#launcher_list div.list-group-item').first + launcher_element[:id].gsub('launcher_', '') end def add_account(project_id, launcher_id, save: true) @@ -221,14 +221,14 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) # TODO end - test 'creating and showing scripts' do + test 'creating and showing launchers' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) expected_yml = <<~HEREDOC --- - title: the script title + title: the launcher title created_at: #{@expected_now} form: - auto_batch_clusters @@ -257,13 +257,13 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) required: false HEREDOC - success_message = I18n.t('dashboard.jobs_scripts_created') + success_message = I18n.t('dashboard.jobs_launchers_created') assert_selector('.alert-success', text: "Close\n#{success_message}") assert_equal(expected_yml, File.read("#{dir}/projects/#{project_id}/.ondemand/launchers/#{launcher_id}/form.yml")) launcher_path = project_launcher_path(project_id, launcher_id) find("[href='#{launcher_path}'].btn-info").click - assert_selector('h1', text: 'the script title', count: 1) + assert_selector('h1', text: 'the launcher title', count: 1) end end @@ -271,12 +271,12 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) Dir.mktmpdir do |dir| Configuration.stubs(:launcher_default_items).returns(['bc_num_hours']) project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) # note that bc_num_hours is in this YAML. expected_yml = <<~HEREDOC --- - title: the script title + title: the launcher title created_at: #{@expected_now} form: - auto_batch_clusters @@ -312,22 +312,22 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) required: true HEREDOC - success_message = I18n.t('dashboard.jobs_scripts_created') + success_message = I18n.t('dashboard.jobs_launchers_created') assert_selector('.alert-success', text: "Close\n#{success_message}") assert_equal(expected_yml, File.read("#{dir}/projects/#{project_id}/.ondemand/launchers/#{launcher_id}/form.yml")) end end - test 'showing scripts with auto attributes' do + test 'showing launchers with auto attributes' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) project_dir = File.join(dir, 'projects', project_id) add_account(project_id, launcher_id) launcher_path = project_launcher_path(project_id, launcher_id) find("[href='#{launcher_path}'].btn-info").click - assert_selector('h1', text: 'the script title', count: 1) + assert_selector('h1', text: 'the launcher title', count: 1) expected_accounts = ['pas1604', 'pas1754', 'pas1871', 'pas2051', 'pde0006', 'pzs0714', 'pzs0715', 'pzs1010', 'pzs1117', 'pzs1118', 'pzs1124'].to_set @@ -341,10 +341,10 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) end end - test 'deleting a script that succeeds' do + test 'deleting a launcher that succeeds' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) project_dir = File.join(dir, 'projects', project_id) ondemand_dir = File.join(project_dir, '.ondemand') launcher_dir = File.join(ondemand_dir, 'launchers', launcher_id) @@ -362,7 +362,7 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) find("#delete_#{launcher_id}").click end - assert_selector '.alert-success', text: 'Script successfully deleted!' + assert_selector '.alert-success', text: 'Launcher successfully deleted!' # ASSERT SCRIPT DIRECTORY IS DELETED assert_not File.directory? launcher_dir end @@ -371,14 +371,14 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) test 'submitting a script with auto attributes that succeeds' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) project_dir = File.join(dir, 'projects', project_id) ondemand_dir = File.join(project_dir, '.ondemand') add_account(project_id, launcher_id) launcher_path = project_launcher_path(project_id, launcher_id) find("[href='#{launcher_path}'].btn-info").click - assert_selector('h1', text: 'the script title', count: 1) + assert_selector('h1', text: 'the launcher title', count: 1) # assert defaults assert_equal 'oakley', find('#launcher_auto_batch_clusters').value @@ -412,7 +412,7 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) test 'submitting a script with job name' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) project_dir = File.join(dir, 'projects', project_id) ondemand_dir = File.join(project_dir, '.ondemand') add_account(project_id, launcher_id, save: false) @@ -425,7 +425,7 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) launcher_path = project_launcher_path(project_id, launcher_id) find("[href='#{launcher_path}'].btn-info").click - assert_selector('h1', text: 'the script title', count: 1) + assert_selector('h1', text: 'the launcher title', count: 1) # assert defaults assert_equal 'oakley', find('#launcher_auto_batch_clusters').value @@ -460,14 +460,14 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) test 'submitting a script with auto attributes that fails' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) project_dir = File.join(dir, 'projects', project_id) ondemand_dir = File.join(project_dir, '.ondemand') add_account(project_id, launcher_id) launcher_path = project_launcher_path(project_id, launcher_id) find("[href='#{launcher_path}'].btn-info").click - assert_selector('h1', text: 'the script title', count: 1) + assert_selector('h1', text: 'the launcher title', count: 1) # assert defaults assert_equal 'oakley', find('#launcher_auto_batch_clusters').value @@ -491,10 +491,10 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) end end - test 'editing scripts initializes correctly' do + test 'editing launchers initializes correctly' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) visit project_path(project_id) @@ -514,10 +514,10 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) end end - test 'adding new fields to scripts' do + test 'adding new fields to launchers' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) visit project_path(project_id) @@ -535,8 +535,8 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) # add bc_num_hours add_bc_num_hours(project_id, launcher_id) - script_edit_path = edit_project_launcher_path(project_id, launcher_id) - find("[href='#{script_edit_path}']").click + launcher_edit_path = edit_project_launcher_path(project_id, launcher_id) + find("[href='#{launcher_edit_path}']").click # now shows 'cluster', 'auto_scripts' & the newly added'bc_num_hours' assert_equal 3, page.all('.editable-form-field').size @@ -563,14 +563,14 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) # correctly saves click_on(I18n.t('dashboard.save')) - success_message = I18n.t('dashboard.jobs_scripts_updated') + success_message = I18n.t('dashboard.jobs_launchers_updated') assert_selector('.alert-success', text: "Close\n#{success_message}") assert_current_path project_path(project_id) # note that bc_num_hours has default, min & max expected_yml = <<~HEREDOC --- - title: the script title + title: the launcher title created_at: #{@expected_now} form: - auto_scripts @@ -621,10 +621,10 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) end end - test 'removing script fields' do + test 'removing launcher fields' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) # add bc_num_hours add_bc_num_hours(project_id, launcher_id) @@ -654,13 +654,13 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) # correctly saves click_on(I18n.t('dashboard.save')) - success_message = I18n.t('dashboard.jobs_scripts_updated') + success_message = I18n.t('dashboard.jobs_launchers_updated') assert_selector('.alert-success', text: "Close\n#{success_message}") assert_current_path project_path(project_id) expected_yml = <<~HEREDOC --- - title: the script title + title: the launcher title created_at: #{@expected_now} form: - auto_accounts @@ -725,52 +725,52 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) assert_selector('.alert-danger', text: 'Cannot find project 1') end - test 'cant create script when project is invalid' do + test 'cant create launcher when project is invalid' do visit edit_project_launcher_path('1', '1') assert_current_path('/projects') assert_selector('.alert-danger', text: "Close\nCannot find project: 1") end - test 'cant show script when project is invalid' do + test 'cant show launcher when project is invalid' do visit project_launcher_path('1', '1') assert_current_path('/projects') assert_selector('.alert-danger', text: "Close\nCannot find project: 1") end - test 'cant edit script when project is invalid' do + test 'cant edit launcher when project is invalid' do visit edit_project_launcher_path('1', '1') assert_current_path('/projects') assert_selector('.alert-danger', text: "Close\nCannot find project: 1") end - test 'cant show invalid script' do + test 'cant show invalid launcher' do Dir.mktmpdir do |dir| project_id = setup_project(dir) visit project_launcher_path(project_id, '12345678') assert_current_path("/projects/#{project_id}") - assert_selector('.alert-danger', text: "Close\nCannot find script 12345678") + assert_selector('.alert-danger', text: "Close\nCannot find launcher 12345678") end end - test 'cant edit invalid script' do + test 'cant edit invalid launcher' do Dir.mktmpdir do |dir| project_id = setup_project(dir) visit edit_project_launcher_path(project_id, '12345678') assert_current_path("/projects/#{project_id}") - assert_selector('.alert-danger', text: "Close\nCannot find script 12345678") + assert_selector('.alert-danger', text: "Close\nCannot find launcher 12345678") end end # this test: - # creates a project & script with auto_accounts - # excludes some of the accounts from auto_accounts in script#edit - # asserts that they've actually been removed from script#show - # adds some of the accounts back in script#edit - # asserts that the _new_ list of excluded accounts have actually been removed from script#show + # creates a project & launcher with auto_accounts + # excludes some of the accounts from auto_accounts in launcher#edit + # asserts that they've actually been removed from launcher#show + # adds some of the accounts back in launcher#edit + # asserts that the _new_ list of excluded accounts have actually been removed from launcher#show test 'excluding and including select options' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) add_account(project_id, launcher_id) visit edit_project_launcher_path(project_id, launcher_id) @@ -791,12 +791,12 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) assert_equal('false', add_btn[:disabled]) end - find('#save_script_edit').click + find('#save_launcher_edit').click assert_current_path(project_path(project_id)) launcher_path = project_launcher_path(project_id, launcher_id) find("[href='#{launcher_path}'].btn-info").click - # now let's check scripts#show to see if they've actually been excluded. + # now let's check launchers#show to see if they've actually been excluded. show_account_options = page.all('#launcher_auto_accounts option').map(&:value) exclude_accounts.each do |acct| assert(!show_account_options.include?(acct)) @@ -819,12 +819,12 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) assert_equal('false', rm_btn[:disabled]) end - find('#save_script_edit').click + find('#save_launcher_edit').click assert_current_path(project_path(project_id)) launcher_path = project_launcher_path(project_id, launcher_id) find("[href='#{launcher_path}'].btn-info").click - # now let's check scripts#show and they should be back. + # now let's check launchers#show and they should be back. show_account_options = page.all('#launcher_auto_accounts option').map(&:value) exclude_accounts.each do |acct| assert(show_account_options.include?(acct)) @@ -835,7 +835,7 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) test 'fixing select options' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) add_account(project_id, launcher_id) visit edit_project_launcher_path(project_id, launcher_id) @@ -866,7 +866,7 @@ def add_auto_environment_variable(project_id, launcher_id, save: true) test 'excluding newly created options' do Dir.mktmpdir do |dir| project_id = setup_project(dir) - launcher_id = setup_script(project_id) + launcher_id = setup_launcher(project_id) visit(edit_project_launcher_path(project_id, launcher_id)) # now add 'auto_accounts'