Skip to content

Commit

Permalink
Fixes #36799 - Add Salt image path to ConfigReportsController
Browse files Browse the repository at this point in the history
  • Loading branch information
bastian-src committed Oct 5, 2023
1 parent 4e205ba commit 6d3a973
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/config_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions test/controllers/config_reports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,33 @@ def test_index
assert_equal 1, response.body.lines.size
end

test 'Ansible origin and icon are identified' do
report = 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
report = 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
report = 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'
Expand Down

0 comments on commit 6d3a973

Please sign in to comment.