From d291b215eaa24b76743e45e45f85167437ec13cb Mon Sep 17 00:00:00 2001 From: osc-bot <78549874+osc-bot@users.noreply.github.com> Date: Thu, 16 Nov 2023 08:15:31 -0500 Subject: [PATCH] lint a random file (#3191) --- .../models/configuration_singleton_test.rb | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/apps/myjobs/test/models/configuration_singleton_test.rb b/apps/myjobs/test/models/configuration_singleton_test.rb index f8b48b798f..9a083408b5 100644 --- a/apps/myjobs/test/models/configuration_singleton_test.rb +++ b/apps/myjobs/test/models/configuration_singleton_test.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'test_helper' # FIXME: move to system directory for system tests class ConfigurationSingletonTest < ActiveSupport::TestCase - #FIXME: this approach is ugly and difficult to follow + # FIXME: this approach is ugly and difficult to follow # # Marshaling the Configuration doesn't work because the methods are evaluated when # you call them: Configuration doesn't store data for most of its options. @@ -31,7 +33,7 @@ def runner(code, env: 'development', envvars: '') # # @return [OpenStruct] attrs have values set in Configuration after initialization def config_via_runner(env: 'development', envvars: '') - code = %q(puts Marshal.dump( + code = 'puts Marshal.dump( OpenStruct.new( dataroot: Configuration.dataroot, production_database_path: Configuration.production_database_path, @@ -39,64 +41,66 @@ def config_via_runner(env: 'development', envvars: '') show_job_options_account_field: Configuration.show_job_options_account_field? ) ) - ) + ' Marshal.load(runner(code, env: env, envvars: envvars)) end - test "tests should not be run with .env.local* files in directory" do - assert Dir.glob(".env.local{.development,.production,}").none?, "these tests should not be run with a .env.local or .env.local.development or .env.local.production" + test 'tests should not be run with .env.local* files in directory' do + assert Dir.glob('.env.local{.development,.production,}').none?, + 'these tests should not be run with a .env.local or .env.local.development or .env.local.production' end - test "configuration defaults in development env" do + test 'configuration defaults in development env' do config = config_via_runner - assert_equal Rails.root.join("data").to_s, config.dataroot.to_s + assert_equal Rails.root.join('data').to_s, config.dataroot.to_s refute config.load_external_config assert config.show_job_options_account_field end - test "loading custom OSC external config in production env" do - config_root = Rails.root.join('config','examples','osc') + test 'loading custom OSC external config in production env' do + config_root = Rails.root.join('config', 'examples', 'osc') config = config_via_runner(env: 'production', envvars: "OOD_APP_CONFIG_ROOT=#{config_root}") - assert_equal File.expand_path("~/ondemand/data/sys/myjobs"), config.dataroot.to_s - assert_equal File.expand_path("~/ondemand/data/sys/myjobs/production.sqlite3"), config.production_database_path.to_s + assert_equal File.expand_path('~/ondemand/data/sys/myjobs'), config.dataroot.to_s + assert_equal File.expand_path('~/ondemand/data/sys/myjobs/production.sqlite3'), config.production_database_path.to_s assert_equal true, config.load_external_config end - test "loading custom AweSim external config in production env" do - config_root = Rails.root.join('config','examples','awesim') + test 'loading custom AweSim external config in production env' do + config_root = Rails.root.join('config', 'examples', 'awesim') config = config_via_runner(env: 'production', envvars: "OOD_APP_CONFIG_ROOT=#{config_root}") - assert_equal File.expand_path("~/awesim/data/sys/myjobs"), config.dataroot.to_s - assert_equal File.expand_path("~/awesim/data/sys/myjobs/production.sqlite3"), config.production_database_path.to_s + assert_equal File.expand_path('~/awesim/data/sys/myjobs'), config.dataroot.to_s + assert_equal File.expand_path('~/awesim/data/sys/myjobs/production.sqlite3'), config.production_database_path.to_s assert_equal true, config.load_external_config end - test "setting dataroot and database path" do + test 'setting dataroot and database path' do Bundler.with_unbundled_env do ENV['OOD_DATAROOT'] = nil ENV['RAILS_ENV'] = 'production' # default - assert_equal File.expand_path("~/ondemand/data/sys/myjobs"), ConfigurationSingleton.new.dataroot.to_s - assert_equal File.expand_path("~/ondemand/data/sys/myjobs/production.sqlite3"), ConfigurationSingleton.new.production_database_path.to_s + assert_equal File.expand_path('~/ondemand/data/sys/myjobs'), ConfigurationSingleton.new.dataroot.to_s + assert_equal File.expand_path('~/ondemand/data/sys/myjobs/production.sqlite3'), + ConfigurationSingleton.new.production_database_path.to_s # set to tmp dir - ENV['OOD_DATAROOT'] = "/tmp/myjobs" - assert_equal "/tmp/myjobs", ConfigurationSingleton.new.dataroot.to_s - assert_equal "/tmp/myjobs/production.sqlite3", ConfigurationSingleton.new.production_database_path.to_s + ENV['OOD_DATAROOT'] = '/tmp/myjobs' + assert_equal '/tmp/myjobs', ConfigurationSingleton.new.dataroot.to_s + assert_equal '/tmp/myjobs/production.sqlite3', ConfigurationSingleton.new.production_database_path.to_s # set seprate database path - ENV['DATABASE_PATH'] = "/tmp/db.sqlite3" - assert_equal "/tmp/db.sqlite3", ConfigurationSingleton.new.production_database_path.to_s + ENV['DATABASE_PATH'] = '/tmp/db.sqlite3' + assert_equal '/tmp/db.sqlite3', ConfigurationSingleton.new.production_database_path.to_s - ENV['DATABASE_PATH'] = "~root/db.sqlite3" - assert_equal "/root/db.sqlite3", ConfigurationSingleton.new.production_database_path.to_s + ENV['DATABASE_PATH'] = '~root/db.sqlite3' + assert_equal '/root/db.sqlite3', ConfigurationSingleton.new.production_database_path.to_s end end - test "hide account field" do + test 'hide account field' do Bundler.with_unbundled_env do assert ConfigurationSingleton.new.show_job_options_account_field?