From c6a82d3b0da835fbec50f9d522a40bd836ea8fcc Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Mon, 13 Nov 2017 09:32:25 -0500 Subject: [PATCH] Merge pull request #16444 from yrudman/name-of-refresh-task-should-fit-255 Truncate name of refresh task to 255 (cherry picked from commit f74530dd5716da2b8b36701f6e9adfe850b00134) https://bugzilla.redhat.com/show_bug.cgi?id=1513123 --- app/models/ems_refresh.rb | 2 +- spec/models/ems_refresh_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/ems_refresh.rb b/app/models/ems_refresh.rb index cdc084a8d61..af2bc4f31dc 100644 --- a/app/models/ems_refresh.rb +++ b/app/models/ems_refresh.rb @@ -202,7 +202,7 @@ def self.queue_merge(targets, ems, create_task = false) def self.create_refresh_task(ems, targets) task_options = { - :action => "EmsRefresh(#{ems.name}) [#{targets}]", + :action => "EmsRefresh(#{ems.name}) [#{targets}]".truncate(255), :userid => "system" } diff --git a/spec/models/ems_refresh_spec.rb b/spec/models/ems_refresh_spec.rb index 0d7ac91f956..a66223231a4 100644 --- a/spec/models/ems_refresh_spec.rb +++ b/spec/models/ems_refresh_spec.rb @@ -94,6 +94,16 @@ expect(task_ids.length).to eq(2) end end + + describe ".create_refresh_task" do + it "create refresh task and trancates task name to 255 symbols" do + vm = FactoryGirl.create(:vm_vmware, :name => "vm_vmware1", :ext_management_system => @ems) + targets = Array.new(500) { vm } + task_name = described_class.send(:create_refresh_task, @ems, targets).name + expect(task_name.include?(@ems.name)).to eq true + expect(task_name.length).to eq 255 + end + end end def queue_refresh_and_assert_queue_item(target, expected_targets)