From ade8f9d20f6fc96250cdd91e3ddb34e484568943 Mon Sep 17 00:00:00 2001 From: Bastian Schmidt Date: Wed, 4 Oct 2023 11:37:18 +0200 Subject: [PATCH] Fixes #36799 - Add Salt image path to ConfigReportsController --- app/controllers/config_reports_controller.rb | 1 + .../config_reports_controller_test.rb | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/controllers/config_reports_controller.rb b/app/controllers/config_reports_controller.rb index 62f37faf1ef..568d0babbd7 100644 --- a/app/controllers/config_reports_controller.rb +++ b/app/controllers/config_reports_controller.rb @@ -81,6 +81,7 @@ def origin_image_path(report) @origin_image_paths ||= { Ansible: helpers.image_path('Ansible.png'), Puppet: helpers.image_path('Puppet.png'), + Salt: helpers.image_path('Salt.png'), } { src: @origin_image_paths[:"#{report.origin}"], label: report.origin } end diff --git a/test/controllers/config_reports_controller_test.rb b/test/controllers/config_reports_controller_test.rb index 3f8e3dbe713..72b3f9f46b4 100644 --- a/test/controllers/config_reports_controller_test.rb +++ b/test/controllers/config_reports_controller_test.rb @@ -44,6 +44,33 @@ def test_index assert_equal 1, response.body.lines.size end + test 'Ansible origin and icon are identified' do + FactoryBot.create(:config_report, origin: 'Ansible') + get :index, params: {format: :json}, session: set_session_user + parsed = YAML.safe_load(response.body) + assert_response :success + assert_equal 'Ansible', parsed['reports'][0]['origin']['label'] + assert_match %r{/assets/Ansible-[0-9a-f]+.png}, parsed['reports'][0]['origin']['src'] + end + + test 'Puppet origin and icon are identified' do + FactoryBot.create(:config_report, origin: 'Puppet') + get :index, params: {format: :json}, session: set_session_user + parsed = YAML.safe_load(response.body) + assert_response :success + assert_equal 'Puppet', parsed['reports'][0]['origin']['label'] + assert_match %r{/assets/Puppet-[0-9a-f]+.png}, parsed['reports'][0]['origin']['src'] + end + + test 'Salt origin and icon are identified' do + FactoryBot.create(:config_report, origin: 'Salt') + get :index, params: {format: :json}, session: set_session_user + parsed = YAML.safe_load(response.body) + assert_response :success + assert_equal 'Salt', parsed['reports'][0]['origin']['label'] + assert_match %r{/assets/Salt-[0-9a-f]+.png}, parsed['reports'][0]['origin']['src'] + end + def test_show get :show, params: { :id => report.id }, session: set_session_user assert_template 'show'