Project

General

Profile

Actions

Bug #25367

closed

Report templates clone doesn't create clone but only renames the report

Added by Martin Bacovsky over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
High
Category:
Reporting
Target version:
-
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

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

Actions #1

Updated by The Foreman Bot over 5 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/6197 added
Actions #2

Updated by Marek Hulán over 5 years ago

  • Fixed in Releases 1.20.0 added
Actions #3

Updated by Tomer Brisker over 5 years ago

  • Category changed from API to Reporting
Actions #4

Updated by Martin Bacovsky over 5 years ago

  • Status changed from Ready For Testing to Closed
Actions #5

Updated by Tomer Brisker over 5 years ago

  • Target version deleted (1.20.1)
Actions

Also available in: Atom PDF