Skip to content

Commit f1d72da

Browse files
adamruzickaadamlazik1
authored andcommitted
Fixes #39148 - Take name from host directly
without taking a detour through asset when building a filename when client tries to download an arf report in html or csv formats. The arf_report-asset association may not exist if the host gets its policy from a hostgroup. Fixes 9b4995a (cherry picked from commit 1545c0a)
1 parent b4a9747 commit f1d72da

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎app/controllers/concerns/foreman_openscap/arf_reports_controller_common_extensions.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module ForemanOpenscap
22
module ArfReportsControllerCommonExtensions
33
extend ActiveSupport::Concern
44
def format_filename
5-
"#{@arf_report.asset.name}-#{@arf_report.reported_at.to_formatted_s(:number)}"
5+
"#{@arf_report.host.name}-#{@arf_report.reported_at.to_formatted_s(:number)}"
66
end
77
end
88
end

‎test/functional/arf_reports_controller_test.rb‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class ArfReportsControllerTest < ActionController::TestCase
3434
arf_report = FactoryBot.create(:arf_report, :host_id => @host.id)
3535
report_html = File.read("#{ForemanOpenscap::Engine.root}/test/files/arf_report/arf_report.html")
3636
ForemanOpenscap::ArfReport.any_instance.stubs(:to_html).returns(report_html)
37+
refute arf_report.asset.nil?
38+
get :download_html, :params => { :id => arf_report.id }, :session => set_session_user
39+
assert_equal report_html, @response.body
40+
41+
arf_report.asset.destroy
3742
get :download_html, :params => { :id => arf_report.id }, :session => set_session_user
3843
assert_equal report_html, @response.body
3944
end

0 commit comments

Comments
 (0)