From 4fc0e8d55d5830920f0570f76af50229974ab2db Mon Sep 17 00:00:00 2001 From: Rene Martin Date: Sun, 11 Sep 2016 22:33:42 +0100 Subject: [PATCH] Bug updating the resource after a save If the attribute to update is a hash and it is nill, then the wrong attributes are being updated. I found this bug while I was updating the assignee in an issue without assignee. In that case, with this code: issue.save!('fields' => { 'assignee' => user.attrs }) if issue.assignee.nil? in this case, all the attributes of the user are being set to the issue, for instance the issue.id becomes user.id, etc ... This patch solves the issue and pases all the tests. --- lib/jira/base.rb | 1 + lib/jira/version.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jira/base.rb b/lib/jira/base.rb index bbbd01f6..38bc948c 100644 --- a/lib/jira/base.rb +++ b/lib/jira/base.rb @@ -401,6 +401,7 @@ def set_attrs(hash, clobber=true, target = nil) else hash.each do |k, v| if v.is_a?(Hash) + target[k] = {} if !target.key?(k) || target[k].nil? set_attrs(v, clobber, target[k]) else target[k] = v diff --git a/lib/jira/version.rb b/lib/jira/version.rb index 12e80823..0bb0e461 100644 --- a/lib/jira/version.rb +++ b/lib/jira/version.rb @@ -1,3 +1,3 @@ module JIRA - VERSION = "1.1.0" + VERSION = "1.1.1" end