diff options
Diffstat (limited to 'app/models/project_services/issue_tracker_service.rb')
-rw-r--r-- | app/models/project_services/issue_tracker_service.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index f54497fc6d8..3a1130ffc15 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -5,6 +5,8 @@ class IssueTrackerService < Service default_value_for :category, 'issue_tracker' + before_save :handle_properties + # Pattern used to extract links from comments # Override this method on services that uses different patterns # This pattern does not support cross-project references @@ -18,6 +20,37 @@ class IssueTrackerService < Service end end + # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084 + def title + if title_attribute = read_attribute(:title) + title_attribute + elsif self.properties && self.properties['title'].present? + self.properties['title'] + else + default_title + end + end + + # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084 + def description + if description_attribute = read_attribute(:description) + description_attribute + elsif self.properties && self.properties['description'].present? + self.properties['description'] + else + default_description + end + end + + def handle_properties + properties.slice('title', 'description').each do |key, _| + current_value = self.properties.delete(key) + value = attribute_changed?(key) ? attribute_change(key).last : current_value + + write_attribute(key, value) + end + end + def default? default end |