diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f54a5eac..0da43e40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,6 @@ jobs: fail-fast: false matrix: foreman: - - 3.9-stable - develop uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0 with: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8e6309f4..8974aadd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -84,7 +84,7 @@ Layout/FirstHashElementIndentation: # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit Layout/HashAlignment: Exclude: - - 'lib/foreman_theme_satellite/branded_words.rb' + - 'lib/foreman_theme_satellite/foreman_brand.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -139,7 +139,7 @@ Layout/SpaceAfterComma: Layout/SpaceAroundOperators: Exclude: - 'app/overrides/bootdisk_help_page.rb' - - 'lib/foreman_theme_satellite/branded_words.rb' + - 'lib/foreman_theme_satellite/foreman_brand.rb' - 'lib/foreman_theme_satellite/engine.rb' - 'lib/generators/foreman_theme_satellite/lib/css_compare.rb' @@ -409,7 +409,7 @@ Style/TrailingCommaInHashLiteral: Exclude: - 'app/models/concerns/provisioning.rb' - 'app/services/concerns/setting_registry_branding.rb' - - 'lib/foreman_theme_satellite/branded_words.rb' + - 'lib/foreman_theme_satellite/foreman_brand.rb' - 'lib/foreman_theme_satellite/deprecated_templates.rb' - 'lib/foreman_theme_satellite/documentation.rb' - 'lib/foreman_theme_satellite/engine.rb' diff --git a/README.md b/README.md index 79865095..eb8cb598 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ const SettingName = ({ setting }) => ( In case there is a need to add more terms to be branded **or bypass branding**, it can be done in -[`branded_words.rb`](https://github.com/RedHatSatellite/foreman_theme_satellite/blob/develop/lib/foreman_theme_satellite/branded_words.rb). +[`foreman_brand.rb`](https://github.com/RedHatSatellite/foreman_theme_satellite/blob/develop/lib/foreman_theme_satellite/foreman_brand.rb). This is a dictionary where the key is a [Regular Expression](https://regex101.com/) and the value is a replacement string. diff --git a/app/views/foreman_theme_satellite/_theme_client_side_branding.js.erb b/app/views/foreman_theme_satellite/_theme_client_side_branding.js.erb index 1c83e72a..e417b99a 100644 --- a/app/views/foreman_theme_satellite/_theme_client_side_branding.js.erb +++ b/app/views/foreman_theme_satellite/_theme_client_side_branding.js.erb @@ -1,4 +1,4 @@ -<% require_relative '../../../lib/foreman_theme_satellite/branded_words' %> +<% require_relative '../../../lib/foreman_theme_satellite/foreman_brand' %> var branded_words = [] <% ForemanThemeSatellite::FOREMAN_BRAND.map do |exp, replace| %> diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 00000000..7ba88342 --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,6 @@ +Rails.autoloaders.each do |autoloader| + autoloader.inflector.inflect( + 'foreman_brand' => 'FOREMAN_BRAND', + 'deprecated_templates' => 'DEPRECATED_TEMPLATES' + ) +end diff --git a/config/initializers/zeitwerk.rb b/config/initializers/zeitwerk.rb new file mode 100644 index 00000000..5a525a6f --- /dev/null +++ b/config/initializers/zeitwerk.rb @@ -0,0 +1,4 @@ +Rails.autoloaders.main.ignore( + ForemanThemeSatellite::Engine.root.join('lib/generators'), + ForemanThemeSatellite::Engine.root.join('lib/foreman_theme_satellite/version.rb') +) diff --git a/db/migrate/20181108171732_change_blog_url.rb b/db/migrate/20181108171732_change_blog_url.rb index 85bacf00..ea35110d 100644 --- a/db/migrate/20181108171732_change_blog_url.rb +++ b/db/migrate/20181108171732_change_blog_url.rb @@ -1,4 +1,4 @@ -class ChangeBlogUrl < ActiveRecord::Migration[5.1] +class ChangeBlogURL < ActiveRecord::Migration[5.1] def up if Setting[:rss_url] == 'https://access.redhat.com/blogs/1169563/feed' Setting[:rss_url] = 'https://www.redhat.com/en/rss/blog/channel/red-hat-satellite' diff --git a/lib/foreman_theme_satellite/engine.rb b/lib/foreman_theme_satellite/engine.rb index 7cddb950..f58fa4da 100644 --- a/lib/foreman_theme_satellite/engine.rb +++ b/lib/foreman_theme_satellite/engine.rb @@ -6,21 +6,11 @@ module ForemanThemeSatellite class Engine < ::Rails::Engine engine_name 'foreman_theme_satellite' - - config.eager_load_paths += Dir["#{config.root}/app/overrides"] - config.eager_load_paths += Dir["#{config.root}/app/controllers/concerns"] - config.eager_load_paths += Dir["#{config.root}/app/helpers"] - config.eager_load_paths += Dir["#{config.root}/app/models/concerns"] - config.eager_load_paths += Dir["#{config.root}/app/services/concerns"] - config.eager_load_paths += Dir["#{config.root}/lib/foreman_theme_satellite"] - - initializer 'foreman_theme_satellite.load_default_settings', :before => :load_config_initializers do |app| - SettingRegistry.prepend SettingRegistryBranding - end + config.eager_load_paths += Dir["#{config.root}/lib"] initializer 'foreman_theme_satellite.register_plugin', :before=> :finisher_hook do |app| Foreman::Plugin.register :foreman_theme_satellite do - requires_foreman '>= 3.7.0' + requires_foreman '>= 3.13.0' register_gettext settings do @@ -36,7 +26,7 @@ class Engine < ::Rails::Engine end end - tests_to_skip ({ + tests_to_skip ({ "ComputeResourceTest" => ["friendly provider name"], "RealmIntegrationTest" => ["create new page"], "SmartProxyIntegrationTest" => ["create new page", "index page"], @@ -49,7 +39,7 @@ class Engine < ::Rails::Engine "OrganizationTest" => ["should clone organization with all associations"], "RealmTest" => ["realm can be assigned to locations"], "LocationTest" => ["should clone location with all associations"] - }) + }) extend_rabl_template 'api/v2/home/status', 'api/v2/home/status_extensions' extend_template_helpers ForemanThemeSatellite::RendererMethods @@ -69,19 +59,12 @@ class Engine < ::Rails::Engine end end - initializer 'foreman_theme_satellite.rails_loading_workaround' do - # Without this, in production environment the module gets prepended too - # late and the extensions do not get applied - # the idea is stolen from https://github.com/theforeman/foreman_remote_execution/commit/2efd0a6eccfc19e282f453d5629cf46e729963eb - ProvisioningTemplatesHelper.prepend ProvisioningTemplatesHelperBranding - end - # Include concerns in this config.to_prepare block config.to_prepare do begin + SettingRegistry.prepend SettingRegistryBranding # Include your monkey-patches over here ::ForemanGoogle::GCE.send(:prepend, GCE::ClassMethods) if Foreman::Plugin.installed?("foreman_google") - require 'rss_checker_branding' UINotifications::RssNotificationsChecker.send :prepend, RssCheckerBranding Foreman::Model::Openstack.send :include, Openstack Foreman::Model::Ovirt.send :include, Ovirt diff --git a/lib/foreman_theme_satellite/branded_words.rb b/lib/foreman_theme_satellite/foreman_brand.rb similarity index 100% rename from lib/foreman_theme_satellite/branded_words.rb rename to lib/foreman_theme_satellite/foreman_brand.rb diff --git a/lib/foreman_theme_satellite/replacer_repository.rb b/lib/foreman_theme_satellite/replacer_repository.rb index 7c0bc767..7bf01850 100644 --- a/lib/foreman_theme_satellite/replacer_repository.rb +++ b/lib/foreman_theme_satellite/replacer_repository.rb @@ -1,5 +1,4 @@ require 'fast_gettext' -require_relative 'branded_words' module ForemanThemeSatellite # This repository is a wrapper above other repository, diff --git a/test/link_checker.rb b/test/link_checker.rb index 069ae78b..c74e45f3 100644 --- a/test/link_checker.rb +++ b/test/link_checker.rb @@ -47,7 +47,9 @@ def navigate_path(path, hash = @toc) inner_hash = hash[first] - return inner_hash if rest.empty? + # rubocop:disable Rails/Blank + return inner_hash if rest.nil? || rest.empty? + # rubocop:enable Rails/Blank navigate_path(rest, inner_hash) end