Project

General

Profile

Bug #25367

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

Added by Martin Bacovsky about 2 months ago. Updated 14 days ago.

Status:
Closed
Priority:
High
Category:
Reporting
Target version:
-
Difficulty:
Triaged:
Yes
Bugzilla link:
Team Backlog:
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

Associated revisions

Revision 3315a292 (diff)
Added by Martin Bacovsky about 1 month ago

Fixes #25367 - Create new object when cloning the report template

History

#1 Updated by The Foreman Bot about 2 months ago

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

#2 Updated by Marek Hulán about 1 month ago

  • Fixed in Releases 1.20.0 added

#3 Updated by Tomer Brisker about 1 month ago

  • Category changed from API to Reporting

#4 Updated by Martin Bacovsky about 1 month ago

  • Status changed from Ready For Testing to Closed

#5 Updated by Tomer Brisker 14 days ago

  • Target version deleted (1.20.1)

Also available in: Atom PDF