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 1b85e53
Show file tree
Hide file tree
Showing 2 changed files with 34 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
33 changes: 33 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
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'
Expand Down Expand Up @@ -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

0 comments on commit 1b85e53

Please sign in to comment.