Skip to content

Commit

Permalink
Expose multi-CV feature downstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Nov 4, 2024
1 parent 6d995cc commit 1e34872
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/models/concerns/setting_branding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def replace_keywords(keyword)
end

def [](name)
if UpstreamOnlySettings::SETTINGS.include?(name.to_s)
if UpstreamOnlySettings.include?(name.to_s)
Rails.logger.debug "Setting '#{name}' is not available in Satellite; ignoring"
return nil
end
Expand Down
11 changes: 9 additions & 2 deletions app/models/concerns/upstream_only_settings.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Settings to hide in downstream (will return nil for all values)
module UpstreamOnlySettings
class UpstreamOnlySettings
SETTINGS = %w[
allow_multiple_content_views
].freeze

def self.include?(key)
new.include?(key)
end

def include?(key)
SETTINGS.include?(key.to_s)
end
end
20 changes: 17 additions & 3 deletions test/unit/setting_registry_branding_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,28 @@ class SettingRegistryBrandingTest < ActiveSupport::TestCase
end

test 'hides upstream-only settings' do
assert_nil Setting['allow_multiple_content_views']
Foreman::SettingManager.define('test2') do
category(:Content) do
setting(
:test_setting,
description: N_("Upstream-only setting test"),
default: 'definitely not falsey',
full_name: N_('Upstream-only setting test'),
type: :string
)
end
end
Foreman.settings.load
UpstreamOnlySettings.expects(:include?).with('test_setting').returns(true)
assert_nil Setting['test_setting']
end
end
end

class SettingBrandingTest < ActiveSupport::TestCase
test 'replaces warning for upstream-only settings' do
Rails.logger.expects(:debug).with('Setting \'allow_multiple_content_views\' is not available in Satellite; ignoring')
Setting['allow_multiple_content_views']
UpstreamOnlySettings.expects(:include?).with('test_setting').returns(true)
Rails.logger.expects(:debug).with('Setting \'test_setting\' is not available in Satellite; ignoring')
Setting['test_setting']
end
end

0 comments on commit 1e34872

Please sign in to comment.