diff --git a/config/foreman.migrations/20231005004305_redis_default_cache.rb b/config/foreman.migrations/20231005004305_redis_default_cache.rb new file mode 100644 index 00000000..6ea76bfe --- /dev/null +++ b/config/foreman.migrations/20231005004305_redis_default_cache.rb @@ -0,0 +1,3 @@ +if answers['foreman'].is_a?(Hash) && answers.dig('foreman', 'rails_cache_store', 'type') == 'file' + answers['foreman']['rails_cache_store'] = { 'type' => 'redis' } +end diff --git a/config/katello.migrations/231005004311-redis-default-cache.rb b/config/katello.migrations/231005004311-redis-default-cache.rb new file mode 100644 index 00000000..6ea76bfe --- /dev/null +++ b/config/katello.migrations/231005004311-redis-default-cache.rb @@ -0,0 +1,3 @@ +if answers['foreman'].is_a?(Hash) && answers.dig('foreman', 'rails_cache_store', 'type') == 'file' + answers['foreman']['rails_cache_store'] = { 'type' => 'redis' } +end diff --git a/spec/migration_spec.rb b/spec/migration_spec.rb index ed961924..313e829a 100644 --- a/spec/migration_spec.rb +++ b/spec/migration_spec.rb @@ -123,3 +123,21 @@ end end end + +migration '20231005004305_redis_default_cache' do + scenarios %w[foreman katello] do + context 'changes default cache to Redis' do + let(:answers) do + { + 'foreman' => { + 'rails_cache_store' => { 'type' => 'file' }, + }, + } + end + + it 'changes the default to Redis' do + expect(migrated_answers['foreman']['rails_cache_store']).to eq({ 'type' => 'redis' }) + end + end + end +end