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..6a37d452893 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 + create_a_report_with_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 /\/assets\/Ansible-[0-9a-f]+\.png/, parsed['reports'][0]['origin']['src'] + end + + test 'Puppet origin and icon are identified' do + create_a_report_with_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 /\/assets\/Puppet-[0-9a-f]+\.png/, parsed['reports'][0]['origin']['src'] + end + + test 'Salt origin and icon are identified' do + create_a_report_with_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 /\/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' @@ -114,4 +141,10 @@ def test_destroy def create_a_report @report = ConfigReport.import(read_json_fixture('reports/empty.json')) end + + def create_a_report_with_origin(origin) + report = FactoryBot.create(:config_report) + report.origin = origin + report.save! + end end