Actions
Bug #25367
closedReport templates clone doesn't create clone but only renames the report
Description
While trying to clone the report template via API call it gets only renamed and new record is not added.
[ INFO 2018-11-01T16:24:40 API] POST /api/report_templates/142/clone [DEBUG 2018-11-01T16:24:40 API] Params: { "report_template" => { "name" => "Cloned report" }, "name" => "Cloned report" } [DEBUG 2018-11-01T16:24:40 API] Headers: {} [DEBUG 2018-11-01T16:24:40 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth [DEBUG 2018-11-01T16:24:44 API] Response: { "id" => 142, "name" => "Cloned report", "template" => "<%#\nname: Registered hosts\nsnippet: false\nmodel: ReportTemplate\nrequire:\n - plugin: katello\n version: 3.9.0\n-%>\n<%- load_hosts(search: '', includes: [:operatingsystem,:subscriptions,:fact_values,:fact_names,:applicable_errata,:applicable_rpms]).each_record do |host| -%>\n<%- report_row(\n 'Name': host.name,\n 'Ip': host.ip,\n 'Operating System': host.operatingsystem,\n 'Subscriptions': host_subscriptions(host),\n 'Applicable Errata': host_applicable_errata_ids(host),\n 'Owner': host.owner,\n 'Kernel': host.facts['kernelrelease'],\n 'Latest kernel available': host_latest_applicable_rpm_version(host, 'kernel')\n ) -%>\n<%- end -%>\n<%= report_render -%>", "snippet" => false, "template_kind_id" => nil, "created_at" => "2018-10-09T08:13:05.901Z", "updated_at" => "2018-11-01T15:24:43.904Z", "locked" => false, "default" => false, "vendor" => nil, "os_family" => nil, "job_category" => "Miscellaneous", "provider_type" => nil, "description_format" => nil, "execution_timeout_interval" => nil }
It is caused by using the `clone` method in the controller. Since Rails 4 it seems to behave differently and the `dup` should be used instead.
Some more details can be found in e.g. https://medium.com/@raycent/ruby-clone-vs-dup-8a49b295f29a
Updated by The Foreman Bot over 6 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/6197 added
Updated by Tomer Brisker over 6 years ago
- Category changed from API to Reporting
Updated by Martin Bacovsky over 6 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset 3315a292ea4f7f69ec2c1ea4cb15943f53a832e0.
Actions