Skip to content

Commit

Permalink
Merge pull request #14105 from yrudman/do-not-truncate-message-attrib…
Browse files Browse the repository at this point in the history
…ute-in-miq-tasks-table

Do not truncate(255) message attribute in miq_tasks table
  • Loading branch information
Fryguy authored Mar 1, 2017
2 parents 5336cc4 + 9bea373 commit aa01358
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/models/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def attributes_for_task
{:status => status.try(:capitalize),
:state => state.try(:capitalize),
:name => name,
:message => message.try(:truncate, 255),
:message => message,
:userid => userid,
:miq_server_id => miq_server_id,
:context_data => context,
Expand Down
6 changes: 3 additions & 3 deletions app/models/miq_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def check_associations
def update_status(state, status, message)
status = STATUS_ERROR if status == STATUS_EXPIRED
_log.info("Task: [#{id}] [#{state}] [#{status}] [#{message}]")
attributes = {:state => state, :status => status, :message => message.truncate(255)}
attributes = {:state => state, :status => status, :message => message}
attributes[:started_on] = Time.now.utc if state == STATE_ACTIVE && started_on.nil?
update_attributes!(attributes)
end
Expand All @@ -71,15 +71,15 @@ def self.update_message(taskid, message)

def update_message(message)
_log.info("Task: [#{id}] [#{message}]")
update_attributes!(:message => message.truncate(255))
update_attributes!(:message => message)
end

def update_context(context)
update_attributes!(:context_data => context)
end

def message=(message)
super(message.truncate(255))
super(message)
end

def self.info(taskid, message, pct_complete)
Expand Down
2 changes: 1 addition & 1 deletion spec/models/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
:status => @job.status.try(:capitalize),
:state => @job.state.try(:capitalize),
:name => @job.name,
:message => @job.message.try(:truncate, 255),
:message => @job.message,
:userid => @job.userid,
:miq_server_id => @job.miq_server_id,
:context_data => @job.context,
Expand Down
11 changes: 0 additions & 11 deletions spec/models/miq_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@
expect(@miq_task.message).to eq(message)
end

it "should trim long message to 255" do
message = ("So there I was sitting in a rabbit's suit" * 100).freeze
@miq_task.message = message
expect(@miq_task.message.length).to eq(255)
expect(@miq_task.message[252, 3]).to eq("...")

@miq_task.update_attributes(:message => message)
expect(@miq_task.message.length).to eq(255)
expect(@miq_task.message[252, 3]).to eq("...")
end

it "should update context upon request" do
context = {:a => 1, :b => 2}
@miq_task.update_context(context)
Expand Down

0 comments on commit aa01358

Please sign in to comment.