From 7a3d0c88978432a5d6a7b51572f2e7249704075b Mon Sep 17 00:00:00 2001 From: Tim Jones Date: Sun, 20 Jan 2019 16:27:08 -0800 Subject: [PATCH] Add support for moving stories between projects --- lib/tracker_api/resources/story.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/tracker_api/resources/story.rb b/lib/tracker_api/resources/story.rb index 3e1ebad..c34f41f 100644 --- a/lib/tracker_api/resources/story.rb +++ b/lib/tracker_api/resources/story.rb @@ -54,6 +54,7 @@ class UpdateRepresenter < Representable::Decorator property :deadline property :requested_by_id property :owner_ids, if: ->(_) { !owner_ids.blank? } + property :project_id # Use render_empty: false to address: https://github.com/dashofcode/tracker_api/issues/110 # - The default value of the labels attribute in Resources::Story is an empty array. @@ -165,6 +166,17 @@ def transitions(params = {}) end end + # Returns the story's original ("undirtied") project_id + # + # @return Integer + def project_id + if dirty_attributes.key?(:project_id) + original_attributes[:project_id] + else + @project_id + end + end + # @param [Hash] params attributes to create the task with # @return [Task] newly created Task def create_task(params)