lib/tracker_api/resources/story.rb in tracker_api-1.5.0 vs lib/tracker_api/resources/story.rb in tracker_api-1.6.0
- old
+ new
@@ -32,10 +32,11 @@
attribute :requested_by, Person
attribute :requested_by_id, Integer
attribute :story_type, String # (feature, bug, chore, release)
attribute :task_ids, [Integer]
attribute :tasks, [Task]
+ attribute :transitions, [StoryTransition]
attribute :updated_at, DateTime
attribute :url, String
class UpdateRepresenter < Representable::Decorator
@@ -72,13 +73,28 @@
else
label
end
# Use attribute writer to get coercion and dirty tracking.
- self.labels = (labels ? labels.dup : []).push(new_label)
+ self.labels = (labels ? labels.dup : []).push(new_label).uniq
end
+ # Adds a new owner to the story.
+ #
+ # @param [Person|Fixnum] owner
+ def add_owner(owner)
+ owner_id = if owner.kind_of?(Fixnum)
+ owner_id = owner
+ else
+ raise ArgumentError, 'Valid Person expected.' unless owner.instance_of?(Resources::Person)
+ owner_id = owner.id
+ end
+
+ # Use attribute writer to get coercion and dirty tracking.
+ self.owner_ids = (owner_ids ? owner_ids.dup : []).push(owner_id).uniq
+ end
+
# Provides a list of all the activity performed on the story.
#
# @param [Hash] params
# @return [Array[Activity]]
def activity(params = {})
@@ -116,9 +132,21 @@
def owners(params = {})
if params.blank? && @owners.present?
@owners
else
@owners = Endpoints::StoryOwners.new(client).get(project_id, id, params)
+ end
+ end
+
+ # Provides a list of all the transitions of the story.
+ #
+ # @param [Hash] params
+ # @return [Array[StoryTransition]]
+ def transitions(params = {})
+ if params.blank? && @transitions.present?
+ @transitions
+ else
+ @transitions = Endpoints::StoryTransitions.new(client).get(project_id, id, params)
end
end
# @param [Hash] params attributes to create the task with
# @return [Task] newly created Task